2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 /* standard library header */
20 /* SLP library header */
24 #include "PKCS15DODF.h"
25 #include "SimpleTLV.h"
27 namespace smartcard_service_api
29 // PKCS15DODF::PKCS15DODF():PKCS15Object()
34 PKCS15DODF::PKCS15DODF(unsigned int fid, Channel *channel):PKCS15Object(channel)
38 if ((ret = select(fid)) == 0)
40 ByteArray dodfData, extra;
42 SCARD_DEBUG("response : %s", selectResponse.toString());
44 if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
46 SCARD_DEBUG("odfData : %s", dodfData.toString());
52 SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
57 SCARD_DEBUG_ERR("select failed, [%d]", ret);
61 PKCS15DODF::PKCS15DODF(ByteArray path, Channel *channel):PKCS15Object(channel)
65 if ((ret = select(path)) == 0)
67 ByteArray dodfData, extra;
69 SCARD_DEBUG("response : %s", selectResponse.toString());
71 if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
73 SCARD_DEBUG("dodfData : %s", dodfData.toString());
79 SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
84 SCARD_DEBUG_ERR("select failed, [%d]", ret);
88 PKCS15DODF::~PKCS15DODF()
92 bool PKCS15DODF::parseData(ByteArray data)
97 while (tlv.decodeTLV())
101 case (unsigned int)0xA1 : /* CHOICE 1 : OidDO */
103 PKCS15OID oid(tlv.getValue());
105 SCARD_DEBUG("OID DataObject");
107 pair<ByteArray, PKCS15OID> newPair(oid.getOID(), oid);
108 mapOID.insert(newPair);
113 SCARD_DEBUG("Unknown tlv : t [%X], l [%d], v %s", tlv.getTag(), tlv.getLength(), tlv.getValue().toString());
118 SCARD_DEBUG("dataList.size() = %d", mapOID.size());
123 int PKCS15DODF::searchOID(ByteArray oid, ByteArray &data)
126 map<ByteArray, PKCS15OID>::iterator item;
128 item = mapOID.find(oid);
129 if (item != mapOID.end())
131 data = item->second.getPath();
138 } /* namespace smartcard_service_api */