2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "APDUHelper.h"
22 #include "SimpleTLV.h"
24 namespace smartcard_service_api
26 static unsigned char path_efdir[] = { 0x2f, 0x00 };
27 static ByteArray PATH_EFDIR(ARRAY_AND_SIZE(path_efdir));
29 EFDIR::EFDIR(Channel *channel) : FileObject(channel)
33 EFDIR::EFDIR(Channel *channel, const ByteArray &selectResponse) :
34 FileObject(channel, selectResponse)
46 ret = FileObject::select(PATH_EFDIR, false);
47 if (ret < SCARD_ERROR_OK)
49 _ERR("EFDIR select failed, [%d]", ret);
55 const ByteArray EFDIR::parseRecord(const Record &record, const ByteArray &aid)
59 SimpleTLV tlv(record.getData());
61 if (tlv.decodeTLV() == true && tlv.getTag() == 0x61)
63 tlv.enterToValueTLV();
64 while (tlv.decodeTLV() == true)
69 if (tlv.getValue() == aid)
72 case 0x50 : /* label */
74 case 0x51 : /* path */
75 result = tlv.getValue();
81 tlv.returnToParentTLV();
85 _DBG("Found!! : path %s", result.toString().c_str());
96 const ByteArray EFDIR::getPathByAID(const ByteArray &aid)
103 for (id = 1; status >= 0; id++)
105 status = readRecord(0, id, record);
108 result = parseRecord(record, aid);
109 if (result.size() > 0)
116 } /* namespace smartcard_service_api */