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.
19 #include "PKCS15OID.h"
20 #include "SimpleTLV.h"
22 namespace smartcard_service_api
24 PKCS15OID::PKCS15OID(const ByteArray &data)
29 PKCS15OID::~PKCS15OID()
33 bool PKCS15OID::parseOID(const ByteArray &data)
40 while (tlv.decodeTLV() == true)
44 case PKCS15::TAG_SEQUENCE :
47 /* common object attribute */
48 tlv.enterToValueTLV();
49 if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */
51 name = tlv.getValue();
53 tlv.returnToParentTLV();
57 /* common object attribute */
58 /* if you want to use this value, add member variable and parse here */
59 // _ERR("common object attribute is empty");
63 case 0xA0 : /* CHOICE 0 : External Oid??? */
64 _ERR("oid doesn't exist");
67 case 0xA1 : /* CHOICE 1 : OidDO */
68 tlv.enterToValueTLV();
71 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
73 tlv.enterToValueTLV();
76 if (tlv.decodeTLV() == true && tlv.getTag() == (unsigned int)0x06) /* ?? */
80 _DBG("oid : %s", oid.toString().c_str());
88 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
90 path = SimpleTLV::getOctetString(tlv.getValue());
92 _DBG("path : %s", path.toString().c_str());
98 _ERR("sequence is empty");
101 tlv.returnToParentTLV();
105 _ERR("common dataobject attribute is empty");
107 tlv.returnToParentTLV();
112 _ERR("Unknown tag : 0x%02X", tlv.getTag());
121 } /* namespace smartcard_service_api */