我有空的JavaCOS A40智能卡,并希望将其设置为PKCS PKI卡。
我将使用它作为ssh密钥和电子合同签名。俄罗斯不像欧盟国家那样为公民提供基于智能卡的e-id。商业电子签名提供商正在销售某种受密码保护的usb驱动器,这是不安全的,因为您可以很容易地导出私钥。他们也卖普通的智能卡,但它们真的很贵(x10-x20比空javacard)和寿命短(大约1年)。所以我想用javacard的RSA算法做我自己的PKI卡。
现在我的javacard处于OP_READY状态,我没有改变它,因为改变是不可逆的。它使用默认密钥,任何人都可以上传任何内容。我在Ubuntu上使用ACR38U阅读器和pcsc linux驱动程序,它可以正常工作,所以我默认使用GlobalPlatformPro上传PKI IsoApplet。所以GP的输出是:
java -jar gp.jar -list
Warning: no keys given, using default test key 404142434445464748494A4B4C4D4E4F
ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement
APP: F276A288BCFBA69D34F31001 (SELECTABLE)
Privs: CardReset
PKG: F276A288BCFBA69D34F310 (LOADED)
Version: 1.0
Applet: F276A288BCFBA69D34F31001cardpeek成功地连接到它,我可以向applet发送低级命令

但是,当我尝试使用opensc prober连接到卡和小程序以查看应答请求(ATR)时,opensc-tool --reader 0 --atr失败。See maximum debug info
简写版本:
opensc-tool --reader 0 --atr -vv
Connecting to card in reader ACS ACR 38U-CCID 00 00...
0x7fc849e7e740 22:17:14.634 [opensc-tool] card.c:200:sc_connect_card: called
0x7fc849e7e740 22:17:14.634 [opensc-tool] card-entersafe.c:138:entersafe_match_card: called
Failed to connect to card: Card command failed
0x7fc849e7e740 22:17:14.797 [opensc-tool] ctx.c:870:sc_release_context: called根据制造商信息,卡支持ISO7816上的T=0,但opensc尝试与T=1通信。那么我该如何解决这个问题呢?
似乎,opensc工具是不可定制的。我需要使用pkcs15-crypt,但它无法连接。我可以更换驱动程序,使用补丁重新编译opensc,或者使用其他实用程序吗?例如,我如何使用其他方法来使用OpenPGP?
发布于 2018-09-21 20:05:34
您的问题肯定不是传输协议的问题,因为它与卡通信的是APDU。在查看日志记录时,从ATR卡似乎错误地猜测该卡是epass2003
0x7f175a21e740 22:14:13.904 [opensc-tool] card.c:287:sc_connect_card: matched: epass2003然后对它执行一条命令:
0x7f175a21e740 22:14:13.904 [opensc-tool] apdu.c:378:sc_single_transmit: CLA:0, INS:CA, P1:1, P2:86, data(0) (nil)
0x7f175a21e740 22:14:13.904 [opensc-tool] reader-pcsc.c:283:pcsc_transmit: reader 'ACS ACR 38U-CCID 00 00'
0x7f175a21e740 22:14:13.904 [opensc-tool] reader-pcsc.c:284:pcsc_transmit:
Outgoing APDU (5 bytes):
00 CA 01 86 00 .....
0x7f175a21e740 22:14:13.904 [opensc-tool] reader-pcsc.c:212:pcsc_internal_transmit: called
0x7f175a21e740 22:14:13.912 [opensc-tool] reader-pcsc.c:293:pcsc_transmit:
Incoming APDU (2 bytes):
6D 00 m.
0x7f175a21e740 22:14:13.912 [opensc-tool] apdu.c:390:sc_single_transmit: returning with: 0 (Success)
0x7f175a21e740 22:14:13.912 [opensc-tool] apdu.c:543:sc_transmit: returning with: 0 (Success)
0x7f175a21e740 22:14:13.912 [opensc-tool] card.c:459:sc_unlock: called
0x7f175a21e740 22:14:13.912 [opensc-tool] reader-pcsc.c:662:pcsc_unlock: called
0x7f175a21e740 22:14:13.921 [opensc-tool] card-epass2003.c:189:epass2003_check_sw: Instruction code not supported or invalid
0x7f175a21e740 22:14:13.921 [opensc-tool] card-epass2003.c:1118:get_data: get_data failed: -1204 (Unsupported INS byte in APDU)现在,这个命令是通过T=1中的通信通道执行的(如果该卡还支持T=CL,那么它就不太可能只支持T=0,因为T=CL和T=1非常相似-在更高的级别上)。不仅如此,它正确地返回了一个结果,即使这是更高级别的错误条件: 6D00,这意味着不支持指令。
这会导致高电平错误条件:
Failed to connect to card: Card command failed这有点误导,因为它确实连接到了卡,只是无法使用get data命令从卡中获取任何数据。这并不奇怪,因为它没有首先选择任何小程序,并且获取数据(使用isn CA)不太可能出现在根文件夹/小程序中。
TL;DR您的连接正常,现在通过向其发出GlobalPlatform卡管理器命令开始对其进行编程。如果可能,使用不同的工具或获取opensc工具来跳过识别阶段/初始命令。
发布于 2018-09-22 19:38:49
IsoApplet和OpenPGP是两个不同的世界。要获得OpenPGP支持,可以在github上查看ANSSI-FR的SmartPGP,或者在Github上查看ykneo openpgp(也是在Github上)。
对于签名,您也不需要pkcs15-crypt,而是应该通过PKCS#11库来工作。
由于此特定原因-卡与epass匹配,请在opensc.conf中禁用epass驱动程序。
https://stackoverflow.com/questions/52131519
复制相似问题