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 :
51 /* common object attribute */
52 tlv.enterToValueTLV();
53 if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */ {
54 name = tlv.getValue();
55 SECURE_LOGD("name : %s", name.toString().c_str());
57 tlv.returnToParentTLV();
59 /* common object attribute */
60 /* if you want to use this value, add member variable and parse here */
61 // _ERR("common object attribute is empty");
65 case 0xA0 : /* CHOICE 0 : External Oid??? */
66 _ERR("oid doesn't exist");
69 case 0xA1 : /* CHOICE 1 : OidDO */
70 tlv.enterToValueTLV();
73 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE) {
74 tlv.enterToValueTLV();
77 if (tlv.decodeTLV() == true && tlv.getTag() == (unsigned int)0x06) /* ?? */ {
80 _DBG("oid : %s", oid.toString().c_str());
86 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE) {
87 path = SimpleTLV::getOctetString(tlv.getValue());
89 _DBG("path : %s", path.toString().c_str());
93 _ERR("sequence is empty");
96 tlv.returnToParentTLV();
98 _ERR("common dataobject attribute is empty");
100 tlv.returnToParentTLV();
105 _ERR("Unknown tag : 0x%02X", tlv.getTag());
114 } /* namespace smartcard_service_api */