{"action":"created","issue":{"url":"https://api.github.com/repos/OpenSC/OpenSC/issues/561","labels_url":"https://api.github.com/repos/OpenSC/OpenSC/issues/561/labels{/name}","comments_url":"https://api.github.com/repos/OpenSC/OpenSC/issues/561/comments","events_url":"https://api.github.com/repos/OpenSC/OpenSC/issues/561/events","html_url":"https://github.com/OpenSC/OpenSC/issues/561","id":107869354,"number":561,"title":"Certificate not listed at PKCS#11 interface but with pkcs15-tool -D","user":{"login":"CardContact","id":2071184,"avatar_url":"https://avatars.githubusercontent.com/u/2071184?v=3","gravatar_id":"","url":"https://api.github.com/users/CardContact","html_url":"https://github.com/CardContact","followers_url":"https://api.github.com/users/CardContact/followers","following_url":"https://api.github.com/users/CardContact/following{/other_user}","gists_url":"https://api.github.com/users/CardContact/gists{/gist_id}","starred_url":"https://api.github.com/users/CardContact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CardContact/subscriptions","organizations_url":"https://api.github.com/users/CardContact/orgs","repos_url":"https://api.github.com/users/CardContact/repos","events_url":"https://api.github.com/users/CardContact/events{/privacy}","received_events_url":"https://api.github.com/users/CardContact/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-23T08:06:04Z","updated_at":"2015-09-23T13:10:17Z","closed_at":null,"body":"For a card with EC Private Key and X.509 certificate, pkcs15-tool -D shows the certificate object:\r\n\r\nc:\\Program Files (x86)\\OpenSC Project\\OpenSC\\tools>pkcs15-tool.exe -c -k\r\nUsing reader with a card: Gemplus USB SmartCard Reader 0\r\nX.509 Certificate [f8654afe-c4c4-4680-a574-9e86228234a0]\r\n        Object Flags   : [0x0]\r\n        Authority      : no\r\n        Path           : ce01\r\n        ID             : 66383635346166652d633463342d343638302d613537342d396538363232383233346130\r\n\r\nPrivate EC Key [f8654afe-c4c4-4680-a574-9e86228234a0]\r\n        Object Flags   : [0x3], private, modifiable\r\n        Usage          : [0xE], decrypt, sign, signRecover\r\n        Access Flags   : [0x1D], sensitive, alwaysSensitive, neverExtract, local\r\n        FieldLength    : 192\r\n        Key ref        : 1 (0x1)\r\n        Native         : yes\r\n        Path           : e82b0601040181c31f0201::\r\n        Auth ID        : 01\r\n        ID             : 66383635346166652d633463342d343638302d613537342d396538363232383233346130\r\n        MD:guid        : {15621088-310b-4657-538f-843268ec641c}\r\n          :cmap flags  : 0x0\r\n          :sign        : 0\r\n          :key-exchange: 0\r\n\r\nWith pkcs11-tool the certificate is not shown:\r\n\r\nc:\\Program Files (x86)\\OpenSC Project\\OpenSC\\tools>pkcs11-tool.exe --module opensc-pkcs11 -O --slot 1 --login\r\n\r\nLogging in to \"SmartCard-HSM (UserPIN)\".\r\n\r\nPlease enter User PIN: 2015-09-22 17:44:44.103 cannot lock memory, \r\nsensitive data may be paged to disk\r\n\r\nPrivate Key Object; EC\r\n  label:      f8654afe-c4c4-4680-a574-9e86228234a0\r\n  ID:         66383635346166652d633463342d343638302d613537342d396538363232383233346130\r\n  Usage:      decrypt, sign\r\n\r\nThe log reveals, that the code has an issue with the curve, but the same code is used by pkcs15-tool.\r\n\r\n2015-09-23 08:44:45.149 [opensc-pkcs11] pkcs15-pubkey.c:1463:sc_pkcs15_fix_ec_parameters: Unsupported named curve: -1408 (Not supported)\r\n2015-09-23 08:44:45.149 [opensc-pkcs11] pkcs15-pubkey.c:1331:sc_pkcs15_pubkey_from_spki_fields: failed to fix EC parameters: -1408 (Not supported)\r\n2015-09-23 08:44:45.149 decoding of ASN.1 object 'subjectPublicKeyInfo' failed: Not supported\r\n2015-09-23 08:44:45.149 decoding of ASN.1 object 'tbsCertificate' failed: Not supported\r\n2015-09-23 08:44:45.149 [opensc-pkcs11] pkcs15-cert.c:109:parse_x509_cert: ASN.1 parsing of certificate failed: -1408 (Not supported)\r\n2015-09-23 08:44:45.149 [opensc-pkcs11] pkcs15-cert.c:198:sc_pkcs15_read_certificate: returning with: -1401 (Invalid ASN.1 object)\r\n2015-09-23 08:44:45.149 Found 0 data objects\r\n2015-09-23 08:44:45.149 Looking for objects related to object 0\r\n2015-09-23 08:44:45.149 Object is a private key and has id 66383635346166652d633463342d343638302d613537342d396538363232383233346130\r\n2015-09-23 08:44:45.149 found 1 FW objects\r\n2015-09-23 08:44:45.149 Found 1 FW objects objects\r\n2015-09-23 08:44:45.149 Found 2 authentication objects\r\n2015-09-23 08:44:45.149 Found authentication object 'UserPIN'\r\n2015-09-23 08:44:45.149 Create slot (p11card 00A0B608, fw_data 00A17A68, auth 00A17FB0, app_info 00000000)\r\n2015-09-23 08:44:45.149 Allocated slot 0x1 for card in reader Gemplus USB SmartCard Reader 0\r\n2015-09-23 08:44:45.149 Initialized token 'SmartCard-HSM (UserPIN)' in slot 0x1\r\n2015-09-23 08:44:45.149 Add objects related to PIN('UserPIN',ID:01)\r\n2015-09-23 08:44:45.149 ObjID(00A137A8,f8654afe-c4c4-4680-a574-9e86228234a0,104):01\r\n2015-09-23 08:44:45.149 Slot:00A16540, obj:00A137A8  Adding private key 0 to PIN 'UserPIN'\r\n2015-09-23 08:44:45.149 Slot:1 Setting object handle of 0x0 to 0xa137a8\r\n2015-09-23 08:44:45.149 Set first slot: 00A16540\r\n2015-09-23 08:44:45.149 Add public objects to slot 00A16540\r\n2015-09-23 08:44:45.149 1 public objects to process\r\n2015-09-23 08:44:45.149 All tokens created\r\n\r\nThe code worked in 0.14, so the bug was introduced on the way to 0.15\r\n"},"comment":{"url":"https://api.github.com/repos/OpenSC/OpenSC/issues/comments/142594215","html_url":"https://github.com/OpenSC/OpenSC/issues/561#issuecomment-142594215","issue_url":"https://api.github.com/repos/OpenSC/OpenSC/issues/561","id":142594215,"user":{"login":"dengert","id":865329,"avatar_url":"https://avatars.githubusercontent.com/u/865329?v=3","gravatar_id":"","url":"https://api.github.com/users/dengert","html_url":"https://github.com/dengert","followers_url":"https://api.github.com/users/dengert/followers","following_url":"https://api.github.com/users/dengert/following{/other_user}","gists_url":"https://api.github.com/users/dengert/gists{/gist_id}","starred_url":"https://api.github.com/users/dengert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dengert/subscriptions","organizations_url":"https://api.github.com/users/dengert/orgs","repos_url":"https://api.github.com/users/dengert/repos","events_url":"https://api.github.com/users/dengert/events{/privacy}","received_events_url":"https://api.github.com/users/dengert/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T13:10:17Z","updated_at":"2015-09-23T13:10:17Z","body":"See if this may have caused a problem. It is from April:\r\n\r\nhttps://github.com/OpenSC/OpenSC/commit/ee23d286547d730dc82011857b318186140b31f5\r\n\r\nIs the curve size a multiple of 8 bits?"}}