Problems with token and rsa and possible bug with cryptAddPrivateKey
JexMcByte <[email protected]> Thu, 26 Jul 2012 12:29:36 -0700 (PDT)
| Newsgroups | gmane.comp.encryption.cryptlib |
|---|---|
| Message-ID | <[email protected]> |
I've tryed in different ways to get a public/private keypair inside a token but, so far, without any luck 1) crreating the keykair: res = cryptDeviceOpen( &cryptDevice, CRYPT_UNUSED, CRYPT_DEVICE_PKCS11, "[Autodetect]" ); res = cryptDeviceCreateContext( cryptDevice, &cryptDeviceContext, CRYPT_ALGO_RSA ); res = cryptSetAttribute( cryptDeviceContext, CRYPT_CTXINFO_KEYSIZE, 2048 / 8 ); res = cryptSetAttributeString( cryptDeviceContext, CRYPT_CTXINFO_LABEL, "Key Server", 10 ); res = cryptSetAttribute( cryptDeviceContext, CRYPT_CTXINFO_KEYSIZE, 2048 / 8 ); res = cryptGenerateKey( cryptDeviceContext); final return is CRYPT_ERROR_NOTINITED 2) creating the keypair on a normal context and importing on the device res = cryptCreateContext( &cryptContext, CRYPT_UNUSED, CRYPT_ALGO_RSA ); res = cryptSetAttributeString( cryptContext, CRYPT_CTXINFO_LABEL, "label", 5 ); res = cryptSetAttribute( cryptContext, CRYPT_CTXINFO_KEYSIZE, 2048 / 8 ); res = cryptGenerateKey( cryptContext ); res = cryptKeysetOpen( &cryptKeyset, CRYPT_UNUSED, CRYPT_KEYSET_FILE, "KeySet", CRYPT_KEYOPT_CREATE ); res = cryptAddPrivateKey( cryptKeyset, cryptContext, "somepassword" ); res = cryptGetPublicKey( cryptKeyset, &pubKey, CRYPT_KEYID_NAME, "label" ); res = cryptGetPrivateKey( cryptKeyset, &privKey, CRYPT_KEYID_NAME, "label", "somepassword" ); res = cryptCreateContext(&sessionContext, CRYPT_UNUSED, CRYPT_ALGO_AES ); res = cryptSetAttribute( sessionContext, CRYPT_CTXINFO_KEYSIZE, 256 / 8 ); res = cryptGenerateKey( sessionContext ); res = cryptExportKey( NULL, 0, &pubMaxLen, pubKey, sessionContext ); pubBuffer = (byte*)malloc( pubMaxLen ); res = cryptExportKey( pubBuffer, pubMaxLen, &pubLen, pubKey, sessionContext ); res = cryptExportKey( NULL, 0, &privMaxLen, privKey, sessionContext ); privBuffer = (byte*)malloc( privMaxLen ); res = cryptExportKey( privBuffer, privMaxLen, &privLen, privKey, sessionContext ); res = cryptImportKey( privBuffer, privLen, cryptDeviceContext, sessionContext ); res = cryptImportKey( pubBuffer, pubLen, cryptDeviceContext, sessionContext ); return is CRYPT_ERROR_NOTINITED instead of importing on the device adding it res = cryptGetPublicKey( cryptKeyset, &certificate, CRYPT_KEYID_NAME, "label" ); res = cryptGetPrivateKey( cryptKeyset, &privKey, CRYPT_KEYID_NAME, "label", "somepassword" ); res = cryptAddPublicKey( cryptDevice, certificate ); // -2 res = cryptAddPrivateKey( cryptDevice, privKey, NULL ); // -3 the AddPrivateKey is bugged if I provide the password it fails deep while checking that devices do not use password for private key if I do not provide the password if fails while checking the parameters as password is needed Any help would be greatly appreciated. Variables declarations Init, etc were omited.. -- View this message in context: http://old.nabble.com/Problems-with-token-and-rsa-and-possible-bug-with-cryptAddPrivateKey-tp34216174p34216174.html Sent from the Cryptlib mailing list archive at Nabble.com. _______________________________________________ Cryptlib mailing list [email protected] via Mail: [email protected] Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/ http://news.gmane.org/gmane.comp.encryption.cryptlib Posts from non-subscribed addresses are blocked to prevent spam, please subscribe in order to post messages.