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 "APDUHelper.h"
27 namespace smartcard_service_api
29 static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50,
30 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
31 ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
33 PKCS15::PKCS15(Channel *channel)
34 : PKCS15Object(channel), odf(NULL)
38 ret = select(PKCS15::PKCS15_AID);
39 if (ret == FileObject::SUCCESS)
41 SCARD_DEBUG("response : %s", selectResponse.toString());
43 else if (ret == ResponseHelper::ERROR_FILE_NOT_FOUND)
45 SCARD_DEBUG_ERR("PKCS15 AID not found, search in EF DIR");
47 if (selectFromEFDIR() == true)
49 SCARD_DEBUG("response : %s", selectResponse.toString());
53 SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret);
58 SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret);
62 PKCS15::PKCS15(Channel *channel, ByteArray selectResponse)
63 : PKCS15Object(channel, selectResponse), odf(NULL)
76 bool PKCS15::selectFromEFDIR()
82 path = dir.getPathByAID(PKCS15_AID);
83 if (path.getLength() > 0)
87 ret = select(path, false);
88 if (ret == FileObject::SUCCESS)
94 SCARD_DEBUG_ERR("path select failed, [%d]", ret);
99 SCARD_DEBUG_ERR("PKCS15 not found");
105 PKCS15ODF *PKCS15::getODF()
109 odf = new PKCS15ODF(channel);
111 if (odf != NULL && odf->isClosed() == true)
113 SCARD_DEBUG_ERR("failed to open ODF");
120 SCARD_DEBUG("odf [%p]", odf);
124 } /* namespace smartcard_service_api */