Closed zosocanuck closed 8 years ago
What versions of OpenSSL, libp11 and engine_pkcs11?
Are you using the OpenSC pkcs11 module?
What smart card are you using?
How did you create the key? Can you use opensc or openssl to read the pubkey?
Are you using the OpenSC pkcs11 module?
On 11/5/2015 2:50 PM, Ivan Wallis wrote:
Hi,
I'm attempting to generate a csr via openssl:
openssl req -engine pkcs11 -new -key slot_492971157-label_myecdsa -keyform engine -out req.pem -x509 -subj "/CN=John Smith"
The error is:
engine "pkcs11" set. 139637347223200:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139637347223200:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306:
[pid 2086] ERR_load_crypto_strings(0x469a01, 0x7fff82159856, 0x7fff821589e8, 0) = 0x7f0ca9d34cb8 [pid 2086] OPENSSL_load_builtin_modules(0xcbe010, 0xcd83a0, 0, 0x7fff82157dd0) = 1 [pid 2086] CONF_modules_load(0xcd83a0, 0, 0, 2) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0, 0x469b27, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0, 0x47736a, 0) = 0xcd8d00 [pid 2086] NCONF_get_section(0xcd83a0, 0xcd8d00, 11, 0) = 0xcd90b0 [pid 2086] sk_num(0xcd90b0, 0xcd8d00, 8, 0) = 3 [pid 2086] sk_value(0xcd90b0, 0, 8, 0) = 0xcd94a0 [pid 2086] OBJ_create(0xcd9500, 0xcd94c0, 0xcd94c0, 0) = 958 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] sk_value(0xcd90b0, 1, 0x7f0ca9b47768, 0xcdf040) = 0xcd9520 [pid 2086] OBJ_create(0xcd9580, 0xcd9540, 0xcd9540, 0xcdf040) = 959 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] sk_value(0xcd90b0, 2, 0x7f0ca9b47768, 0xcdf040) = 0xcd95a0 [pid 2086] OBJ_create(0xcd9600, 0xcd95c0, 0xcd95c0, 0xcdf040) = 960 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b30, 0xcdf040) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b3b, 0) = 0xcdaf00 [pid 2086] X509V3_set_ctx(0x7fff82157e00, 0, 0, 0) = 0xcdaf00 [pid 2086] X509V3_set_nconf(0x7fff82157e00, 0xcd83a0, 0, 0) = 0x7f0ca9f93f00 [pid 2086] X509V3_EXT_add_nconf(0xcd83a0, 0x7fff82157e00, 0xcdaf00, 0) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b4b, 0xcdf060) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b5a, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b6a, 0) = 0xcdaf80 [pid 2086] ASN1_STRING_set_default_mask_asc(0xcdaf80, 0x469b6a, 11, 0) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x4699c0, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b76, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] BIO_s_file(0, 0xffffffff, 0x7f0ca9b47788, 0) = 0x7f0ca9f908a0 [pid 2086] BIO_new(0x7f0ca9f908a0, 0xffffffff, 0x7f0ca9b47788, 0) = 0xcdf720 [pid 2086] BIO_s_file(0xcdf720, 436, 0x7f0ca9ce9436, 4) = 0x7f0ca9f908a0 [pid 2086] BIO_new(0x7f0ca9f908a0, 436, 0x7f0ca9ce9436, 4) = 0xcdf7a0 [pid 2086] ENGINE_by_id(0x7fff821597fd, 0x7fff821597fe, 0, 4) = 0xcddf50 [pid 2086] ENGINE_ctrl_cmd(0xcddf50, 0x477486, 0, 0xcd81c0) = 1 [pid 2086] ENGINE_set_default(0xcddf50, 0xffff, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] ENGINE_get_id(0xcddf50, 187, 0x7f0ca9d296f4, 8) = 0x7f0ca9382368 [pid 2086] BIO_printf(0xcbe010, 0x4774b0, 0x7f0ca9382368, 8engine "pkcs11" set. ) = 21 [pid 2086] ENGINE_free(0xcddf50, 274, 0x7f0ca9ce91ba, 0) = 1 [pid 2086] ENGINE_load_private_key(0xcddf50, 0x7fff8215980e, 0xcd81c0, 0x7fff82157c00) = 0xcf3fe0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b85, 0xcfc4b0) = 0xcd8c80 [pid 2086] RAND_egd(0xcd8c80, 0xcbe010, 0, 0) = 0 [pid 2086] RAND_load_file(0xcd8c80, -1, 12, 0) = 0 [pid 2086] RAND_status(0xcd8c80, 0x7fff82157660, 0, -1) = 1 [pid 2086] X509_REQ_new(0x689160, 0x46a830, 0x7f0ca9d2ac53, 1) = 0xcfcb10 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469c01, 0x7f0ca9b47760) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469c08, 0xcfd170) = 0xcdada0 [pid 2086] NCONF_get_section(0xcd83a0, 0xcdada0, 2, 0) = 0xcd9da0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x4778d8, 0) = 0xcdae30 [pid 2086] NCONF_get_section(0xcd83a0, 0xcdae30, 10, 0) = 0xcdabf0 [pid 2086] X509_REQ_set_version(0xcfcb10, 0, 14, 0) = 1 [pid 2086] strlen("/CN=Ivan Wallis") = 15 [pid 2086] CRYPTO_malloc(16, 0x4772dc, 2134, 2134) = 0xcfc5f0 [pid 2086] CRYPTO_malloc(72, 0x4772dc, 2136, 0x7f0ca9b47760) = 0xcfd000 [pid 2086] CRYPTO_malloc(72, 0x4772dc, 2137, 0x7f0ca9b47760) = 0xcf4040 [pid 2086] CRYPTO_malloc(36, 0x4772dc, 2138, 0x7f0ca9b47760) = 0xcfc8a0 [pid 2086] X509_NAME_new(1, 0xcfc5ff, 0, 0xcfc5fe) = 0xcfc870 [pid 2086] OBJ_txt2nid(0xcfc5f0, 0x7f0ca9b47760, 0xcfc0a0, 0x7f0ca9b47760) = 13 [pid 2086] X509_NAME_add_entry_by_NID(0xcfc870, 13, 4097, 0xcfc5f3) = 1 [pid 2086] CRYPTO_free(0xcf4040, 0xffffffff, 0x7f0ca9b47768, 0xcfc130) = 0 [pid 2086] CRYPTO_free(0xcfd000, 0xffffffff, 0x7f0ca9b47780, 0xce6cd0) = 0 [pid 2086] CRYPTO_free(0xcfc5f0, 0xffffffff, 0x7f0ca9b47780, 0xcf4030) = 0 [pid 2086] CRYPTO_free(0xcfc8a0, 0xffffffff, 0x7f0ca9b47768, 0xcfc0e0) = 0 [pid 2086] X509_REQ_set_subject_name(0xcfcb10, 0xcfc870, 0x7f0ca9b47770, 0xcfd1d0) = 1 [pid 2086] X509_NAME_free(0xcfc870, 0xffffffff, 0x7f0ca9b47770, 0xcfcb30) = 0 [pid 2086] X509_REQ_set_pubkey(0xcfcb10, 0xcf3fe0, 0x7f0ca9b47770, 0xcfc830) = 1 [pid 2086] X509_new(1, 0xffffffff, 0x7f0ca9b47768, 0xcfc600) = 0xcfd4b0 [pid 2086] X509_set_version(0xcfd4b0, 2, 0x7f0ca9ce9436, 4) = 1 [pid 2086] X509_get_serialNumber(0xcfd4b0, 2, 0, 0xffffffff) = 0xcfc570 [pid 2086] BN_new(0, 0xcfc570, 0, 0xffffffff) = 0xcfc630 [pid 2086] BN_pseudo_rand(0xcfc630, 64, 0, 0) = 1 [pid 2086] BN_to_ASN1_INTEGER(0xcfc630, 0xcfc570, 1, 0) = 0xcfc570 [pid 2086] BN_free(0xcfc630, 0xcfd758, 1, 0) = 0 [pid 2086] X509_set_issuer_name(0xcfd4b0, 0xcfc430, 0x7f0ca9b47768, 0xcfd560) = 1 [pid 2086] X509_gmtime_adj(0xcfc0a0, 0, 0x7f0ca9b47770, 0xcfc860) = 0xcfc0a0 [pid 2086] X509_time_adj_ex(0xcfc4c0, 30, 0, 0) = 0xcfc4c0 [pid 2086] X509_set_subject_name(0xcfd4b0, 0xcfc430, 0xe000, 96) = 1 [pid 2086] X509_REQ_get_pubkey(0xcfcb10, 0xffffffff, 0x7f0ca9b47770, 0xcfc980) = 0xcfd050 [pid 2086] X509_set_pubkey(0xcfd4b0, 0xcfd050, 0x7f0ca9d2c813, 8) = 1 [pid 2086] EVP_PKEY_free(0xcfd050, 0xffffffff, 0x7f0ca9b47768, 0xcfce30) = 1 [pid 2086] X509V3_set_ctx(0x7fff82157e00, 0xcfd4b0, 0xcfd4b0, 0) = 1 [pid 2086] X509V3_set_nconf(0x7fff82157e00, 0xcd83a0, 0xcfd4b0, 0) = 0x7f0ca9f93f00 [pid 2086] X509V3_EXT_add_nconf(0xcd83a0, 0x7fff82157e00, 0xcdaf00, 0xcfd4b0) = 1 [pid 2086] EVP_MD_CTX_init(0x7fff82157bd0, 0xcfd4b0, 0xcf3fe0, 0) = 0 [pid 2086] EVP_MD_CTX_init(0x7fff82157bd0, 0xcfd4b0, 0, 0) = 0 [pid 2086] EVP_DigestSignInit(0x7fff82157bd0, 0x7fff82157bc0, 0, 0) = 1 [pid 2086] sk_num(0, 0, 0xcfe080, 0) = 0xffffffff [pid 2086] X509_sign_ctx(0xcfd4b0, 0x7fff82157bd0, 0xcfe080, 0) = 0 [pid 2086] EVP_MD_CTX_cleanup(0x7fff82157bd0, 0xffffffff, 0x7f0ca9b47780, 0xcfd1b0) = 1 [pid 2086] ERR_print_errors(0xcbe010, 0xffffffff, 0, 0139692372833952:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139692372833952:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0 [pid 2086] ERR_print_errors(0xcbe010, 473, 0x7f0ca9d2ae33, 8) = 0 [pid 2086] BIO_free(0xcdf720, 473, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] BIO_free_all(0xcdf7a0, 0xffffffff, 1, 0xcfe070) = 1 [pid 2086] EVP_PKEY_free(0xcf3fe0, 0xffffffff, 1, 0xcdf710) = 0 [pid 2086] X509_REQ_free(0xcfcb10, 0xffffffff, 0x7f0ca9b47778, 0xcfbc90) = 0 [pid 2086] X509_free(0xcfd4b0, 0xffffffff, 0x7f0ca9b47770, 0xcfc420) = 0 [pid 2086] ASN1_INTEGER_free(0, 0, 0, 0x7f0ca9c93be0) = 2 [pid 2086] OBJ_cleanup(0, 0x7f0ca9f80b60, 2, 0x7f0ca9c93be0) = 0 [pid 2086] NCONF_free(0xcd83a0, 0, 0, 0xcdf170) = 1 [pid 2086] lh_free(0xcd88e0, 0xffffffff, 0x7f0ca9b47770, 0xcda3c0) = 0 [pid 2086] CONF_modules_unload(1, 0, 0, 0xcdd650) = 0 [pid 2086] UI_destroy_method(0xcd81c0, 0xffffffff, 0x7f0ca9b47770, 0xcddd80) = 0 [pid 2086] OBJ_cleanup(0, 0xffffffff, 0x7f0ca9b47778, 0xcdddb0) = 0x7f0ca9f98480 [pid 2086] EVP_cleanup(0, 0xffffffff, 0, 0xcdddb0) = 0x7f0ca9f98480 [pid 2086] ENGINE_cleanup(0, 0x7f0ca9c7b650, 0, 0xcd7570) = 1 [pid 2086] CRYPTO_cleanup_all_ex_data(0, 0xffffffff, 0x7f0ca9b47770, 0xcd7f00) = 0 [pid 2086] ERR_remove_thread_state(0, 0, 0, 0xcbe150) = 0 [pid 2086] RAND_cleanup(0x7f0ca9b47760, 0, 0, 8) = 1 [pid 2086] ERR_free_strings(0, 0, 0, 8) = 8 [pid 2086] COMP_zlib_cleanup(0x689160, 380, 0x7f0ca9d2ae33, 8) = 8 [pid 2086] CRYPTO_mem_leaks(0xcbe010, 380, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] BIO_free(0xcbe010, 274, 0x7f0ca9ce91ba, 8) = 1 [pid 2086] exit(1 [pid 2086] +++ exited (status 1) +++
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34.
Douglas E. Engert DEEngert@gmail.com
Hi, OpenSSL version: 1.0.2d libp11 version: 0.3.0 engine_pkcs11 version: 0.2.0 Using the Thales nCipher PKCS#11 interface libcknfast.so against one of their HSMs. Key was created using the nCipher utilities. It is an ECDSA nistp256 keypair using the Thales debug tools i can get the ec_point.
I can try against a softhsm if necessary.
Can you dump the public key? The problem could be the the public key does not have the EC parameters, usually a named_curve.
There could also be a logon is needed.
Can you try using the pkcs11-spy to see what PKCS#11 returns.
On 11/5/2015 7:03 PM, Ivan Wallis wrote:
Hi, OpenSSL version: 1.0.2d libp11 version: 0.3.0 engine_pkcs11 version: 0.2.0 Using the Thales nCipher PKCS#11 interface libcknfast.so against one of their HSMs. Key was created using the nCipher utilities. It is an ECDSA nistp256 keypair using the Thales debug tools i can get the ec_point.
I can try against a softhsm if necessary.
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154251238.
Douglas E. Engert DEEngert@gmail.com
public key is:
04410490 b1f30cb1 04d743da d6165260 cf537b0f 2bdb454d 0632e6fb 7efca0ef d0faff2a 1233bc61 b6232ddb 6ef96156 fa660fc3 1702293d a764234b 22102c91 7780af
Note that I can get this to work if I use OpenSSL 1.0.1f and building with BUILD_WITH_ECS_LOCL_H against engine_pkcs11 0.1.8 and the dengert/libp11 build that supports ecdsa.
Here is partial output of running the nCipher PKCS#11 library in debug mode:
2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_PARAMS length 10 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_PARAMS pAtt->pValue= 10 bytes 06082a86 48ce3d03 0107
2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_POINT length 67 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_POINT pAtt->pValue= 67 bytes 04410490 b1f30cb1 04d743da d6165260 cf537b0f 2bdb454d 0632e6fb 7efca0ef d0faff2a 1233bc61 b6232ddb 6ef96156 fa660fc3 1702293d a764234b 22102c91 7780af
2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_SENSITIVE: true 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EXTRACTABLE: false 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_PARAMS length 10 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_PARAMS pAtt->pValue= 10 bytes 06082a86 48ce3d03 0107
2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_POINT length 67 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB >> C_GetAttributeValue 2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < CKA_EC_POINT pAtt->pValue= 67 bytes 04410490 b1f30cb1 04d743da d6165260 cf537b0f 2bdb454d 0632e6fb 7efca0ef d0faff2a 1233bc61 b6232ddb 6ef96156 fa660fc3 1702293d a764234b 22102c91 7780af
2015-11-05 21:20:19 [3980]: pkcs11: 000008CB < rv 0x00000000 (CKR_OK) 139738337183392:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139738337183392:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: 2015-11-05 21:20:19 [3980]: pkcs11: 00000000 >> C_Finalize 2015-11-05 21:20:19 [3980]: pkcs11: 00000000 < rv 0x00000000
using OpenSSL-1.0.2a, libp11 and engine_pkcs11 from github as of today, I can not reproduce using PIV card to sign a request.
I can not get gdb to stop in ecdsa_do_sign in ecs_ossl.c to see what is NULL parameter. It is not clear if using the pkcs11_engine to do ECDSA ecdsa_do_sign in ecs_ossl.c should ever be called! In PKCS#11 trace there are no calls to PKCS#11 C_SignInit
OpenSSL could have made changes between 1.0.2a and 1.0.2f that broke the engine.
Could also be LD_LIBRARY_PATH need to be set to pick up correct versions of libs.
Douglas E. Engert DEEngert@gmail.com
Converted to using OpenSSL-1.0.2d, and it still works.
In a script I can do: OPENSC_LIB=/opt/smartcard/lib SPY=1 if [ $SPY -eq 0 ] ; then MODULE=$OPENSC_LIB/opensc-pkcs11.so else MODULE=$OPENSC_LIB/pkcs11-spy.so PKCS11SPY=$OPENSC_LIB/opensc-pkcs11.so export PKCS11SPY PKCS11SPY_OUTPUT=/tmp/pkcs11.spy.log export PKCS11SPY_OUTPUT fi
cat >/tmp/genreq.openssl.input << EOT req $SSLEAY_CONFIG -engine pkcs11 -keyform engine -sha256 -new -key slot1-id$ID -out cards/$1.myreq.$KEYID.pem -text EOT gdb -ex 'set args < /tmp/genreq.openssl.input' openssl
openssl.conf has:
[ openssl_def ] engines = engine_section
[ engine_section ]
pkcs11 = pkcs11_section
[ pkcs11_section ]
engine_id = pkcs11 dynamic_path = /opt/smartcard/lib/engines/libpkcs11.so MODULE_PATH = /opt/smartcard/lib/pkcs11-spy.so init = 0
Its probably something in my build steps, so can you provider yours to make sure I'm not doing something stupid?
This line in the trace looks wrong. [pid 2086] EVP_DigestSignInit(0x7fff82157bd0, 0x7fff82157bc0, 0, 0) = 1
(This looks like only 4 parameters are shown) but the 3rd is the digest and it is NULL. And the routine returned 1. The next traces are showing the errors.
Can you try a digest like -sha256 command line?
Douglas E. Engert DEEngert@gmail.com
ok tried with -sha256 but same result, here is the relevant ltrace:
EVP_MD_CTX_init(0x7ffc607b99f0, 0x70c410, 0x6f9360, 0x7f9bd261a280) = 0 EVP_MD_CTX_init(0x7ffc607b99f0, 0x70c410, 0, 0) = 0 EVP_DigestSignInit(0x7ffc607b99f0, 0x7ffc607b99e0, 0x7f9bd261a280, 0) = 1 sk_num(0, 0, 0x70cfe0, 0) = 0xffffffff X509_sign_ctx(0x70c410, 0x7ffc607b99f0, 0x70cfe0, 0) = 0 EVP_MD_CTX_cleanup(0x7ffc607b99f0, 0xffffffff, 0x7f9bd21db780, 0x70c110) = 1 ERR_print_errors(0x6cd010, 0xffffffff, 0, 0140307231143584:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 140307231143584:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0
https://github.com/nmav https://github.com/dwmw2 should also be looking at your problems because #25 is related and says "Since we use p11-kit-proxy.so by default, and accept PKCS#11 URIs, using engine_pkcs11 is very simple now. No config file is needed, and no special engine configuration.
On 11/6/2015 9:58 PM, Ivan Wallis wrote:
ok tried with -sha256 but same result, here is the relevant ltrace:
EVP_MD_CTX_init(0x7ffc607b99f0, 0x70c410, 0x6f9360, 0x7f9bd261a280) = 0 EVP_MD_CTX_init(0x7ffc607b99f0, 0x70c410, 0, 0) = 0 EVP_DigestSignInit(0x7ffc607b99f0, 0x7ffc607b99e0, 0x7f9bd261a280, 0) = 1
OK, the md parameter in the call above is now not null but that does not show the 5th parameter that would be the pkey, and if the pkey is using the engine.
I don't believe the ECDSA_do_sign should be called which might indicate the engine is not being used at this point.
How do you point at the engine? Do you have sections in the openssl.conf to give the options needed to load libpkcs.so that used to be called engine_pkcs11.so? How do you point libp11 to the pkcs#11 module it should uses?
Note the init = 0 in the [ pkcs11_section ] and the absolute paths.
I am not using the p11-kit-proxy.so in my testing. I don't think you are either. But there could be issues when trying to test with not standard locations for libpkcs11.so, libp11 and opensc and any dynamic loaded libs they may need."
Can you run your test with gdb?
break at EVP_DigestSignInit get a stace trace and look at the parameters, especially the pkey. Then step into called routines looking for ECDSA_do_sign (I don't think it should get there) or any of the use of the engine or p11 routines.
One other thing, the ec_point X starts with 90 We have seen problems converting an ec_point to BIGNUM as the ec_point is unsigned, but BIGNUM are signed. The X has the first bit set. Maybe we still have a problem with the first bit of X (or Y) being set.
sk_num(0, 0, 0x70cfe0, 0) = 0xffffffff X509_sign_ctx(0x70c410, 0x7ffc607b99f0, 0x70cfe0, 0) = 0 EVP_MD_CTX_cleanup(0x7ffc607b99f0, 0xffffffff, 0x7f9bd21db780, 0x70c110) = 1 ERR_print_errors(0x6cd010, 0xffffffff, 0, 0140307231143584:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 140307231143584:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154615186.
Douglas E. Engert DEEngert@gmail.com
Why the -x509 in the command? That says you are starting from a certificate.
openssl req -engine pkcs11 -new -key slot_492971157-label_myecdsa -keyform engine -out req.pem -x509 -subj "/CN=John Smith"
In your trace I see: [pid 2086] EVP_DigestSignInit(0x7fff82157bd0, 0x7fff82157bc0, 0, 0) = 1 [pid 2086] X509_sign_ctx(0xcfd4b0, 0x7fff82157bd0, 0xcfe080, 0) = 0
note return of 0.
[pid 2086] EVP_MD_CTX_cleanup(0x7fff82157bd0, 0xffffffff, 0x7f0ca9b47780, 0xcfd1b0) = 1 [pid 2086] ERR_print_errors(0xcbe010, 0xffffffff, 0, 0139692372833952:error:2A065043:lib
In my trace without the -x509 (but I added -text) I see:
openssl->EVP_DigestSignInit(0x7ffd94722890, 0x7ffd94722880, 0x7f71ea6de280, 0) = 1 openssl->sk_num(0, 0, 0x18e2d00, 0) = 0xffffffff openssl->X509_REQ_sign_ctx(0x18e2a90, 0x7ffd94722890, 0x18e2d00, 0) = 71
Different routine, Returns 71.
openssl->EVP_MD_CTX_cleanup(0x7ffd94722890, 0, 0, 0) = 1 openssl->BIO_ctrl(0x18a7260, 108, 5, 0x7ffd9472317c) = 1
Then prints test of REQ.
openssl->X509_REQ_print_ex(0x18a7260, 0x18e2a90, 0, 0) = 1
Looks like -x509 should have created self signed cert. But can you try without -x509 to see if you can create a signe request?
I was able to create a self signed certificate:
openssl req -config /tmp/genreq.13426.openssl.conf -engine pkcs11 -keyform engine -sha256 -new -key slot_1-id_2 -out /tmp/selfsigned.pem -x509 -text
I use the old -key slot_1-id_2 You are using: -key slot_492971157-label_myecdsa
I don't see any prompt for a PIN to use the signing key. Is that not in your dump?
I was using this that does show a call to CLogin: ltrace -o /tmp/ltrace.log -l "libp11.so" -l "libpkcs11.so_" -l "libcrypto.so*" -l "opensc-pkcs11.so" openssl < /tmp/genreq.openssl.input.test
libpkcs11.so->PKCS11_login(0x2503488, 0, 0x2507b10, 0) = 0 libpkcs11.so->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0fa8, 0x7fff66ce0f88, 0x7fff66ce0fa8) = 0 libpkcs11.so->PKCS11_get_private_key(0x2508fe0, 0x7fff66ce1071, 0x2508b60, 1 <unfinished ...> libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e70, 0x7fff66ce0e68, 0x7fff66ce0e70) = 0 libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e50, 0x7fff66ce0e48, 0x7fff66ce0e50) = 0 <... PKCS11_get_private_key resumed> ) = 0x2503a20 <... ENGINE_load_private_key resumed> ) = 0x2503a20
without -x509 still getting the same error:
X509V3_set_ctx(0x7ffec7aa3aa0, 0, 0, 0x2033310) = 1 X509V3_set_nconf(0x7ffec7aa3aa0, 0x2010680, 0, 0x2033310) = 0x7f0d0e3d4e00 EVP_MD_CTX_init(0x7ffec7aa3850, 0x2033310, 0x202dc40, 0x7f0d0e3c7260) = 0 EVP_MD_CTX_init(0x7ffec7aa3850, 0x2033310, 0x202dc40, 0) = 0 EVP_DigestSignInit(0x7ffec7aa3850, 0x7ffec7aa3848, 0x7f0d0e3c7260, 0) = 1 sk_num(0, 7, 0x20334e0, 0) = 0xffffffff X509_REQ_sign_ctx(0x2033310, 0x7ffec7aa3850, 0x20334e0, 0) = 0 EVP_MD_CTX_cleanup(0x7ffec7aa3850, 0x7f0d0dd81b60, 0x202d0f0, 0) = 1 ERR_print_errors(0x1ff6010, 0x7f0d0dd81b60, 0x202d0f0, 0139694054954648:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139694054954648:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0 ERR_print_errors(0x1ff6010, 1, 8, 473) = 0
Also I am using an nCipher HSM with module protected keys so no login to the token is needed.
openssl config:
[openssl_def] engines = engine_section
[engine_section] pkcs11 = pkcs11_section
[pkcs11_section] engine_id = pkcs11 dynamic_path = /usr/local/lib/engines/libpkcs11.so MODULE_PATH = /opt/nfast/toolkits/pkcs11/libcknfast.so
I tried with RSA keys via the pkcs11 engine and everything works fine.
On Sun, Nov 8, 2015 at 4:12 PM, Doug Engert notifications@github.com wrote:
I was able to create a self signed certificate:
openssl req -config /tmp/genreq.13426.openssl.conf -engine pkcs11 -keyform engine -sha256 -new -key slot_1-id_2 -out /tmp/selfsigned.pem -x509 -text
I use the old -key slot_1-id_2 You are using: -key slot_492971157-label_myecdsa
I don't see any prompt for a PIN to use the signing key. Is that not in your dump?
I was using this that does show a call to CLogin: ltrace -o /tmp/ltrace.log -l "libp11.so" -l "libpkcs11.so_" -l "libcrypto.so*" -l "opensc-pkcs11.so" openssl < /tmp/genreq.openssl.input.test
libpkcs11.so->PKCS11_login(0x2503488, 0, 0x2507b10, 0) = 0 libpkcs11.so->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0fa8, 0x7fff66ce0f88, 0x7fff66ce0fa8) = 0 libpkcs11.so->PKCS11_get_private_key(0x2508fe0, 0x7fff66ce1071, 0x2508b60, 1 libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e70, 0x7fff66ce0e68, 0x7fff66ce0e70) = 0 libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e50, 0x7fff66ce0e48, 0x7fff66ce0e50) = 0 <... PKCS11_get_private_key resumed> ) = 0x2503a20 <... ENGINE_load_private_key resumed> ) = 0x2503a20
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154888969.
First try to see if there is a library mismatch problem
Run the ldd command on each of the modules involved looking to make sure it is using the versions of the engine, libp11 and openssl you are using:
Assuming you built in /usr/local cd /usr/local ldd bin/openssl ldd lib/engines/libpkcs11.so ldd lib/libp11.so ldd lib/pkcs11-spy.so ldd /opt/nfast/toolkits/pkcs11/libcknfast.so
try adding the location of the OpenSSL-1.0.2d libs export LD_LIBRARY_PATH=/usr/local/lib (assuming that is where the openssl libs are.)
Then try adding to openssl.conf try adding: INIT = 0 as the last line.
If that does not work, Lets get SPY working. Change: MODULE_PATH = /opt/nfast/toolkits/pkcs11/libcknfast.so to MODULE_PATH = /usr/local/lib/pkcs11-spy.so (or where ever the OpenSC spy is)
And then before running openssl set these:
export PKCS11SPY=/opt/nfast/toolkits/pkcs11/libcknfast.so export PKCS11SPY_OUTPUT=/tmp/pkcs11.spy.log
When you create a EC key on the HSM, does it also create a public key object?
I would like to see what OpenSC's view of what it thinks is on the device: Can you try running pkcs11-tool --module=/opt/nfast/toolkits/pkcs11/libcknfast.so -O
On 11/8/2015 7:11 PM, Ivan Wallis wrote:
without -x509 still getting the same error:
X509V3_set_ctx(0x7ffec7aa3aa0, 0, 0, 0x2033310) = 1 X509V3_set_nconf(0x7ffec7aa3aa0, 0x2010680, 0, 0x2033310) = 0x7f0d0e3d4e00 EVP_MD_CTX_init(0x7ffec7aa3850, 0x2033310, 0x202dc40, 0x7f0d0e3c7260) = 0 EVP_MD_CTX_init(0x7ffec7aa3850, 0x2033310, 0x202dc40, 0) = 0 EVP_DigestSignInit(0x7ffec7aa3850, 0x7ffec7aa3848, 0x7f0d0e3c7260, 0) = 1 sk_num(0, 7, 0x20334e0, 0) = 0xffffffff X509_REQ_sign_ctx(0x2033310, 0x7ffec7aa3850, 0x20334e0, 0) = 0 EVP_MD_CTX_cleanup(0x7ffec7aa3850, 0x7f0d0dd81b60, 0x202d0f0, 0) = 1 ERR_print_errors(0x1ff6010, 0x7f0d0dd81b60, 0x202d0f0, 0139694054954648:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139694054954648:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0 ERR_print_errors(0x1ff6010, 1, 8, 473) = 0
Also I am using an nCipher HSM with module protected keys so no login to the token is needed.
openssl config:
[openssl_def] engines = engine_section
[engine_section] pkcs11 = pkcs11_section
[pkcs11_section] engine_id = pkcs11 dynamic_path = /usr/local/lib/engines/libpkcs11.so MODULE_PATH = /opt/nfast/toolkits/pkcs11/libcknfast.so
I tried with RSA keys via the pkcs11 engine and everything works fine.
On Sun, Nov 8, 2015 at 4:12 PM, Doug Engert notifications@github.com wrote:
I was able to create a self signed certificate:
openssl req -config /tmp/genreq.13426.openssl.conf -engine pkcs11 -keyform engine -sha256 -new -key slot_1-id_2 -out /tmp/selfsigned.pem -x509 -text
I use the old -key slot_1-id_2 You are using: -key slot_492971157-label_myecdsa
I don't see any prompt for a PIN to use the signing key. Is that not in your dump?
I was using this that does show a call to CLogin: ltrace -o /tmp/ltrace.log -l "libp11.so" -l "libpkcs11.so_" -l "libcrypto.so*" -l "opensc-pkcs11.so" openssl < /tmp/genreq.openssl.input.test
libpkcs11.so->PKCS11_login(0x2503488, 0, 0x2507b10, 0) = 0 libpkcs11.so->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0fa8, 0x7fff66ce0f88, 0x7fff66ce0fa8) = 0 libpkcs11.so->PKCS11_get_private_key(0x2508fe0, 0x7fff66ce1071, 0x2508b60, 1 libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e70, 0x7fff66ce0e68, 0x7fff66ce0e70) = 0 libp11.so.2->PKCS11_enumerate_keys(0x2503860, 0x7fff66ce0e50, 0x7fff66ce0e48, 0x7fff66ce0e50) = 0 <... PKCS11_get_private_key resumed> ) = 0x2503a20 <... ENGINE_load_private_key resumed> ) = 0x2503a20
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154888969.
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154895530.
Douglas E. Engert DEEngert@gmail.com
[root@ecdsa engine_pkcs11-master]# ldd /usr/local/lib/engines/libpkcs11.so linux-vdso.so.1 (0x00007ffc19fce000) libp11.so.2 => /usr/local/lib/libp11.so.2 (0x00007f9d4b1af000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f9d4af63000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f9d4ad5f000) libc.so.6 => /lib64/libc.so.6 (0x00007f9d4a99e000) libfreebl3.so => /lib64/libfreebl3.so (0x00007f9d4a720000) /lib64/ld-linux-x86-64.so.2 (0x00005636beb50000) [root@ecdsa engine_pkcs11-master]# cd /opt/openssl-1.0.2d/lib [root@ecdsa lib]# ls engines libcrypto.a libcrypto.so libcrypto.so.1.0.0 libssl.a libssl.so libssl.so.1.0.0 pkgconfig [root@ecdsa lib]# ldd /usr/local/lib/libp11.so linux-vdso.so.1 (0x00007ffcc47cc000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fa0e43ec000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fa0e41e7000) libc.so.6 => /lib64/libc.so.6 (0x00007fa0e3e26000) libfreebl3.so => /lib64/libfreebl3.so (0x00007fa0e3ba9000) /lib64/ld-linux-x86-64.so.2 (0x00005595b0d8b000) [root@ecdsa lib]# ldd /opt/nfast/toolkits/pkcs11/libcknfast.so linux-vdso.so.1 (0x00007ffc681f4000) libc.so.6 => /lib64/libc.so.6 (0x00007f97dfa9e000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f97df880000) librt.so.1 => /lib64/librt.so.1 (0x00007f97df678000) libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f97df45f000) /lib64/ld-linux-x86-64.so.2 (0x0000555c2b24b000) [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/bin/openssl linux-vdso.so.1 (0x00007fffda3bb000) libssl.so.1.0.0 => /opt/openssl-1.0.2d/lib/libssl.so.1.0.0 (0x00007fb9cc763000) libcrypto.so.1.0.0 => /opt/openssl-1.0.2d/lib/libcrypto.so.1.0.0 (0x00007fb9cc310000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fb9cc0f7000) libc.so.6 => /lib64/libc.so.6 (0x00007fb9cbd36000) /lib64/ld-linux-x86-64.so.2 (0x0000562cdb9bc000) [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so libcrypto.so libcrypto.so.1.0.0 [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so libcrypto.so libcrypto.so.1.0.0 [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so linux-vdso.so.1 (0x00007ffed4bd3000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fa376ff9000) libc.so.6 => /lib64/libc.so.6 (0x00007fa376c37000) /lib64/ld-linux-x86-64.so.2 (0x0000564b565cf000) [root@ecdsa lib]#
i'll send the rest later
[root@ecdsa lib]# pkcs11-tool --module=/opt/nfast/toolkits/pkcs11/libcknfast.so -O Using slot 0 with a present token (0x1d622495) Private Key Object; RSA label: ivanrsa ID: 0816afba9c63d057eacd3a82c301613538154671 Usage: decrypt, sign, unwrap warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12)
Public Key Object; RSA 1024 bits label: ivanrsa ID: 0816afba9c63d057eacd3a82c301613538154671 Usage: encrypt, verify, wrap Private Key Object; EC label: ivanecdsa Usage: sign warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12)
Public Key Object; EC EC_POINT 256 bits EC_POINT: 04410486159c8bc0792c66382d51f222064fc7037eaec2986e65bebb10e3470523c77d1d6ef7683dcf3da72e2d63e6259768a7b5c10d835a4c75e1c3933243bc58b966 EC_PARAMS: 06082a8648ce3d030107 label: ivanecdsa Usage: verify
*** OpenSC PKCS#11 spy ***** Loaded: "/opt/nfast/toolkits/pkcs11/libcknfast.so"
0: C_GetFunctionList 2015-11-08 20:18:21.999 Returned: 0 CKR_OK
1: C_Initialize 2015-11-08 20:18:21.999 [in] pInitArgs = (nil) Returned: 0 CKR_OK
2: C_GetInfo 2015-11-08 20:18:22.087 [out] pInfo: cryptokiVersion: 2.1 manufacturerID: 'nCipher Corp. Ltd ' flags: 0 libraryDescription: 'nCipher PKCS#11 2.2.1 ' libraryVersion: 2.2 Returned: 0 CKR_OK
3: C_GetSlotList 2015-11-08 20:18:22.087 [in] tokenPresent = 0x0 [out] pSlotList: Count is 2 [out] *pulCount = 0x2 Returned: 0 CKR_OK
4: C_GetSlotList 2015-11-08 20:18:22.087 [in] tokenPresent = 0x0 [out] pSlotList: Slot 492971157 Slot 492971158 [out] *pulCount = 0x2 Returned: 0 CKR_OK
5: C_GetSlotInfo
2015-11-08 20:18:22.087
[in] slotID = 0x1d622495
[out] pInfo:
slotDescription: 'B2B8-5C8F-1924 Rt2 '
' '
manufacturerID: 'nCipher Corp. Ltd '
hardwareVersion: 0.7
firmwareVersion: 2.51
flags: 5
CKF_TOKEN_PRESENT
CKF_HW_SLOT
Returned: 0 CKR_OK
6: C_GetTokenInfo
2015-11-08 20:18:22.087
[in] slotID = 0x1d622495
[out] pInfo:
label: 'accelerator '
manufacturerID: 'nCipher Corp. Ltd '
model: ' '
serialNumber: 'B2B8-5C8F-1924 '
ulMaxSessionCount: 0
ulSessionCount: 0
ulMaxRwSessionCount: 0
ulRwSessionCount: 0
ulMaxPinLen: 256
ulMinPinLen: 0
ulTotalPublicMemory: -1
ulFreePublicMemory: -1
ulTotalPrivateMemory: -1
ulFreePrivateMemory: -1
hardwareVersion: 0.7
firmwareVersion: 2.51
time: ' '
flags: 209
CKF_RNG
CKF_USER_PIN_INITIALIZED
CKF_DUAL_CRYPTO_OPERATIONS
Returned: 0 CKR_OK
7: C_GetSlotInfo
2015-11-08 20:18:22.087
[in] slotID = 0x1d622496
[out] pInfo:
slotDescription: 'B2B8-5C8F-1924 Rt2 slot 0 '
' '
manufacturerID: 'nCipher Corp. Ltd '
hardwareVersion: 0.7
firmwareVersion: 2.51
flags: 6
CKF_REMOVABLE_DEVICE
CKF_HW_SLOT
Returned: 0 CKR_OK
8: C_OpenSession 2015-11-08 20:18:22.087 [in] slotID = 0x1d622495 [in] flags = 0x4 pApplication=(nil) Notify=(nil) [out] *phSession = 0x8cb Returned: 0 CKR_OK
9: C_FindObjectsInit
2015-11-08 20:18:22.087
[in] hSession = 0x8cb
[in] pTemplate[1]:
CKA_CLASS CKO_CERTIFICATE
Returned: 0 CKR_OK
10: C_FindObjects 2015-11-08 20:18:22.087 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
11: C_FindObjectsFinal 2015-11-08 20:18:22.087 [in] hSession = 0x8cb Returned: 0 CKR_OK
12: C_FindObjectsInit
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] pTemplate[1]:
CKA_CLASS CKO_PRIVATE_KEY
Returned: 0 CKR_OK
13: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x45e matches Returned: 0 CKR_OK
14: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45e
[in] pTemplate[1]:
CKA_KEY_TYPE 00007ffdec83a990 / 8
[out] pTemplate[1]:
CKA_KEY_TYPE CKK_RSA
Returned: 0 CKR_OK
15: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45e [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 7 6976616E 727361 i v a n r s a Returned: 0 CKR_OK
16: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45e
[in] pTemplate[1]:
CKA_ID 00007ffdec83aaa0 / 256
[out] pTemplate[1]:
CKA_ID 00007ffdec83aaa0 / 20
00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5
00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
17: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45e
[in] pTemplate[1]:
CKA_ID 00000000019754d0 / 255
[out] pTemplate[1]:
CKA_ID 00000000019754d0 / 20
00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5
00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
18: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x460 matches Returned: 0 CKR_OK
19: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x460
[in] pTemplate[1]:
CKA_KEY_TYPE 00007ffdec83a990 / 8
[out] pTemplate[1]:
CKA_KEY_TYPE CKK_EC
Returned: 0 CKR_OK
20: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 9 6976616E 65636473 61 i v a n e c d s a Returned: 0 CKR_OK
21: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 0 Returned: 0 CKR_OK
22: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ID 0000000001975600 / 255 [out] pTemplate[1]: CKA_ID 0000000001975600 / 0 Returned: 0 CKR_OK
23: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
24: C_FindObjectsFinal 2015-11-08 20:18:22.088 [in] hSession = 0x8cb Returned: 0 CKR_OK
25: C_FindObjectsInit
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] pTemplate[1]:
CKA_CLASS CKO_PUBLIC_KEY
Returned: 0 CKR_OK
26: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x45f matches Returned: 0 CKR_OK
27: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45f
[in] pTemplate[1]:
CKA_KEY_TYPE 00007ffdec83a990 / 8
[out] pTemplate[1]:
CKA_KEY_TYPE CKK_RSA
Returned: 0 CKR_OK
28: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45f [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 7 6976616E 727361 i v a n r s a Returned: 0 CKR_OK
29: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45f
[in] pTemplate[1]:
CKA_ID 00007ffdec83aaa0 / 256
[out] pTemplate[1]:
CKA_ID 00007ffdec83aaa0 / 20
00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5
00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
30: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x45f
[in] pTemplate[1]:
CKA_ID 00000000019757d0 / 255
[out] pTemplate[1]:
CKA_ID 00000000019757d0 / 20
00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5
00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
31: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x461 matches Returned: 0 CKR_OK
32: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x461
[in] pTemplate[1]:
CKA_KEY_TYPE 00007ffdec83a990 / 8
[out] pTemplate[1]:
CKA_KEY_TYPE CKK_EC
Returned: 0 CKR_OK
33: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 9 6976616E 65636473 61 i v a n e c d s a Returned: 0 CKR_OK
34: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 0 Returned: 0 CKR_OK
35: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_ID 00000000019759d0 / 255 [out] pTemplate[1]: CKA_ID 00000000019759d0 / 0 Returned: 0 CKR_OK
36: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
37: C_FindObjectsFinal 2015-11-08 20:18:22.088 [in] hSession = 0x8cb Returned: 0 CKR_OK
38: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_SENSITIVE 00007ffdec83abde / 1 [out] pTemplate[1]: CKA_SENSITIVE True Returned: 0 CKR_OK
39: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_EXTRACTABLE 00007ffdec83abdf / 1 [out] pTemplate[1]: CKA_EXTRACTABLE False Returned: 0 CKR_OK
40: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 0 [out] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 10 Returned: 0 CKR_OK
41: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x460
[in] pTemplate[1]:
CKA_ECDSA_PARAMS 000000000196e530 / 10
[out] pTemplate[1]:
CKA_ECDSA_PARAMS 000000000196e530 / 10
00000000 06 08 2A 86 48 CE 3D 03 01 07 ..*.H.=...
Returned: 0 CKR_OK
42: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 0 [out] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 67 Returned: 0 CKR_OK
43: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x461
[in] pTemplate[1]:
CKA_EC_POINT 0000000001962db0 / 67
[out] pTemplate[1]:
CKA_EC_POINT 0000000001962db0 / 67
00000000 04 41 04 86 15 9C 8B C0 79 2C 66 38 2D 51 F2 22 .A......y,f8-Q."
00000010 06 4F C7 03 7E AE C2 98 6E 65 BE BB 10 E3 47 05 .O..~...ne....G.
00000020 23 C7 7D 1D 6E F7 68 3D CF 3D A7 2E 2D 63 E6 25 #.}.n.h=.=..-c.%
00000030 97 68 A7 B5 C1 0D 83 5A 4C 75 E1 C3 93 32 43 BC .h.....ZLu...2C.
00000040 58 B9 66 X.f
Returned: 0 CKR_OK
44: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_SENSITIVE 00007ffdec83abde / 1 [out] pTemplate[1]: CKA_SENSITIVE True Returned: 0 CKR_OK
45: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_EXTRACTABLE 00007ffdec83abdf / 1 [out] pTemplate[1]: CKA_EXTRACTABLE False Returned: 0 CKR_OK
46: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 0 [out] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 10 Returned: 0 CKR_OK
47: C_GetAttributeValue
2015-11-08 20:18:22.088
[in] hSession = 0x8cb
[in] hObject = 0x460
[in] pTemplate[1]:
CKA_ECDSA_PARAMS 0000000001975f40 / 10
[out] pTemplate[1]:
CKA_ECDSA_PARAMS 0000000001975f40 / 10
00000000 06 08 2A 86 48 CE 3D 03 01 07 ..*.H.=...
Returned: 0 CKR_OK
48: C_GetAttributeValue 2015-11-08 20:18:22.089 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 0 [out] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 67 Returned: 0 CKR_OK
49: C_GetAttributeValue
2015-11-08 20:18:22.089
[in] hSession = 0x8cb
[in] hObject = 0x461
[in] pTemplate[1]:
CKA_EC_POINT 0000000001976a80 / 67
[out] pTemplate[1]:
CKA_EC_POINT 0000000001976a80 / 67
00000000 04 41 04 86 15 9C 8B C0 79 2C 66 38 2D 51 F2 22 .A......y,f8-Q."
00000010 06 4F C7 03 7E AE C2 98 6E 65 BE BB 10 E3 47 05 .O..~...ne....G.
00000020 23 C7 7D 1D 6E F7 68 3D CF 3D A7 2E 2D 63 E6 25 #.}.n.h=.=..-c.%
00000030 97 68 A7 B5 C1 0D 83 5A 4C 75 E1 C3 93 32 43 BC .h.....ZLu...2C.
00000040 58 B9 66 X.f
Returned: 0 CKR_OK
50: C_Finalize 2015-11-08 20:18:22.090 Returned: 0 CKR_OK
Another debug option, is to add in the openssl.conf after the MODULE = and init = 0 add VERBOSE = EMPTY
This sets the verbose=1 in libp11, and can be used to get extra messages to stderr.
On 11/8/2015 10:23 PM, Ivan Wallis wrote:
[root@ecdsa lib]# pkcs11-tool --module=/opt/nfast/toolkits/pkcs11/libcknfast.so -O Using slot 0 with a present token (0x1d622495) Private Key Object; RSA label: ivanrsa ID: 0816afba9c63d057eacd3a82c301613538154671 Usage: decrypt, sign, unwrap warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12)
Disregard, this is the user_consent CKA_ALWAYS_AUTHENTICATE attribute libcknfast.so does not understand it, so assumption is attribute is false. (Later on the lib says it is PKCS#11 version 2.1. I believe this was introduced in v2.20)
Public Key Object; RSA 1024 bits label: ivanrsa ID: 0816afba9c63d057eacd3a82c301613538154671 Usage: encrypt, verify, wrap
Private Key Object; EC label: ivanecdsa Usage: sign warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12)
Disregard, this is the user_consent CKA_ALWAYS_AUTHENTICATE attribute libcknfast.so does not understand it, so assumption is attribute is false.
Public Key Object; EC EC_POINT 256 bits EC_POINT: 04410486159c8bc0792c66382d51f222064fc7037eaec2986e65bebb10e3470523c77d1d6ef7683dcf3da72e2d63e6259768a7b5c10d835a4c75e1c3933243bc58b966 EC_PARAMS: 06082a8648ce3d030107 label: ivanecdsa Usage: verify
Note the RSA key has an CKA_ID, but the EC key does not. This could be the problem.
When you created the key, was there an option to add the ID?
Why does the libcknfast.so show a CKA_ID for RSA keys but not EC keys? Any way to fill a bug with them on this?
http://sourceforge.net/p/ejbca/discussion/123123/thread/6818d462/
PKCS#11 3.30 says: "The CKA_LABEL attribute is intended to assist users in browsing."
10.7.2 Overview "The CKA_ID field is intended to distinguish among multiple keys. In the case of public and private keys, this field assists in handling multiple keys held by the same subject; the key identifier for a public key and its corresponding private key should be the same. The key identifier should also be the same as for the corresponding certificate, if one exists. Cryptoki does not enforce these associations, however. (See Section 10.6 for further commentary.)"
12.3.4 Elliptic curve private key objects "Note that when generating an EC private key, the EC domain parameters are not specified in the key’s template."
Since when EC keys are created in pairs when done be PKCS#11, the CKA_EC_POINT and CKA_EC_PARAMS are the public key. (The CKA_EC_PARAMS may be read from the private key, but that is optional.)
OpenSC libp11 uses the CKA_ID to associate the public key and private key.
Try the VERBOSE = EMPTY with the sign test for now t see what might be going on.
*** OpenSC PKCS#11 spy ***** Loaded: "/opt/nfast/toolkits/pkcs11/libcknfast.so"
0: C_GetFunctionList 2015-11-08 20:18:21.999 Returned: 0 CKR_OK
1: C_Initialize 2015-11-08 20:18:21.999 [in] pInitArgs = (nil) Returned: 0 CKR_OK
2: C_GetInfo 2015-11-08 20:18:22.087 [out] pInfo: cryptokiVersion: 2.1 manufacturerID: 'nCipher Corp. Ltd ' flags: 0 libraryDescription: 'nCipher PKCS#11 2.2.1 ' libraryVersion: 2.2 Returned: 0 CKR_OK
3: C_GetSlotList 2015-11-08 20:18:22.087 [in] tokenPresent = 0x0 [out] pSlotList: Count is 2 [out] *pulCount = 0x2 Returned: 0 CKR_OK
4: C_GetSlotList 2015-11-08 20:18:22.087 [in] tokenPresent = 0x0 [out] pSlotList: Slot 492971157 Slot 492971158 [out] *pulCount = 0x2 Returned: 0 CKR_OK
5: C_GetSlotInfo 2015-11-08 20:18:22.087 [in] slotID = 0x1d622495 [out] pInfo: slotDescription: 'B2B8-5C8F-1924 Rt2 ' ' ' manufacturerID: 'nCipher Corp. Ltd ' hardwareVersion: 0.7 firmwareVersion: 2.51 flags: 5 CKF_TOKEN_PRESENT
CKF_HW_SLOT
Returned: 0 CKR_OK
6: C_GetTokenInfo 2015-11-08 20:18:22.087 [in] slotID = 0x1d622495 [out] pInfo: label: 'accelerator ' manufacturerID: 'nCipher Corp. Ltd ' model: ' ' serialNumber: 'B2B8-5C8F-1924 ' ulMaxSessionCount: 0 ulSessionCount: 0 ulMaxRwSessionCount: 0 ulRwSessionCount: 0 ulMaxPinLen: 256 ulMinPinLen: 0 ulTotalPublicMemory: -1 ulFreePublicMemory: -1 ulTotalPrivateMemory: -1 ulFreePrivateMemory: -1 hardwareVersion: 0.7 firmwareVersion: 2.51 time: ' ' flags: 209 CKF_RNG
CKF_USER_PIN_INITIALIZED
CKF_DUAL_CRYPTO_OPERATIONS
Returned: 0 CKR_OK
7: C_GetSlotInfo 2015-11-08 20:18:22.087 [in] slotID = 0x1d622496 [out] pInfo: slotDescription: 'B2B8-5C8F-1924 Rt2 slot 0 ' ' ' manufacturerID: 'nCipher Corp. Ltd ' hardwareVersion: 0.7 firmwareVersion: 2.51 flags: 6 CKF_REMOVABLE_DEVICE
CKF_HW_SLOT
Returned: 0 CKR_OK
8: C_OpenSession 2015-11-08 20:18:22.087 [in] slotID = 0x1d622495 [in] flags = 0x4 pApplication=(nil) Notify=(nil) [out] *phSession = 0x8cb Returned: 0 CKR_OK
9: C_FindObjectsInit 2015-11-08 20:18:22.087 [in] hSession = 0x8cb [in] pTemplate[1]: CKA_CLASS CKO_CERTIFICATE
Returned: 0 CKR_OK
10: C_FindObjects 2015-11-08 20:18:22.087 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
11: C_FindObjectsFinal 2015-11-08 20:18:22.087 [in] hSession = 0x8cb Returned: 0 CKR_OK
12: C_FindObjectsInit 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] pTemplate[1]: CKA_CLASS CKO_PRIVATE_KEY
Returned: 0 CKR_OK
13: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x45e matches Returned: 0 CKR_OK
14: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45e [in] pTemplate[1]: CKA_KEY_TYPE 00007ffdec83a990 / 8 [out] pTemplate[1]: CKA_KEY_TYPE CKK_RSA
Returned: 0 CKR_OK
15: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45e [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 7 6976616E 727361 i v a n r s a Returned: 0 CKR_OK
16: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45e [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 20 00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5 00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
17: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45e [in] pTemplate[1]: CKA_ID 00000000019754d0 / 255 [out] pTemplate[1]: CKA_ID 00000000019754d0 / 20 00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5 00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
18: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x460 matches Returned: 0 CKR_OK
19: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_KEY_TYPE 00007ffdec83a990 / 8 [out] pTemplate[1]: CKA_KEY_TYPE CKK_EC
Returned: 0 CKR_OK
20: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 9 6976616E 65636473 61 i v a n e c d s a Returned: 0 CKR_OK
21: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 0 Returned: 0 CKR_OK
22: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ID 0000000001975600 / 255 [out] pTemplate[1]: CKA_ID 0000000001975600 / 0 Returned: 0 CKR_OK
23: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
24: C_FindObjectsFinal 2015-11-08 20:18:22.088 [in] hSession = 0x8cb Returned: 0 CKR_OK
25: C_FindObjectsInit 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] pTemplate[1]: CKA_CLASS CKO_PUBLIC_KEY
Returned: 0 CKR_OK
26: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x45f matches Returned: 0 CKR_OK
27: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45f [in] pTemplate[1]: CKA_KEY_TYPE 00007ffdec83a990 / 8 [out] pTemplate[1]: CKA_KEY_TYPE CKK_RSA
Returned: 0 CKR_OK
28: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45f [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 7 6976616E 727361 i v a n r s a Returned: 0 CKR_OK
29: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45f [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 20 00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5 00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
30: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x45f [in] pTemplate[1]: CKA_ID 00000000019757d0 / 255 [out] pTemplate[1]: CKA_ID 00000000019757d0 / 20 00000000 08 16 AF BA 9C 63 D0 57 EA CD 3A 82 C3 01 61 35 .....c.W..:...a5 00000010 38 15 46 71 8.Fq
Returned: 0 CKR_OK
31: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 0x461 matches Returned: 0 CKR_OK
32: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_KEY_TYPE 00007ffdec83a990 / 8 [out] pTemplate[1]: CKA_KEY_TYPE CKK_EC
Returned: 0 CKR_OK
33: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 256 [out] pTemplate[1]: CKA_LABEL 00007ffdec83a9a0 / 9 6976616E 65636473 61 i v a n e c d s a Returned: 0 CKR_OK
34: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 256 [out] pTemplate[1]: CKA_ID 00007ffdec83aaa0 / 0 Returned: 0 CKR_OK
35: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_ID 00000000019759d0 / 255 [out] pTemplate[1]: CKA_ID 00000000019759d0 / 0 Returned: 0 CKR_OK
36: C_FindObjects 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x0 Returned: 0 CKR_OK
37: C_FindObjectsFinal 2015-11-08 20:18:22.088 [in] hSession = 0x8cb Returned: 0 CKR_OK
38: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_SENSITIVE 00007ffdec83abde / 1 [out] pTemplate[1]: CKA_SENSITIVE True Returned: 0 CKR_OK
39: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_EXTRACTABLE 00007ffdec83abdf / 1 [out] pTemplate[1]: CKA_EXTRACTABLE False Returned: 0 CKR_OK
40: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 0 [out] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 10 Returned: 0 CKR_OK
41: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 000000000196e530 / 10 [out] pTemplate[1]: CKA_ECDSA_PARAMS 000000000196e530 / 10 00000000 06 08 2A 86 48 CE 3D 03 01 07 ..*.H.=...
Returned: 0 CKR_OK
42: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 0 [out] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 67 Returned: 0 CKR_OK
43: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000001962db0 / 67 [out] pTemplate[1]: CKA_EC_POINT 0000000001962db0 / 67 00000000 04 41 04 86 15 9C 8B C0 79 2C 66 38 2D 51 F2 22 .A......y,f8-Q." 00000010 06 4F C7 03 7E AE C2 98 6E 65 BE BB 10 E3 47 05 .O..~...ne....G. 00000020 23 C7 7D 1D 6E F7 68 3D CF 3D A7 2E 2D 63 E6 25 #.}.n.h=.=..-c.% 00000030 97 68 A7 B5 C1 0D 83 5A 4C 75 E1 C3 93 32 43 BC .h.....ZLu...2C. 00000040 58 B9 66 X.f
Returned: 0 CKR_OK
44: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_SENSITIVE 00007ffdec83abde / 1 [out] pTemplate[1]: CKA_SENSITIVE True Returned: 0 CKR_OK
45: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_EXTRACTABLE 00007ffdec83abdf / 1 [out] pTemplate[1]: CKA_EXTRACTABLE False Returned: 0 CKR_OK
46: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 0 [out] pTemplate[1]: CKA_ECDSA_PARAMS 0000000000000000 / 10 Returned: 0 CKR_OK
47: C_GetAttributeValue 2015-11-08 20:18:22.088 [in] hSession = 0x8cb [in] hObject = 0x460 [in] pTemplate[1]: CKA_ECDSA_PARAMS 0000000001975f40 / 10 [out] pTemplate[1]: CKA_ECDSA_PARAMS 0000000001975f40 / 10 00000000 06 08 2A 86 48 CE 3D 03 01 07 ..*.H.=...
Returned: 0 CKR_OK
48: C_GetAttributeValue 2015-11-08 20:18:22.089 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 0 [out] pTemplate[1]: CKA_EC_POINT 0000000000000000 / 67 Returned: 0 CKR_OK
49: C_GetAttributeValue 2015-11-08 20:18:22.089 [in] hSession = 0x8cb [in] hObject = 0x461 [in] pTemplate[1]: CKA_EC_POINT 0000000001976a80 / 67 [out] pTemplate[1]: CKA_EC_POINT 0000000001976a80 / 67 00000000 04 41 04 86 15 9C 8B C0 79 2C 66 38 2D 51 F2 22 .A......y,f8-Q." 00000010 06 4F C7 03 7E AE C2 98 6E 65 BE BB 10 E3 47 05 .O..~...ne....G. 00000020 23 C7 7D 1D 6E F7 68 3D CF 3D A7 2E 2D 63 E6 25 #.}.n.h=.=..-c.% 00000030 97 68 A7 B5 C1 0D 83 5A 4C 75 E1 C3 93 32 43 BC .h.....ZLu...2C. 00000040 58 B9 66 X.f
Returned: 0 CKR_OK
50: C_Finalize 2015-11-08 20:18:22.090 Returned: 0 CKR_OK
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154916847.
Douglas E. Engert DEEngert@gmail.com
It would be wise to run all your tests with: export LD_LIBRARY_PATH=/usr/local/lib
This will make sure all the modules that may need other libraries get the one you have compiled in /usr/local/lib.
On 11/8/2015 9:44 PM, Ivan Wallis wrote:
[root@ecdsa engine_pkcs11-master]# ldd /usr/local/lib/engines/libpkcs11.so linux-vdso.so.1 (0x00007ffc19fce000) libp11.so.2 => /usr/local/lib/libp11.so.2 (0x00007f9d4b1af000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f9d4af63000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f9d4ad5f000) libc.so.6 => /lib64/libc.so.6 (0x00007f9d4a99e000) libfreebl3.so => /lib64/libfreebl3.so (0x00007f9d4a720000) /lib64/ld-linux-x86-64.so.2 (0x00005636beb50000) [root@ecdsa engine_pkcs11-master]# cd /opt/openssl-1.0.2d/lib [root@ecdsa lib]# ls engines libcrypto.a libcrypto.so libcrypto.so.1.0.0 libssl.a libssl.so libssl.so.1.0.0 pkgconfig [root@ecdsa lib]# ldd /usr/local/lib/libp11.so linux-vdso.so.1 (0x00007ffcc47cc000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fa0e43ec000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fa0e41e7000) libc.so.6 => /lib64/libc.so.6 (0x00007fa0e3e26000) libfreebl3.so => /lib64/libfreebl3.so (0x00007fa0e3ba9000) /lib64/ld-linux-x86-64.so.2 (0x00005595b0d8b000) [root@ecdsa lib]# ldd /opt/nfast/toolkits/pkcs11/libcknfast.so linux-vdso.so.1 (0x00007ffc681f4000) libc.so.6 => /lib64/libc.so.6 (0x00007f97dfa9e000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f97df880000) librt.so.1 => /lib64/librt.so.1 (0x00007f97df678000) libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f97df45f000) /lib64/ld-linux-x86-64.so.2 (0x0000555c2b24b000) [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/bin/openssl linux-vdso.so.1 (0x00007fffda3bb000) libssl.so.1.0.0 => /opt/openssl-1.0.2d/lib/libssl.so.1.0.0 (0x00007fb9cc763000) libcrypto.so.1.0.0 => /opt/openssl-1.0.2d/lib/libcrypto.so.1.0.0 (0x00007fb9cc310000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fb9cc0f7000) libc.so.6 => /lib64/libc.so.6 (0x00007fb9cbd36000) /lib64/ld-linux-x86-64.so.2 (0x0000562cdb9bc000) [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so libcrypto.so libcrypto.so.1.0.0 [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so libcrypto.so libcrypto.so.1.0.0 [root@ecdsa lib]# ldd /opt/openssl-1.0.2d/lib/libcrypto.so linux-vdso.so.1 (0x00007ffed4bd3000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fa376ff9000) libc.so.6 => /lib64/libc.so.6 (0x00007fa376c37000) /lib64/ld-linux-x86-64.so.2 (0x0000564b565cf000) [root@ecdsa lib]#
i'll send the rest later
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-154911058.
Douglas E. Engert DEEngert@gmail.com
[root@ecdsa bin]# ./openssl req -engine pkcs11 -new -key slot_492971157-label_ivanecdsa -keyform engine -sha256 -out req.pem -subj "/CN=Ivan Wallis" initializing engine engine "pkcs11" set. Looking in slot 492971157 for key: label: ivanecdsa Found 2 slots [492971157] B2B8-5C8F-1924 Rt2 uninitialized (accelerator) [492971158] B2B8-5C8F-1924 Rt2 slot 0 no tok Found slot: B2B8-5C8F-1924 Rt2 Found token: accelerator Found 0 certificate: Found 2 keys: 1 P ivanrsa 2 P ivanecdsa 140005056951960:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 140005056951960:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306:
I created a new ecdsa keypair using pkcs11-tool, but still getting the same error:
./openssl req -engine pkcs11 -new -key slot_492971157-id_1234 -keyform engine -sha256 -out req.pem -subj "/CN=Ivan Wallis"
Note CKA_ID for public public and private.
Public Key Object; EC EC_POINT 256 bits EC_POINT: 04410486159c8bc0792c66382d51f222064fc7037eaec2986e65bebb10e3470523c77d1d6ef7683dcf3da72e2d63e6259768a7b5c10d835a4c75e1c3933243bc58b966 EC_PARAMS: 06082a8648ce3d030107 label: ivanecdsa Usage: verify Private Key Object; EC label: ivanecdsa2 ID: 1234 Usage: sign warning: PKCS11 function C_GetAttributeValue(ALWAYS_AUTHENTICATE) failed: rv = CKR_ATTRIBUTE_TYPE_INVALID (0x12)
Public Key Object; EC EC_POINT 256 bits EC_POINT: 044104dc407b385c2973ffda3961fc0c5c2d0aa0c5f27143468e788af51f04ab9435fdaf34609f25756ff602a3e262c1d53c7af6926e384389afe2464d7a6a07bb4077 EC_PARAMS: 06082a8648ce3d030107 label: ivanecdsa2 ID: 1234 Usage: verify
X509V3_set_ctx(0x7fffcf3c9360, 0, 0, 0xd414d0) = 0x7fffcf3c9360 X509V3_set_nconf(0x7fffcf3c9360, 0xd02d40, 0xd02d40, 0xd414d0) = 0x7fffcf3c9360 EVP_MD_CTX_init(0x7fffcf3c9300, 0xd414d0, 0xd3df10, 0x7f43616fa2a0) = 0x7fffcf3c9300 EVP_MD_CTX_init(0x7fffcf3c9300, 0x7fffcf3c9300, 0xd3df10, 0x7f43616fa2a0) = 0x7fffcf3c9300 EVP_DigestSignInit(0x7fffcf3c9300, 0x7fffcf3c92a8, 0x7f43616fa2a0, 0) = 1 sk_num(0, 0, 0xd40d40, 0xd40d40) = 0xffffffff X509_REQ_sign_ctx(0xd414d0, 0x7fffcf3c9300, 0x7fffcf3c9300, 0xd40d40) = 0 EVP_MD_CTX_cleanup(0x7fffcf3c9300, 1, 0xd2c800, 256) = 1 ERR_print_errors(0xc9b010, 0, 48, 256139927379130008:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139927379130008:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0
More output using softhsm, which also produces the same result:
[root@ecdsa bin]# ./openssl dgst -sha1 -engine pkcs11 -keyform engine -sign slot_0-label_key1 -out sig.txt data.txt initializing engine engine "pkcs11" set. Looking in slot 0 for key: label: key1 Found 2 slots [0] SoftHSM slot 0 login (slot0) [1] SoftHSM slot 1 uninitialized, login (no label) Found slot: SoftHSM slot 0 Found token: slot0 Found 0 certificate: PKCS#11 token PIN: Found 1 key: 1 P key1 Error Signing Data 139766204876544:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 3956 file=p11_misc.c, line=43, number=11, address=010F9590 3465 file=stack.c, line=162, number=32, address=010D6130 5725 file=p11_misc.c, line=26, number=296, address=010FB560 3955 file=p11_misc.c, line=43, number=16, address=010F9500 3942 file=p11_misc.c, line=43, number=16, address=010F8CD0 3464 file=dso_lib.c, line=106, number=72, address=010D6070 3954 file=p11_misc.c, line=43, number=1, address=010F9470 3950 file=p11_misc.c, line=43, number=15, address=010F9270 3939 file=p11_misc.c, line=26, number=80, address=010F43C0 3941 file=p11_misc.c, line=43, number=15, address=010F8C40 3949 file=p11_misc.c, line=26, number=112, address=010F9180 3459 file=stack.c, line=162, number=32, address=010D5D50 2684 file=lhash.c, line=122, number=128, address=010BC930
thread=139766204876440, file=err.c, line=454, info="int_thread_get (err.c)" 5730 file=buf_str.c, line=88, number=5, address=010FB350 3940 file=p11_misc.c, line=26, number=112, address=010F8B50 2682 file=err.c, line=1027, number=600, address=010BC4D0 3948 file=p11_misc.c, line=43, number=17, address=010F90F0 3461 file=stack.c, line=162, number=32, address=010D5E90 5710 file=p11_key.c, line=349, number=96, address=010F47E0 3944 file=p11_misc.c, line=26, number=40, address=010F8E60 3945 file=p11_misc.c, line=43, number=6, address=010F9060 5711 file=p11_misc.c, line=26, number=296, address=010FB060 3953 file=p11_misc.c, line=26, number=40, address=010F8E30 2685 file=lhash.c, line=191, number=24, address=010BC7E0 3466 file=stack.c, line=164, number=32, address=010D61D0 3947 file=p11_misc.c, line=43, number=11, address=010F9000 3463 file=buf_str.c, line=88, number=36, address=010D5FD0 3946 file=p11_misc.c, line=43, number=16, address=010F8F70 3468 file=dso_dlfcn.c, line=368, number=36, address=010D6310 3943 file=p11_misc.c, line=26, number=56, address=010F4890 3458 file=eng_dyn.c, line=210, number=88, address=010D5C80 3952 file=p11_misc.c, line=26, number=56, address=010F4BD0 2683 file=lhash.c, line=120, number=176, address=010BC800 thread=139766204876440, file=err.c, line=454, info="int_thread_get (err.c)" 3957 file=p11_misc.c, line=43, number=1, address=010F9620 3460 file=stack.c, line=164, number=32, address=010D5DF0 5716 file=buf_str.c, line=88, number=5, address=010F9B90 3462 file=stack.c, line=164, number=32, address=010D5F30 3951 file=p11_misc.c, line=43, number=16, address=010F9300 3467 file=dso_lib.c, line=356, number=36, address=010D6270 2723 bytes leaked in 39 chunks
In libp11 src/p11_ec.c at line 177 is a commented line: /* EC_KEY_print_fp(stderr, ec, 5); */
Can you uncomment and rebuild, and run some tests.
It run that statement twice.
The libp11 code takes the PKCS#11 private key, and the PKCS#11 public key and combines them into one OpenSSL EC_KEY This is needed as the private key may not have the ec_param
How are you at running gdb to do some debugging?
OpenSSL> initializing engine engine "pkcs11" set. Looking in slot 1 for key: 02 Found 2 slots [18446744073709551615] Virtual hotplug slot no tok [1] SCM Microsystems Inc. SCR login (PIV_II (PIV Card Holder pin)) Found slot: SCM Microsystems Inc. SCR 355 [CCID Interface] 00 00 Found token: PIV_II (PIV Card Holder pin) Found 3 certificates: 1 Certificate for PIV Authentication (/CN=dougengert) 2 Certificate for Digital Signature (/CN=deengert) 3 Certificate for Key Management (/CN=dougengert) PKCS#11 token PIN: Found 3 keys: 1 P PIV AUTH key 2 P SIGN key 3 P KEY MAN key Private-Key: (256 bit) pub: 04:5a:de:47:f5:b8:32:5a:75:eb:6f:0a:40:12:a5: 1a:42:b8:71:78:cb:48:51:63:b6:6a:c6:7e:c3:ae: e4:b4:db:74:50:e2:a9:e3:8f:dc:f4:a0:19:cf:3e: e5:39:c7:a1:0a:0f:c5:88:ce:07:23:4c:34:20:15: 0e:73:f9:c3:18 ASN1 OID: prime256v1 NIST CURVE: P-256 Private-Key: (256 bit) pub: 04:5a:de:47:f5:b8:32:5a:75:eb:6f:0a:40:12:a5: 1a:42:b8:71:78:cb:48:51:63:b6:6a:c6:7e:c3:ae: e4:b4:db:74:50:e2:a9:e3:8f:dc:f4:a0:19:cf:3e: e5:39:c7:a1:0a:0f:c5:88:ce:07:23:4c:34:20:15: 0e:73:f9:c3:18 ASN1 OID: prime256v1 NIST CURVE: P-256
On 11/9/2015 3:21 PM, Ivan Wallis wrote:
More output using softhsm, which also produces the same result:
[root@ecdsa bin]# ./openssl dgst -sha1 -engine pkcs11 -keyform engine -sign slot_0-label_key1 -out sig.txt data.txt initializing engine engine "pkcs11" set. Looking in slot 0 for key: label: key1 Found 2 slots [0] SoftHSM slot 0 login (slot0) [1] SoftHSM slot 1 uninitialized, login (no label) Found slot: SoftHSM slot 0 Found token: slot0 Found 0 certificate: PKCS#11 token PIN: Found 1 key: 1 P key1 Error Signing Data 139766204876544:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 3956 file=p11_misc.c, line=43, number=11, address=010F9590 3465 file=stack.c, line=162, number=32, address=010D6130 5725 file=p11_misc.c, line=26, number=296, address=010FB560 3955 file=p11_misc.c, line=43, number=16, address=010F9500 3942 file=p11_misc.c, line=43, number=16, address=010F8CD0 3464 file=dso_lib.c, line=106, number=72, address=010D6070 3954 file=p11_misc.c, line=43, number=1, address=010F9470 3950 file=p11_misc.c, line=43, number=15, address=010F9270 3939 file=p11_misc.c, line=26, number=80, address=010F43C0 3941 file=p11_misc.c, line=43, number=15, address=010F8C40 3949 file=p11_misc.c, line=26, number=112, address=010F9180 3459 file=stack.c, line=162, number=32, address=010D5D50 2684 file=lhash.c, line=122, number=128, address=010BC930
thread=139766204876440, file=err.c, line=454, info="int_thread_get (err.c)" 5730 file=buf_str.c, line=88, number=5, address=010FB350 3940 file=p11_misc.c, line=26, number=112, address=010F8B50 2682 file=err.c, line=1027, number=600, address=010BC4D0 3948 file=p11_misc.c, line=43, number=17, address=010F90F0 3461 file=stack.c, line=162, number=32, address=010D5E90 5710 file=p11_key.c, line=349, number=96, address=010F47E0 3944 file=p11_misc.c, line=26, number=40, address=010F8E60 3945 file=p11_misc.c, line=43, number=6, address=010F9060 5711 file=p11_misc.c, line=26, number=296, address=010FB060 3953 file=p11_misc.c, line=26, number=40, address=010F8E30 2685 file=lhash.c, line=191, number=24, address=010BC7E0 3466 file=stack.c, line=164, number=32, address=010D61D0 3947 file=p11_misc.c, line=43, number=11, address=010F9000 3463 file=buf_str.c, line=88, number=36, address=010D5FD0 3946 file=p11_misc.c, line=43, number=16, address=010F8F70 3468 file=dso_dlfcn.c, line=368, number=36, address=010D6310 3943 file=p11_misc.c, line=26, number=56, address=010F4890 3458 file=eng_dyn.c, line=210, number=88, address=010D5C80 3952 file=p11_misc.c, line=26, number=56, address=010F4BD0 2683 file=lhash.c, line=120, number=176, address=010BC800 thread=139766204876440, file=err.c, line=454, info="int_thread_get (err.c)" 3957 file=p11_misc.c, line=43, number=1, address=010F9620 3460 file=stack.c, line=164, number=32, address=010D5DF0 5716 file=buf_str.c, line=88, number=5, address=010F9B90 3462 file=stack.c, line=164, number=32, address=010D5F30 3951 file=p11_misc.c, line=43, number=16, address=010F9300 3467 file=dso_lib.c, line=356, number=36, address=010D6270 2723 bytes leaked in 39 chunks
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155199622.
Douglas E. Engert DEEngert@gmail.com
[root@ecdsa bin]# ./openssl dgst -sha1 -engine pkcs11 -keyform engine -sign slot_0-label_key1 -out sig.txt data.txt initializing engine engine "pkcs11" set. Looking in slot 0 for key: label: key1 Found 2 slots [0] SoftHSM slot 0 login (slot0) [1] SoftHSM slot 1 uninitialized, login (no label) Found slot: SoftHSM slot 0 Found token: slot0 Found 0 certificate: PKCS#11 token PIN: Found 1 key: 1 P key1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Error Signing Data 139781570053888:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:231:
Time to use gdb.
break pkcs11_load_public_key print the pk that is returned p *pk
break pkcs11_load_private_key print the pk that is returned p* pk
pkcs11_load_private_key If one of the above fails, may need to step into this to see why.
break ECDSA_do_sign step into it looking for what value is NULL
You can also add some printf statements into the code if needed.
The last set of changes deal with the reference count for the EVP_PKEY * pk in p11_ec.c pkcs11_get_ec_private What does it return?
You may want to step through this looking at the reference count. See the comments around line number 92. It may be the last reference is being dropped at the wrong time.
On 11/9/2015 6:20 PM, Ivan Wallis wrote:
[root@ecdsa bin]# ./openssl dgst -sha1 -engine pkcs11 -keyform engine -sign slot_0-label_key1 -out sig.txt data.txt initializing engine engine "pkcs11" set. Looking in slot 0 for key: label: key1 Found 2 slots [0] SoftHSM slot 0 login (slot0) [1] SoftHSM slot 1 uninitialized, login (no label) Found slot: SoftHSM slot 0 Found token: slot0 Found 0 certificate: PKCS#11 token PIN: Found 1 key: 1 P key1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Error Signing Data 139781570053888:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:231:
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155241536.
Douglas E. Engert DEEngert@gmail.com
Still debugging but pkcs11_get_ec_private does return 0
What is the process to reproduce that with softhsm? Does it work with a particular key/cert or with any random one?
Something like:
At least in my environment it can be reproduced with softhsm.
I ran step 4: softhsm2-util --init-token --slot 0 --label slot0
and then created ecdsa prime256v1 keypair using pkcs11-tool:
pkcs11-tool --module=/usr/local/lib/softhsm/libsofthsm2.so --login --pin 1234 --keypairgen --key-type EC:prime256v1 --id 1234 --label key1 --usage-sign
I even went ahead and used pkcs11-tool to create an ecdsa signature:
pkcs11-tool -v -f openssl --module=/usr/local/lib/softhsm/libsofthsm2.so -m ECDSA --login --pin 1234 --sign --label key1 --input data.txt --output sig.txt
Also running openssl dgst:
./openssl dgst -sha1 -engine pkcs11 -keyform engine -sign slot_0-label_key1 -out sig.txt data.txt initializing engine engine "pkcs11" set. Looking in slot 0 for key: label: key1 Found 2 slots [0] SoftHSM slot 0 login (slot0) [1] SoftHSM slot 1 uninitialized, login (no label) Found slot: SoftHSM slot 0 Found token: slot0 Found 0 certificate: PKCS#11 token PIN: Found 1 key: 1 P key1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Private-Key: (256 bit) pub: 04:5e:a8:70:41:a9:8c:da:d3:cd:71:1a:32:a3:16: 0e:96:0a:c9:63:a7:3d:d1:7d:f2:09:48:38:d4:08: cd:e2:e2:96:dd:a2:72:d3:36:6b:0d:6c:c5:4a:20: a0:72:df:02:d2:93:d8:98:55:84:83:cb:03:05:0b: 5f:9f:af:85:46 ASN1 OID: prime256v1 Error Signing Data 140115377821440:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:231:
[openssl_def] engines = engine_section
[engine_section] pkcs11 = pkcs11_section
[pkcs11_section] engine_id = pkcs11 dynamic_path = /usr/local/lib/engines/libpkcs11.so MODULE_PATH = /usr/local/lib/pkcs11-spy.so init = 0 VERBOSE = EMPTY
@dengert
break ECDSA_do_sign step into it looking for what value is NULL
priv_key is NULL
Are you compiling with OpenSSL_FIPS mode? That may not work.
Here is an gdb stach trace that is working using PIV card whe it enters pkcs11_ecdsa_do_sign So someplace to look at is OpenSSL ecs_sign.c:89 that runs ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey); that calls ecdsa_check that may show something.
ECDSA_do_sign_ex should be loading pkcs11_ecdsa_do_sign here: 74 return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey);
dgst=0x7fffffffce80 "\217\225\207\224Sg\315\303\303\017\213y\330I7\234S\227\065z\323\302\062'N\345|\036\310\346ך;\001", dlen=32, inv=0x0, r=0x0,
ec=0x6e9c20) at ../../src/src/p11_ec.c:228
dgst=dgst@entry=0x7fffffffce80 "\217\225\207\224Sg\315\303\303\017\213y\330I7\234S\227\065z\323\302\062'N\345|\036\310\346ך;\001", dlen=dlen@entry=32,
sig=sig@entry=0x6eac30 " \244n", siglen=siglen@entry=0x7fffffffcde0,
kinv=kinv@entry=0x0, r=r@entry=0x0, eckey=eckey@entry=0x6e9c20)
at ecs_sign.c:89
dgst=dgst@entry=0x7fffffffce80 "\217\225\207\224Sg\315\303\303\017\213y\330I7\234S\227\065z\323\302\062'N\345|\036\310\346ך;\001", dlen=dlen@entry=32,
sig=sig@entry=0x6eac30 " \244n", siglen=siglen@entry=0x7fffffffcde0,
eckey=eckey@entry=0x6e9c20) at ecs_sign.c:80
sig=0x6eac30 " \244n", siglen=0x7fffffffcf50,
tbs=0x7fffffffce80 "\217\225\207\224Sg\315\303\303\017\213y\330I7\234S\227\065z\323\302\062'N\345|\036\310\346ך;\001", tbslen=32) at ec_pmeth.c:180
sigret=sigret@entry=0x6eac30 " \244n", siglen=siglen@entry=0x7fffffffcf50)
at m_sigver.c:163
---Type
ctx=ctx@entry=0x7fffffffcfb0) at x_all.c:104
pkey=<optimized out>, md=md@entry=0x7ffff7b4b280 <sha256_md>,
sigopts=sigopts@entry=0x0) at req.c:1703
at req.c:828
argv=0x6aa6d0) at openssl.c:477
at openssl.c:408
it just shows that priv_key is null.
pkcs11_ecdsa_do_sign is never called which means I am not building libp11 correctly. I am using libp11-0.3.0 straight from github.
Can you provide your working build instructions?
I have scripts to do the configures and use --prefix=/opt/smartcard for OpenSSL, OpenSC, libp11 and engine_pkcs11 (Build in that order too.)
For libp11 the script does:
OPENSSL_CFLAGS=-I/opt/smartcard/include OPENSSL_LIBS=-L/opt/smartcard/lib -lcrypto
CC=gcc CFLAGS=-g CPPFLAGS= LDFLAGS=-g
LD_LIBRARY_PATH=/opt/smartcard/lib: export CC CFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH DYLD_LIBRARY_PATH
PKG_CONFIG_PATH=/opt/smartcard/lib/pkgconfig export PKG_CONFIG_PATH ../src/configure --prefix=/opt/smartcard
At the end of the configure output it has: libp11 has been configured with the following options:
Version: 0.3.0_git Libraries: /opt/smartcard/lib
api doc support: no
Host: x86_64-unknown-linux-gnu Compiler: gcc Preprocessor flags: Compiler flags: -g Linker flags: -g Libraries: -ldl
PTHREAD_FLAGS: OPENSSL_CFLAGS: -I/opt/smartcard/include OPENSSL_LIBS: -L/opt/smartcard/lib -lcrypto
Make sure that it is including the correct locations for OPENSSL_CFLAGS and OPENSSL_LIBS
To see more of the compilation, in the src/Makefile change AM_DEFAULT_VERBOSITY = 0 to AM_DEFAULT_VERBOSITY = 1
For the p11_ec.c it does this. Note the -I/opt/smartcard/include :
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../src/src -I.. -I/opt/smartcard/include -g -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c -o
libp11_la-p11_ec.lo test -f 'p11_ec.c' || echo '../../src/src/'
p11_ec.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../src/src -I.. -I/opt/smartcard/include -g -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c ../../src/src/p11_ec.c -fPIC -DPIC -o
.libs/libp11_la-p11_ec.o
../../src/src/p11_ec.c: In function 'PKCS11_get_ecdsa_method':
../../src/src/p11_ec.c:266:2: warning: passing argument 1 of 'ECDSA_METHOD_new' discards 'const' qualifier from pointer target type [enabled by default]
ops = ECDSA_METHOD_new(ECDSA_OpenSSL());
^
In file included from ../../src/src/p11_ec.c:38:0:
/opt/smartcard/include/openssl/ecdsa.h:236:15: note: expected 'struct ECDSA_METHOD ' but argument is of type 'const struct ECDSA_METHOD '
ECDSA_METHOD ECDSA_METHOD_new(ECDSA_METHOD ecdsa_method);
^
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../src/src -I.. -I/opt/smartcard/include -g -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c ../../src/src/p11_ec.c -o
libp11_la-p11_ec.o >/dev/null 2>&1
mv -f .deps/libp11_la-p11_ec.Tpo .deps/libp11_la-p11_ec.Plo
(The warning should be fixed, but is minor)
On 11/10/2015 8:19 PM, Ivan Wallis wrote:
it just shows that priv_key is null.
pkcs11_ecdsa_do_sign is never called which means I am not building libp11 correctly. I am using libp11-0.3.0 straight from github.
Can you provide your working build instructions?
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155633211.
Douglas E. Engert DEEngert@gmail.com
Still no luck. I prefixed everything to /opt/openssl-1.0.2d for OpenSSL and engine_pkcs11 and set LD_LIBRARY_PATH.
libp11 has been configured with the following options:
Version: 0.3.0 Libraries: /opt/openssl-1.0.2d/lib
api doc support: no
Host: x86_64-unknown-linux-gnu Compiler: gcc Preprocessor flags: Compiler flags: -g -O2 Linker flags: -g Libraries: -ldl
PTHREAD_FLAGS: OPENSSL_CFLAGS: -I/opt/openssl-1.0.2d/include OPENSSL_LIBS: -L/opt/openssl-1.0.2d/lib -lcrypto
relevant make output:
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I/opt/openssl-1.0.2d/include -g -O2 -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c -o libp11_la-p11_ec.lo test -f 'p11_ec.c' || echo './'
p11_ec.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/opt/openssl-1.0.2d/include -g -O2 -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c p11_ec.c -fPIC -DPIC -o .libs/libp11_la-p11_ec.o
p11_ec.c: In function 'pkcs11_ecdsa_do_sign':
p11_ec.c:242:7: warning: implicit declaration of function 'PKCS11_ecdsa_sign' [-Wimplicit-function-declaration]
rv = PKCS11_ecdsa_sign(dgst,dlen,sigret,&siglen, key);
^
p11_ec.c: In function 'PKCS11_get_ecdsa_method':
p11_ec.c:266:25: warning: passing argument 1 of 'ECDSA_METHOD_new' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
ops = ECDSA_METHOD_new(ECDSA_OpenSSL());
^
In file included from p11_ec.c:38:0:
/opt/openssl-1.0.2d/include/openssl/ecdsa.h:236:15: note: expected 'ECDSA_METHOD * {aka struct ecdsa_method }' but argument is of type 'const ECDSA_METHOD * {aka const struct ecdsa_method }'
ECDSA_METHOD ECDSA_METHOD_new(ECDSA_METHOD ecdsa_method);
^
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/opt/openssl-1.0.2d/include -g -O2 -MT libp11_la-p11_ec.lo -MD -MP -MF .deps/libp11_la-p11_ec.Tpo -c p11_ec.c -o libp11_la-p11_ec.o >/dev/null 2>&1
mv -f .deps/libp11_la-p11_ec.Tpo .deps/libp11_la-p11_ec.Plo
Ok, if priv_key is NULL that is OK if using engine. it could mean that the engine in the is not setting PKCS11_get_ecdsa_method is not being set correctly, so never tries to using the engine to sign.
Can you try gdb with these:
(gdb) break ecdsa_check (gdb) break PKCS11_get_ecdsa_method (gdb) break PKCS11_ecdsa_method_free (gdb) break pkcs11_ecdsa_do_sign
Breakpoint 2, PKCS11_get_ecdsa_method () at ../../src/src/p11_ec.c:265
265 if (ops == NULL) {
(gdb) p ops
$7 = (ECDSA_METHOD ) 0x0
(gdb) n
266 ops = ECDSA_METHOD_new(ECDSA_OpenSSL());
(gdb) n
267 ECDSA_METHOD_set_sign(ops, pkcs11_ecdsa_do_sign);
(gdb) p ops
$8 = (ECDSA_METHOD ) 0x6aefb0
(gdb) n
268 ECDSA_METHOD_set_sign_setup(ops, pkcs11_ecdsa_sign_setup);
(gdb) n
270 return ops;
(gdb) p *ops
$9 = {name = 0x7ffff78ed17d "OpenSSL ECDSA method",
ecdsa_do_sign = 0x7ffff6d3ce4f
{prints out on stderr the private key ending with the lines]
ASN1 OID: prime256v1
NIST CURVE: P-256
Breakpoint 1, ecdsa_check (key=0x6e9c20) at ecs_lib.c:187 187 { (gdb) where
arg=0x6ea060) at ecs_lib.c:264
at ../../src/src/p11_ec.c:195
at ../../src/src/p11_key.c:246
s_slot_key_id=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=0x7fffffffcfe0, isPrivate=1)
at ../../src/src/engine_pkcs11.c:1027
s_key_id=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=0x7fffffffcfe0) at ../../src/src/engine_pkcs11.c:1054
key_id=key_id@entry=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=callback_data@entry=0x7fffffffcfe0) at eng_pkey.c:121
file=file@entry=0x7fffffffd88b "slot_1-id_2", format=format@entry=7,
maybe_stdin=maybe_stdin@entry=0, pass=<optimized out>, e=<optimized out>,
key_descrip=key_descrip@entry=0x471749 "Private Key") at apps.c:977
---Type
at openssl.c:408
(gdb) p *key $10 = {version = 1, group = 0x6e82d0, pub_key = 0x6e4d30, priv_key = 0x0, enc_flag = 0, conv_form = POINT_CONVERSION_UNCOMPRESSED, references = 2, flags = 0, method_data = 0x0}
[Second time it hits ecdsa_check]
ASN1 OID: prime256v1
NIST CURVE: P-256
Breakpoint 1, ecdsa_check (key=0x6e9c20) at ecs_lib.c:187 187 { (gdb) where
arg=0x6ea060) at ecs_lib.c:264
at ../../src/src/p11_ec.c:195
at ../../src/src/p11_ec.c:208
at ../../src/src/p11_key.c:247
s_slot_key_id=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=0x7fffffffcfe0, isPrivate=1)
at ../../src/src/engine_pkcs11.c:1027
s_key_id=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=0x7fffffffcfe0) at ../../src/src/engine_pkcs11.c:1054
key_id=key_id@entry=0x7fffffffd88b "slot_1-id_2", ui_method=0x6a51c0,
callback_data=callback_data@entry=0x7fffffffcfe0) at eng_pkey.c:121
file=file@entry=0x7fffffffd88b "slot_1-id_2", format=format@entry=7,
maybe_stdin=maybe_stdin@entry=0, pass=<optimized out>, e=<optimized out>,
key_descrip=key_descrip@entry=0x471749 "Private Key") at apps.c:977
---Type
argv=0x6aa6d0) at openssl.c:477
at openssl.c:408
(gdb) p key
$11 = {version = 1, group = 0x6ea290, pub_key = 0x6e4d30, priv_key = 0x0,
enc_flag = 0, conv_form = POINT_CONVERSION_UNCOMPRESSED, references = 2,
flags = 0, method_data = 0x6e9ca0}
(gdb) p key->method_data
$12 = {next = 0x0, data = 0x6ea7d0,
dup_func = 0x7ffff7816810
(gdb) c Continuing.
[third time it hits ecdsa_check] Breakpoint 1, ecdsa_check (key=key@entry=0x6e9c20) at ecs_lib.c:187 187 { (gdb) where
dgst=0x7fffffffce80 "\004K-\267\206\205\372\273\202\314\016\030g\231\261\347\033\064\203\334`\252\240\f$\277\023\320\071\242\065\257;\001", dlen=32,
kinv=0x0, rp=0x0, eckey=0x6e9c20) at ecs_sign.c:71
dgst=dgst@entry=0x7fffffffce80 "\004K-\267\206\205\372\273\202\314\016\030g\231\261\347\033\064\203\334`\252\240\f$\277\023\320\071\242\065\257;\001",
dlen=dlen@entry=32, sig=sig@entry=0x6eac30 " \244n",
siglen=siglen@entry=0x7fffffffcde0, kinv=kinv@entry=0x0, r=r@entry=0x0,
eckey=eckey@entry=0x6e9c20) at ecs_sign.c:89
dgst=dgst@entry=0x7fffffffce80 "\004K-\267\206\205\372\273\202\314\016\030g\231\261\347\033\064\203\334`\252\240\f$\277\023\320\071\242\065\257;\001",
dlen=dlen@entry=32, sig=sig@entry=0x6eac30 " \244n",
siglen=siglen@entry=0x7fffffffcde0, eckey=eckey@entry=0x6e9c20)
at ecs_sign.c:80
sig=0x6eac30 " \244n", siglen=0x7fffffffcf50,
tbs=0x7fffffffce80 "\004K-\267\206\205\372\273\202\314\016\030g\231\261\347\033\064\203\334`\252\240\f$\277\023\320\071\242\065\257;\001", tbslen=32)
at ec_pmeth.c:180
---Type
algor1=0x6ea4f0, algor2=0x6eaf90, signature=0x6eb8b0, asn=<optimized out>,
ctx=ctx@entry=0x7fffffffcfb0) at a_sign.c:304
ctx=ctx@entry=0x7fffffffcfb0) at x_all.c:104
pkey=<optimized out>, md=md@entry=0x7ffff7b4b280 <sha256_md>,
sigopts=sigopts@entry=0x0) at req.c:1703
at req.c:828
argv=0x6aa6d0) at openssl.c:477
at openssl.c:408
(gdb) c Continuing.
Breakpoint 4, pkcs11_ecdsa_do_sign ( dgst=0x7fffffffce80 "\004K-\267\206\205\372\273\202\314\016\030g\231\261\347\033\064\203\334`\252\240\f$\277\023\320\071\242\065\257;\001", dlen=32, inv=0x0, r=0x0, ec=0x6e9c20) at ../../src/src/p11_ec.c:228 228 {
Douglas E. Engert DEEngert@gmail.com
PKCS11_get_ecdsa_method never gets called as we never hit the breakpoint. What should I check with engine_pkcs11?
ok hardcode fix was to modify engine_pkcs11 src/hw_pkcs11.c and ensure this line is compiled:
!ENGINE_set_ECDSA(e, PKCS11_get_ecdsa_method()) ||
last line of config.log:
For whatever reason it is picking up that OpenSSL doesn't support ECDSA.
I'll keep investigating.
engine_pkcs11 hw_pkcs11.c bind_helper() sets up the engine hooks. try
break bind_helper break hw_pkcs11.c:184 break hw_pkcs11.c:184 break ENGINE_set_ECDSA break PKCS11_get_ecdsa_method()
184 if (!ENGINE_set_id(e, PKCS11_ENGINE_ID) || 185 !ENGINE_set_destroy_function(e, pkcs11_engine_destroy) || 186 !ENGINE_set_init_function(e, pkcs11_init) || 187 !ENGINE_set_finish_function(e, pkcs11_finish) || 188 !ENGINE_set_ctrl_function(e, pkcs11_engine_ctrl) || 189 !ENGINE_set_cmd_defns(e, pkcs11_cmd_defns) || 190 !ENGINE_set_name(e, PKCS11_ENGINE_NAME) || 191 #ifndef OPENSSL_NO_RSA 192 !ENGINE_set_RSA(e, PKCS11_get_rsa_method()) || 193 #endif 194 #ifndef OPENSSL_NO_EC 195 #ifndef OPENSSL_NO_ECDSA 196 !ENGINE_set_ECDSA(e, PKCS11_get_ecdsa_method()) || 197 #endif 198 /* TODO add ECDH 199 !ENGINE_set_ECDH(e, PKCS11_get_ecdh_method()) || 200 */ 201 #endif 202 !ENGINE_set_load_pubkey_function(e, pkcs11_load_public_key) || 203 !ENGINE_set_load_privkey_function(e, pkcs11_load_private_key)) { 204 return 0; 205 } else { 206 return 1; 207 }
It could be that OpenSSL had defined OPENSSL_NO_EC or OPENSSL_NO_ECDSA so line 196 never gets compiled!
Here is what it should look like, #1 is at line 196
Breakpoint 6, bind_helper (e=0x6aacc0) at ../../src/src/hw_pkcs11.c:184 184 if (!ENGINE_set_id(e, PKCS11_ENGINE_ID) || (gdb) n 185 !ENGINE_set_destroy_function(e, pkcs11_engine_destroy) || (gdb) n 184 if (!ENGINE_set_id(e, PKCS11_ENGINE_ID) || (gdb) n 186 !ENGINE_set_init_function(e, pkcs11_init) || (gdb) n 185 !ENGINE_set_destroy_function(e, pkcs11_engine_destroy) || (gdb) n 187 !ENGINE_set_finish_function(e, pkcs11_finish) || (gdb) n 186 !ENGINE_set_init_function(e, pkcs11_init) || (gdb) n 188 !ENGINE_set_ctrl_function(e, pkcs11_engine_ctrl) || (gdb) n 187 !ENGINE_set_finish_function(e, pkcs11_finish) || (gdb) n 189 !ENGINE_set_cmd_defns(e, pkcs11_cmd_defns) || (gdb) n 188 !ENGINE_set_ctrl_function(e, pkcs11_engine_ctrl) || (gdb) n 190 !ENGINE_set_name(e, PKCS11_ENGINE_NAME) || (gdb) n 189 !ENGINE_set_cmd_defns(e, pkcs11_cmd_defns) || (gdb) 192 !ENGINE_set_RSA(e, PKCS11_get_rsa_method()) || (gdb) 190 !ENGINE_set_name(e, PKCS11_ENGINE_NAME) || (gdb) 196 !ENGINE_set_ECDSA(e, PKCS11_get_ecdsa_method()) || (gdb)
Breakpoint 2, PKCS11_get_ecdsa_method () at ../../src/src/p11_ec.c:265 265 if (ops == NULL) { (gdb) 266 ops = ECDSA_METHOD_new(ECDSA_OpenSSL()); (gdb)
On 11/11/2015 8:43 AM, Ivan Wallis wrote:
PKCS11_get_ecdsa_method never gets called as we never hit the breakpoint. What should I check with engine_pkcs11?
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155800518.
Douglas E. Engert DEEngert@gmail.com
Did you run the engine_pkcs11/bootstrap? It uses automake on ./configure.ac to produce ./configure
On 11/11/2015 10:31 AM, Ivan Wallis wrote:
ok hardcode fix was to modify engine_pkcs11 src/hw_pkcs11.c and ensure this line is compiled:
!ENGINE_set_ECDSA(e, PKCS11_get_ecdsa_method()) ||
last line of config.log:
define OPENSSL_NO_ECDSA /**/
For whatever reason it is picking up that OpenSSL doesn't support ECDSA.
I'll keep investigating.
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155836134.
Douglas E. Engert DEEngert@gmail.com
engine_pkcs11/configure checks for the PKCS11_ecdsa_method_free in libp11 What parameters were used to configure engine_pkcs11?
Did you set LIBP11_CFLAGS= and LIBP11_LIBS= Or have done something like: PKG_CONFIG_PATH=/opt/smartcard/lib/pkgconfig export PKG_CONFIG_PATH (Where the directory has the libp11.pc) before running configure
On 11/11/2015 10:31 AM, Ivan Wallis wrote:
ok hardcode fix was to modify engine_pkcs11 src/hw_pkcs11.c and ensure this line is compiled:
!ENGINE_set_ECDSA(e, PKCS11_get_ecdsa_method()) ||
last line of config.log:
define OPENSSL_NO_ECDSA /**/
For whatever reason it is picking up that OpenSSL doesn't support ECDSA.
I'll keep investigating.
— Reply to this email directly or view it on GitHub https://github.com/OpenSC/libp11/issues/34#issuecomment-155836134.
Douglas E. Engert DEEngert@gmail.com
Finally have things working with a properly configured environment. Thanks for your help.
Running into this myself now. I actually am using openssl compiled with OpenSSL_FIPS
. You mentioned above that this would not work @dengert -- is this a limitation of OpenSSL or of libp11? Seems strange that this would be a limitation if fips mode is not turned on... Is there anyway around this?
I said it may not work.
If I recall correctly, OpenSSL_FIPS greatly limits what hooks are available that are needed to implement an engine. i.e. using an engine allows the external code to do crypto operations in effect violating the spirit of FIPS. http://openssl.com/fips/history.html says the latest FIPS module is compatible with 1.0.1. EC support in OpenSSL, especially for use with an engine, was originally non existent and has changed from version to version. (It required compiling the application with internal OpenSSL header files too.) ECDSA_METHOD was added first, then ECDH_METHOD, then these where replaced with EC_KEY_METHOD. The above discussion is about using 1.0.2d or 1.0.2f. Even in minor versions OpenSSL was changing EC engine code. Just getting the libp11 engine code to work was a challenge, and FIPS mode based on 1.0.1 was never looked at.
Roger. Looks like the source of my problem is actually not FIPS mode but static linking. :(
We have a library that statically links openssl (in order to just expose a few limited functions and not everything openssl can do), and this is trying to load pkcs11.dll which also is linked against openssl statically. It is basically failing in the ecdsa_check
function -- this is being called in the context of our openssl wrapper library, and thus its function pointers for ecdsa_dup
, ecdsa_free
, etc. are different than the ones set from pkcs11_get_evp_key_ec
in the context of libp11.dll. Thus, it never finds the method data, ends up calling the built in openssl routes and never invokes the engine :(
FYI. wrote an email to the openssl-dev mailing list about the above static linking issue: https://groups.google.com/forum/#!topic/mailing.openssl.dev/AV7Pd8357pQ
OpenSSL-1.1.0 no longer uses ecdsa_check. libp11 can be compiled
with OpenSSL-1.1.0 so you may want to look at it.
On 7/12/2016 12:49 PM, Matt Hauck
wrote:
Roger. Looks like the source of my problem is actually not FIPS
mode but static linking. :(
We have a library that statically links openssl (in order to
just expose a few limited functions and not everything openssl
can do), and this is trying to load pkcs11.dll which also is
linked against openssl statically. It is basically failing in
the ecdsa_check function -- this is being called
in the context of our openssl wrapper library, and thus its
function pointers for ecdsa_dup, ecdsa_free,
etc. are different than the ones set from pkcs11_get_evp_key_ec
in the context of libp11.dll. Thus, it never finds the method
data, ends up calling the built in openssl routes and never
invokes the engine :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view
it on GitHub, or mute
the thread.
--
Douglas E. Engert DEEngert@gmail.com
What if you link dynamically rather then static?
On 7/12/2016 12:49 PM, Matt Hauck
wrote:
Roger. Looks like the source of my problem is actually not FIPS
mode but static linking. :(
We have a library that statically links openssl (in order to
just expose a few limited functions and not everything openssl
can do), and this is trying to load pkcs11.dll which also is
linked against openssl statically. It is basically failing in
the ecdsa_check function -- this is being called
in the context of our openssl wrapper library, and thus its
function pointers for ecdsa_dup, ecdsa_free,
etc. are different than the ones set from pkcs11_get_evp_key_ec
in the context of libp11.dll. Thus, it never finds the method
data, ends up calling the built in openssl routes and never
invokes the engine :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view
it on GitHub, or mute
the thread.
--
Douglas E. Engert DEEngert@gmail.com
What if you link dynamically rather then static?
This:
$ openssl version
OpenSSL 1.0.2h 3 May 2016
$ pkcs11-ecdsa-demo2
Generating random 250 bytes of Base64-encoded data...
openssl rand -base64 -out /tmp/derive.27369.text 250
Examining public key on the token to determine its curve...
Using reader with a card: Yubico Yubikey NEO OTP+U2F+CCID
read EC key
The key pair is on the curve prime256v1, will use hash sha256
Generating digital signature over /tmp/derive.27369.text...
openssl dgst -engine pkcs11 -keyform engine -sha256 -sign "pkcs11:object=SIGN%20key;object-type=private" -out /tmp/derive.27369.text.sig /tmp/derive.27369.text
engine "pkcs11" set.
PKCS#11 token PIN:
Signature is stored in /tmp/derive.27369.text.sig
Verifying signature over /tmp/derive.27369.text...
openssl dgst -engine pkcs11 -keyform engine -sha256 -verify "pkcs11:object=SIGN%20pubkey;object-type=public" -signature /tmp/derive.27369.text.sig /tmp/derive.27369.text
engine "pkcs11" set.
Verified OK
$ pkcs11-ec-derive-demo3
Extracting public key from the token (in PEM format)...
pkcs15-tool --read-public-key 03 -o /tmp/derive.27384.token.pub.pem
Using reader with a card: Yubico Yubikey NEO OTP+U2F+CCID
CURVE=`openssl ec -in /tmp/derive.27384.token.pub.pem -pubin -text -noout | fgrep ASN1 | cut -d ' ' -f 3`
read EC key
Generating ephemeral ECC key pair on prime256v1...
openssl ecparam -name prime256v1 -genkey -out /tmp/derive.27384.priv.pem
openssl ec -in /tmp/derive.27384.priv.pem -pubout -outform DER -out /tmp/derive.27384.pub.der
read EC key
writing EC key
Generating random 128-bit IV...
IV=`openssl rand -hex 16`
Generating random 250 bytes of Base64-encoded data...
openssl rand -base64 -out /tmp/derive.27384.text 250
Deriving shared key from ephemeral private and token public keys...
openssl pkeyutl -engine pkcs11 -derive -keyform PEM -inkey /tmp/derive.27384.priv.pem -peerform engine -peerkey "pkcs11:object=KEY%20MAN%20pubkey;object-type=public" -hexdump
engine "pkcs11" set.
0000 - 83 87 72 8d 67 5b 62 de-1a 11 eb 32 0e 7f ac 1f ..r.g[b....2....
0010 - ba 72 e3 14 0e 53 54 b1-a2 6e ca e9 42 6a e3 76 .r...ST..n..Bj.v
openssl pkeyutl -derive -inkey /tmp/derive.27384.priv.pem -peerform PEM -peerkey /tmp/derive.27384.token.pub.pem | xxd -c 256 -p
KEY1=8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376
Encrypting data file with derived symmetric key and AES-CFB...
openssl enc -aes-256-cfb -e -a -K 8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376 -iv 4acdf9442a9f89f44edc275f83917498 -in /tmp/derive.27384.text -out /tmp/derive.27384.text.enc
Deriving shared symmetric key on the token, using ephemeral public key...
openssl pkeyutl -engine pkcs11 -keyform engine -derive -inkey "pkcs11:object=KEY%20MAN%20key;object-type=private" -peerform DER -peerkey /tmp/derive.27384.pub.der | xxd -c 256 -p
engine "pkcs11" set.
PKCS#11 token PIN:
KEY2=8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376
Decrypting data file with derived symmetric key and AES-CFB...
openssl enc -aes-256-cfb -d -a -K 8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376 -iv 4acdf9442a9f89f44edc275f83917498 -in /tmp/derive.27384.text.enc -out /tmp/derive.27384.text.dec
Showing derived key via hexdump:
openssl pkeyutl -engine pkcs11 -keyform engine -derive -inkey "pkcs11:object=KEY%20MAN%20key;object-type=private" -peerform DER -peerkey /tmp/derive.27384.pub.der -hexdump
engine "pkcs11" set.
PKCS#11 token PIN:
0000 - 83 87 72 8d 67 5b 62 de-1a 11 eb 32 0e 7f ac 1f ..r.g[b....2....
0010 - ba 72 e3 14 0e 53 54 b1-a2 6e ca e9 42 6a e3 76 .r...ST..n..Bj.v
KEY1="8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376"
KEY2="8387728d675b62de1a11eb320e7fac1fba72e3140e5354b1a26ecae9426ae376"
Original and decrypted keys match
Decrypted file matches the original plaintext.
$
@dengert - I verified that dynamically linking solves the problem. Unfortunately this is not an option for us, neither is moving to 1.1.0 for complicated reasons. We ended up with a small patch for openssl that resolves this by attaching the ECDSA_METHOD pointer to the EC_KEY struct directly.
Good to hear you have a circumvention. Since OpenSSL-1.1.0 no longer has ECDSA_METHOD and ECDH_METHOD, but a single EC_KEY_METHOD with routines for sign and compute_key. Thus there is no need for the ecdsa_check. I don't think you would need the "small patch" with 1.1.0
Hi,
I'm attempting to generate a csr via openssl:
openssl req -engine pkcs11 -new -key slot_492971157-label_myecdsa -keyform engine -out req.pem -x509 -subj "/CN=John Smith"
The error is:
engine "pkcs11" set. 139637347223200:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139637347223200:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306:
[pid 2086] ERR_load_crypto_strings(0x469a01, 0x7fff82159856, 0x7fff821589e8, 0) = 0x7f0ca9d34cb8 [pid 2086] OPENSSL_load_builtin_modules(0xcbe010, 0xcd83a0, 0, 0x7fff82157dd0) = 1 [pid 2086] CONF_modules_load(0xcd83a0, 0, 0, 2) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0, 0x469b27, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0, 0x47736a, 0) = 0xcd8d00 [pid 2086] NCONF_get_section(0xcd83a0, 0xcd8d00, 11, 0) = 0xcd90b0 [pid 2086] sk_num(0xcd90b0, 0xcd8d00, 8, 0) = 3 [pid 2086] sk_value(0xcd90b0, 0, 8, 0) = 0xcd94a0 [pid 2086] OBJ_create(0xcd9500, 0xcd94c0, 0xcd94c0, 0) = 958 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] sk_value(0xcd90b0, 1, 0x7f0ca9b47768, 0xcdf040) = 0xcd9520 [pid 2086] OBJ_create(0xcd9580, 0xcd9540, 0xcd9540, 0xcdf040) = 959 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] sk_value(0xcd90b0, 2, 0x7f0ca9b47768, 0xcdf040) = 0xcd95a0 [pid 2086] OBJ_create(0xcd9600, 0xcd95c0, 0xcd95c0, 0xcdf040) = 960 [pid 2086] sk_num(0xcd90b0, 0xffffffff, 0x7f0ca9b47768, 0xcdf040) = 3 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b30, 0xcdf040) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b3b, 0) = 0xcdaf00 [pid 2086] X509V3_set_ctx(0x7fff82157e00, 0, 0, 0) = 0xcdaf00 [pid 2086] X509V3_set_nconf(0x7fff82157e00, 0xcd83a0, 0, 0) = 0x7f0ca9f93f00 [pid 2086] X509V3_EXT_add_nconf(0xcd83a0, 0x7fff82157e00, 0xcdaf00, 0) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b4b, 0xcdf060) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b5a, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b6a, 0) = 0xcdaf80 [pid 2086] ASN1_STRING_set_default_mask_asc(0xcdaf80, 0x469b6a, 11, 0) = 1 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x4699c0, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b76, 0) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] BIO_s_file(0, 0xffffffff, 0x7f0ca9b47788, 0) = 0x7f0ca9f908a0 [pid 2086] BIO_new(0x7f0ca9f908a0, 0xffffffff, 0x7f0ca9b47788, 0) = 0xcdf720 [pid 2086] BIO_s_file(0xcdf720, 436, 0x7f0ca9ce9436, 4) = 0x7f0ca9f908a0 [pid 2086] BIO_new(0x7f0ca9f908a0, 436, 0x7f0ca9ce9436, 4) = 0xcdf7a0 [pid 2086] ENGINE_by_id(0x7fff821597fd, 0x7fff821597fe, 0, 4) = 0xcddf50 [pid 2086] ENGINE_ctrl_cmd(0xcddf50, 0x477486, 0, 0xcd81c0) = 1 [pid 2086] ENGINE_set_default(0xcddf50, 0xffff, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] ENGINE_get_id(0xcddf50, 187, 0x7f0ca9d296f4, 8) = 0x7f0ca9382368 [pid 2086] BIO_printf(0xcbe010, 0x4774b0, 0x7f0ca9382368, 8engine "pkcs11" set. ) = 21 [pid 2086] ENGINE_free(0xcddf50, 274, 0x7f0ca9ce91ba, 0) = 1 [pid 2086] ENGINE_load_private_key(0xcddf50, 0x7fff8215980e, 0xcd81c0, 0x7fff82157c00) = 0xcf3fe0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469b85, 0xcfc4b0) = 0xcd8c80 [pid 2086] RAND_egd(0xcd8c80, 0xcbe010, 0, 0) = 0 [pid 2086] RAND_load_file(0xcd8c80, -1, 12, 0) = 0 [pid 2086] RAND_status(0xcd8c80, 0x7fff82157660, 0, -1) = 1 [pid 2086] X509_REQ_new(0x689160, 0x46a830, 0x7f0ca9d2ac53, 1) = 0xcfcb10 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469c01, 0x7f0ca9b47760) = 0 [pid 2086] ERR_clear_error(0, 473, 1, 15) = 0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x469c08, 0xcfd170) = 0xcdada0 [pid 2086] NCONF_get_section(0xcd83a0, 0xcdada0, 2, 0) = 0xcd9da0 [pid 2086] NCONF_get_string(0xcd83a0, 0x471490, 0x4778d8, 0) = 0xcdae30 [pid 2086] NCONF_get_section(0xcd83a0, 0xcdae30, 10, 0) = 0xcdabf0 [pid 2086] X509_REQ_set_version(0xcfcb10, 0, 14, 0) = 1 [pid 2086] strlen("/CN=Ivan Wallis") = 15 [pid 2086] CRYPTO_malloc(16, 0x4772dc, 2134, 2134) = 0xcfc5f0 [pid 2086] CRYPTO_malloc(72, 0x4772dc, 2136, 0x7f0ca9b47760) = 0xcfd000 [pid 2086] CRYPTO_malloc(72, 0x4772dc, 2137, 0x7f0ca9b47760) = 0xcf4040 [pid 2086] CRYPTO_malloc(36, 0x4772dc, 2138, 0x7f0ca9b47760) = 0xcfc8a0 [pid 2086] X509_NAME_new(1, 0xcfc5ff, 0, 0xcfc5fe) = 0xcfc870 [pid 2086] OBJ_txt2nid(0xcfc5f0, 0x7f0ca9b47760, 0xcfc0a0, 0x7f0ca9b47760) = 13 [pid 2086] X509_NAME_add_entry_by_NID(0xcfc870, 13, 4097, 0xcfc5f3) = 1 [pid 2086] CRYPTO_free(0xcf4040, 0xffffffff, 0x7f0ca9b47768, 0xcfc130) = 0 [pid 2086] CRYPTO_free(0xcfd000, 0xffffffff, 0x7f0ca9b47780, 0xce6cd0) = 0 [pid 2086] CRYPTO_free(0xcfc5f0, 0xffffffff, 0x7f0ca9b47780, 0xcf4030) = 0 [pid 2086] CRYPTO_free(0xcfc8a0, 0xffffffff, 0x7f0ca9b47768, 0xcfc0e0) = 0 [pid 2086] X509_REQ_set_subject_name(0xcfcb10, 0xcfc870, 0x7f0ca9b47770, 0xcfd1d0) = 1 [pid 2086] X509_NAME_free(0xcfc870, 0xffffffff, 0x7f0ca9b47770, 0xcfcb30) = 0 [pid 2086] X509_REQ_set_pubkey(0xcfcb10, 0xcf3fe0, 0x7f0ca9b47770, 0xcfc830) = 1 [pid 2086] X509_new(1, 0xffffffff, 0x7f0ca9b47768, 0xcfc600) = 0xcfd4b0 [pid 2086] X509_set_version(0xcfd4b0, 2, 0x7f0ca9ce9436, 4) = 1 [pid 2086] X509_get_serialNumber(0xcfd4b0, 2, 0, 0xffffffff) = 0xcfc570 [pid 2086] BN_new(0, 0xcfc570, 0, 0xffffffff) = 0xcfc630 [pid 2086] BN_pseudo_rand(0xcfc630, 64, 0, 0) = 1 [pid 2086] BN_to_ASN1_INTEGER(0xcfc630, 0xcfc570, 1, 0) = 0xcfc570 [pid 2086] BN_free(0xcfc630, 0xcfd758, 1, 0) = 0 [pid 2086] X509_set_issuer_name(0xcfd4b0, 0xcfc430, 0x7f0ca9b47768, 0xcfd560) = 1 [pid 2086] X509_gmtime_adj(0xcfc0a0, 0, 0x7f0ca9b47770, 0xcfc860) = 0xcfc0a0 [pid 2086] X509_time_adj_ex(0xcfc4c0, 30, 0, 0) = 0xcfc4c0 [pid 2086] X509_set_subject_name(0xcfd4b0, 0xcfc430, 0xe000, 96) = 1 [pid 2086] X509_REQ_get_pubkey(0xcfcb10, 0xffffffff, 0x7f0ca9b47770, 0xcfc980) = 0xcfd050 [pid 2086] X509_set_pubkey(0xcfd4b0, 0xcfd050, 0x7f0ca9d2c813, 8) = 1 [pid 2086] EVP_PKEY_free(0xcfd050, 0xffffffff, 0x7f0ca9b47768, 0xcfce30) = 1 [pid 2086] X509V3_set_ctx(0x7fff82157e00, 0xcfd4b0, 0xcfd4b0, 0) = 1 [pid 2086] X509V3_set_nconf(0x7fff82157e00, 0xcd83a0, 0xcfd4b0, 0) = 0x7f0ca9f93f00 [pid 2086] X509V3_EXT_add_nconf(0xcd83a0, 0x7fff82157e00, 0xcdaf00, 0xcfd4b0) = 1 [pid 2086] EVP_MD_CTX_init(0x7fff82157bd0, 0xcfd4b0, 0xcf3fe0, 0) = 0 [pid 2086] EVP_MD_CTX_init(0x7fff82157bd0, 0xcfd4b0, 0, 0) = 0 [pid 2086] EVP_DigestSignInit(0x7fff82157bd0, 0x7fff82157bc0, 0, 0) = 1 [pid 2086] sk_num(0, 0, 0xcfe080, 0) = 0xffffffff [pid 2086] X509_sign_ctx(0xcfd4b0, 0x7fff82157bd0, 0xcfe080, 0) = 0 [pid 2086] EVP_MD_CTX_cleanup(0x7fff82157bd0, 0xffffffff, 0x7f0ca9b47780, 0xcfd1b0) = 1 [pid 2086] ERR_print_errors(0xcbe010, 0xffffffff, 0, 0139692372833952:error:2A065043:lib(42):ECDSA_do_sign:passed a null parameter:ecs_ossl.c:253: 139692372833952:error:0D0DC006:asn1 encoding routines:ASN1_item_sign_ctx:EVP lib:a_sign.c:306: ) = 0 [pid 2086] ERR_print_errors(0xcbe010, 473, 0x7f0ca9d2ae33, 8) = 0 [pid 2086] BIO_free(0xcdf720, 473, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] BIO_free_all(0xcdf7a0, 0xffffffff, 1, 0xcfe070) = 1 [pid 2086] EVP_PKEY_free(0xcf3fe0, 0xffffffff, 1, 0xcdf710) = 0 [pid 2086] X509_REQ_free(0xcfcb10, 0xffffffff, 0x7f0ca9b47778, 0xcfbc90) = 0 [pid 2086] X509_free(0xcfd4b0, 0xffffffff, 0x7f0ca9b47770, 0xcfc420) = 0 [pid 2086] ASN1_INTEGER_free(0, 0, 0, 0x7f0ca9c93be0) = 2 [pid 2086] OBJ_cleanup(0, 0x7f0ca9f80b60, 2, 0x7f0ca9c93be0) = 0 [pid 2086] NCONF_free(0xcd83a0, 0, 0, 0xcdf170) = 1 [pid 2086] lh_free(0xcd88e0, 0xffffffff, 0x7f0ca9b47770, 0xcda3c0) = 0 [pid 2086] CONF_modules_unload(1, 0, 0, 0xcdd650) = 0 [pid 2086] UI_destroy_method(0xcd81c0, 0xffffffff, 0x7f0ca9b47770, 0xcddd80) = 0 [pid 2086] OBJ_cleanup(0, 0xffffffff, 0x7f0ca9b47778, 0xcdddb0) = 0x7f0ca9f98480 [pid 2086] EVP_cleanup(0, 0xffffffff, 0, 0xcdddb0) = 0x7f0ca9f98480 [pid 2086] ENGINE_cleanup(0, 0x7f0ca9c7b650, 0, 0xcd7570) = 1 [pid 2086] CRYPTO_cleanup_all_ex_data(0, 0xffffffff, 0x7f0ca9b47770, 0xcd7f00) = 0 [pid 2086] ERR_remove_thread_state(0, 0, 0, 0xcbe150) = 0 [pid 2086] RAND_cleanup(0x7f0ca9b47760, 0, 0, 8) = 1 [pid 2086] ERR_free_strings(0, 0, 0, 8) = 8 [pid 2086] COMP_zlib_cleanup(0x689160, 380, 0x7f0ca9d2ae33, 8) = 8 [pid 2086] CRYPTO_mem_leaks(0xcbe010, 380, 0x7f0ca9d2ae33, 8) = 1 [pid 2086] BIO_free(0xcbe010, 274, 0x7f0ca9ce91ba, 8) = 1 [pid 2086] exit(1 <no return ...> [pid 2086] +++ exited (status 1) +++