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 */
19 /* SLP library header */
23 #include "PKCS15DODF.h"
24 #include "SimpleTLV.h"
26 namespace smartcard_service_api
28 // PKCS15DODF::PKCS15DODF():PKCS15Object()
33 PKCS15DODF::PKCS15DODF(unsigned int fid, Channel *channel):PKCS15Object(channel)
37 if ((ret = select(fid)) == 0)
39 ByteArray dodfData, extra;
41 _DBG("response : %s", selectResponse.toString());
43 if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
45 _DBG("odfData : %s", dodfData.toString());
51 _ERR("readBinary failed, [%d]", ret);
56 _ERR("select failed, [%d]", ret);
60 PKCS15DODF::PKCS15DODF(ByteArray path, Channel *channel):PKCS15Object(channel)
64 if ((ret = select(path)) == 0)
66 ByteArray dodfData, extra;
68 _DBG("response : %s", selectResponse.toString());
70 if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
72 _DBG("dodfData : %s", dodfData.toString());
78 _ERR("readBinary failed, [%d]", ret);
83 _ERR("select failed, [%d]", ret);
87 PKCS15DODF::~PKCS15DODF()
91 bool PKCS15DODF::parseData(ByteArray data)
96 while (tlv.decodeTLV())
100 case (unsigned int)0xA1 : /* CHOICE 1 : OidDO */
102 PKCS15OID oid(tlv.getValue());
104 _DBG("OID DataObject");
106 pair<ByteArray, PKCS15OID> newPair(oid.getOID(), oid);
107 mapOID.insert(newPair);
112 _DBG("Unknown tlv : t [%X], l [%d], v %s", tlv.getTag(), tlv.getLength(), tlv.getValue().toString());
117 _DBG("dataList.size() = %d", mapOID.size());
122 int PKCS15DODF::searchOID(ByteArray oid, ByteArray &data)
125 map<ByteArray, PKCS15OID>::iterator item;
127 item = mapOID.find(oid);
128 if (item != mapOID.end())
130 data = item->second.getPath();
137 } /* namespace smartcard_service_api */