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.
17 /* standard library header */
20 /* SLP library header */
25 #include "APDUHelper.h"
26 #include "SimpleTLV.h"
28 namespace smartcard_service_api
30 static unsigned char path_efdir[] = { 0x2f, 0x00 };
31 static ByteArray PATH_EFDIR(ARRAY_AND_SIZE(path_efdir));
33 EFDIR::EFDIR(Channel *channel) : FileObject(channel)
37 EFDIR::EFDIR(Channel *channel, const ByteArray &selectResponse) :
38 FileObject(channel, selectResponse)
50 ret = FileObject::select(PATH_EFDIR, false);
51 if (ret < SCARD_ERROR_OK)
53 _ERR("EFDIR select failed, [%d]", ret);
59 const ByteArray EFDIR::parseRecord(const Record &record, const ByteArray &aid)
63 SimpleTLV tlv(record.getData());
65 if (tlv.decodeTLV() == true && tlv.getTag() == 0x61)
67 tlv.enterToValueTLV();
68 while (tlv.decodeTLV() == true)
73 if (tlv.getValue() == aid)
76 case 0x50 : /* label */
78 case 0x51 : /* path */
79 result = tlv.getValue();
85 tlv.returnToParentTLV();
87 if (matched == true) {
88 _DBG("Found!! : path %s", result.toString().c_str());
97 const ByteArray EFDIR::getPathByAID(const ByteArray &aid)
104 for (id = 1; status >= 0; id++)
106 status = readRecord(0, id, record);
109 result = parseRecord(record, aid);
110 if (result.size() > 0)
117 } /* namespace smartcard_service_api */