RE: sign problem
Your problem is with signlen. You’re accessing a null pointer in EVP_DigestSignFinal(). Declare signlen as size_t, not a size_t*, and pass the *ADDRESS* of signlen. E.g.: EVP_DigestSignFinal(mdctx, NULL, signlen); From: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] On Behalf Of Amir Reda Sent: Monday, November 24, 2014 10:10 AM To: openssl-users@openssl.org Subject: sign problem dear all i have a problem with c++ code for sign some data here is the code BIO *sgerr = NULL; const char szPath[MAX_FILE_NAME_SIZE] = sgerr.pem; sgerr = BIO_new_file(szPath,wb); couti'm in sign digestendl; //create private key EVP_PKEY *priv_key = NULL; priv_key = EVP_PKEY_new(); if (1 == EVP_PKEY_set1_RSA(priv_key,m_caKeyPairs)) { coutSuccessful key private createdendl; } else { coutprivate key is badendl; } EVP_MD_CTX *mdctx = NULL; mdctx = EVP_MD_CTX_create(); size_t *signlen = NULL; //Initialize the DigestSign operation if (1 == EVP_DigestSignInit(mdctx, NULL, EVP_sha1(), NULL, priv_key)) { coutinitialize correctendl; } else { coutsomething wrongendl; } //update with the message if (1 == EVP_DigestSignUpdate(mdctx, m_digestData,(DATA_SIZE + RSA_KEY_SIZE))) { coutdigest created successfullyendl; coutdigest is endl; for (int i = 0; i DIGEST_SIZE; i++) { printf(0x%.2x , m_digest[i]); } coutendl; } else { coutsomething wrongendl; } //Finalise the DigestSign operation determine the sign length if (1 == EVP_DigestSignFinal(mdctx, NULL, signlen)) { coutsign length is (*signlen)endl; } else { coutsomething wrongendl; } if (1 == EVP_DigestSignFinal(mdctx, m_signedDigest, signlen)) { coutsign successfully createdendl; } else { coutsomething wrongendl; } the output of this code in terminal during debugging i'm in sign digest Successful key private created initialize correct digest created successfully digest is 0x99 0x2d 0x5c 0x5b 0x2f 0x7a 0x85 0x98 0x7c 0x69 0xca 0x33 0x17 0xab 0x87 0x7c 0x79 0x73 0xd7 0x4a until i arrive to this point if (1 == EVP_DigestSignFinal(mdctx, NULL, signlen)) i got this error No source available for EVP_PKEY_sign() at 0xb7ede098 even this function just return the length of the sign note i'm using eclipse kepler and i don't know what i did wrong -- Warmest regards and best wishes for a good health,urs sincerely mero
RE: sign problem
That looks like a debugger message, not an actual error from the code. From: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] On Behalf Of Amir Reda Sent: Tuesday, November 18, 2014 10:29 AM To: openssl-users@openssl.org Subject: sign problem dear all i made an application a client server the client send a certificate request and server reply with the certificate and it creates a encrypted shared key and some data and sign the digest of the shared key and data my problem is 1- in SignDigest() in EVP_DigestSignFinal(mdctx, NULL, signlen); function return an error No source available for EVP_PKEY_sign() at 0xb7ede098 i don't know the reason for this error it should return the length of the sign only then i reserve a location in memory with this size please help me -- Warmest regards and best wishes for a good health,urs sincerely mero
Re: sign problem
Hello Everyone, Where we are executing these client.cc,server.cc,client.h,server.h,certificate.cpp files ? As i want to make my own Digital Certificate using my own algorithm i was not understanding where to execute these files. Thankyou. Regards, Niraj. On Wed, Nov 19, 2014 at 12:12 AM, Scott Neugroschl scot...@xypro.com wrote: That looks like a debugger message, not an actual error from the code. *From:* owner-openssl-us...@openssl.org [mailto: owner-openssl-us...@openssl.org] *On Behalf Of *Amir Reda *Sent:* Tuesday, November 18, 2014 10:29 AM *To:* openssl-users@openssl.org *Subject:* sign problem dear all i made an application a client server the client send a certificate request and server reply with the certificate and it creates a encrypted shared key and some data and sign the digest of the shared key and data my problem is 1- in SignDigest() in EVP_DigestSignFinal(mdctx, NULL, signlen); function return an error No source available for EVP_PKEY_sign() at 0xb7ede098 i don't know the reason for this error it should return the length of the sign only then i reserve a location in memory with this size please help me -- Warmest regards and best wishes for a good health,*urs sincerely * *mero*
Re: sign problem
sorry sir what do you mean by your question On Wed, Nov 19, 2014 at 9:02 AM, Niraj Sorathiya nirajsorathiya...@gmail.com wrote: Hello Everyone, Where we are executing these client.cc,server.cc,client.h,server.h,certificate.cpp files ? As i want to make my own Digital Certificate using my own algorithm i was not understanding where to execute these files. Thankyou. Regards, Niraj. On Wed, Nov 19, 2014 at 12:12 AM, Scott Neugroschl scot...@xypro.com wrote: That looks like a debugger message, not an actual error from the code. *From:* owner-openssl-us...@openssl.org [mailto: owner-openssl-us...@openssl.org] *On Behalf Of *Amir Reda *Sent:* Tuesday, November 18, 2014 10:29 AM *To:* openssl-users@openssl.org *Subject:* sign problem dear all i made an application a client server the client send a certificate request and server reply with the certificate and it creates a encrypted shared key and some data and sign the digest of the shared key and data my problem is 1- in SignDigest() in EVP_DigestSignFinal(mdctx, NULL, signlen); function return an error No source available for EVP_PKEY_sign() at 0xb7ede098 i don't know the reason for this error it should return the length of the sign only then i reserve a location in memory with this size please help me -- Warmest regards and best wishes for a good health,*urs sincerely * *mero* -- Warmest regards and best wishes for a good health,*urs sincerely * *mero*