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 */
24 #include "PKCS15OID.h"
25 #include "SimpleTLV.h"
27 namespace smartcard_service_api
29 PKCS15OID::PKCS15OID(const ByteArray &data)
34 PKCS15OID::~PKCS15OID()
38 bool PKCS15OID::parseOID(const ByteArray &data)
45 while (tlv.decodeTLV() == true)
49 case PKCS15::TAG_SEQUENCE :
52 /* common object attribute */
53 tlv.enterToValueTLV();
54 if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */
56 name = tlv.getValue();
58 tlv.returnToParentTLV();
62 /* common object attribute */
63 /* if you want to use this value, add member variable and parse here */
64 // _ERR("common object attribute is empty");
68 case 0xA0 : /* CHOICE 0 : External Oid??? */
69 _ERR("oid doesn't exist");
72 case 0xA1 : /* CHOICE 1 : OidDO */
73 tlv.enterToValueTLV();
76 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
78 tlv.enterToValueTLV();
81 if (tlv.decodeTLV() == true && tlv.getTag() == (unsigned int)0x06) /* ?? */
85 _DBG("oid : %s", oid.toString().c_str());
93 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
95 path = SimpleTLV::getOctetString(tlv.getValue());
97 _DBG("path : %s", path.toString().c_str());
103 _ERR("sequence is empty");
106 tlv.returnToParentTLV();
110 _ERR("common dataobject attribute is empty");
112 tlv.returnToParentTLV();
117 _ERR("Unknown tag : 0x%02X", tlv.getTag());
126 } /* namespace smartcard_service_api */