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 */
25 #include "PKCS15OID.h"
26 #include "SimpleTLV.h"
28 namespace smartcard_service_api
30 PKCS15OID::PKCS15OID(ByteArray data)
35 PKCS15OID::~PKCS15OID()
39 bool PKCS15OID::parseOID(ByteArray data)
46 while (tlv.decodeTLV() == true)
50 case PKCS15::TAG_SEQUENCE :
51 if (tlv.getLength() > 0)
53 /* common object attribute */
54 tlv.enterToValueTLV();
55 if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */
57 name = tlv.getValue();
58 SCARD_DEBUG("name : %s", name.toString());
60 tlv.returnToParentTLV();
64 /* common object attribute */
65 /* if you want to use this value, add member variable and parse here */
66 // SCARD_DEBUG_ERR("common object attribute is empty");
70 case 0xA0 : /* CHOICE 0 : External Oid??? */
71 SCARD_DEBUG_ERR("oid doesn't exist");
74 case 0xA1 : /* CHOICE 1 : OidDO */
75 tlv.enterToValueTLV();
78 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
80 tlv.enterToValueTLV();
83 if (tlv.decodeTLV() == true && tlv.getTag() == (unsigned int)0x06) /* ?? */
87 SCARD_DEBUG("oid : %s", oid.toString());
91 SCARD_DEBUG_ERR("oid is empty");
95 if (tlv.decodeTLV() == true && tlv.getTag() == PKCS15::TAG_SEQUENCE)
97 path = SimpleTLV::getOctetString(tlv.getValue());
99 SCARD_DEBUG("path : %s", path.toString());
105 SCARD_DEBUG_ERR("sequence is empty");
108 tlv.returnToParentTLV();
112 SCARD_DEBUG_ERR("common dataobject attribute is empty");
114 tlv.returnToParentTLV();
119 SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
129 ByteArray PKCS15OID::getOID()
134 ByteArray PKCS15OID::getName()
139 ByteArray PKCS15OID::getPath()
144 } /* namespace smartcard_service_api */