How do I decrypt a private key file and sign some text using openssl calls in C?

If not, it will attempt to re-use the EVP_PKEY structure that pkey points to - and if pkey is uninitialised, it will be looking at a random spot in memory.

If not, it will attempt to re-use the EVP_PKEY structure that pkey points to - and if pkey is uninitialised, it will be looking at a random spot in memory. You can use ERR_print_errors_fp(stderr); to dump the OpenSSL error stack to stderr when an error occurs - this is often helpful in finding the problem.

I added pkey = NULL; prior to PEM_read_PrivateKey(). It still errors and ERR_print_errors_fp(stderr); shows: – Steve Dec 1 '10 at 1:25 2732:error:0906B072:lib(9):func(107):reason(114):. \crypto\pem\pem_lib.

C:481: – Steve Dec 1 '10 at 1:25 I've just looked at pem. Lib and the error is taking place in PEM_get_EVP_CIPHER_INFO which is barfing because it doesn't know what the EVP_CIPHER is. How do I associate the EVP_aes_256_cbc() cipher before the PEM_read_PrivateKey() call?

– Steve Dec 1 '10 at 1:31 @Steve: That appears to be an "unsupported algorithm" error. You should be using PEM_write_PKCS8PrivateKey() to write the key - PEM_write_PrivateKey() is deprecated, and this might be the problem (trying to use the old format with AES 256? ) – caf Dec 1 '10 at 1:37 @caf: I changed the call to PEM_write_PKCS8PrivateKey(same args) and it now errors on that call with: 732:error:06074079:lib(6):func(116):reason(121):.

\crypto\evp\evp_pbe. C:89:TYPE=P? BES2 732:error:23077073:lib(35):func(119):reason(115):.

\crypto\pkcs12\p12_decr. C:83: 732:error:2306C067:lib(35):func(108):reason(103):. \crypto\pkcs12\p12_decr.

C:168: 732:error:2307D067:lib(35):func(125):reason(103):. \crypto\pkcs12\p12_p8e. C:88: – Steve Dec 1 '10 at 1:57.

Thanks @caf for your help. By trial and error I fixed PEM_read_PrivateKey() error by adding the following to the start: if (EVP_get_cipherbyname("aes-256-cbc") == NULL) OpenSSL_add_all_algorithms(); However, I'm still looking for the best (practice) way of generating the keys and then using the private key for signing. From my limited understanding, I am looking for openssl methods that adhere to RSA's "PKCS #1 v2.0: RSA Cryptography Standard.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions