[openssl-users] EVP_get_digestbyobj fails for ecdsa-with-SHA256

Chris Bare chris.bare at gmail.com
Thu Jul 7 18:08:08 UTC 2016


EVP_get_digestbyobj fails for ecdsa-with-SHA256

I'm trying to perform a standard signature verification using the EVP_*
functions.
I think my code is correct, because it all runs fine if the digest is
RSA-SHA256.
I have an ASN1_OBJECT that specifics the signature/disgest type.
Here is my code that dumps out all the intermediate steps called by
EVP_get_digestbyobj:

ASN1_OBJECT * ;

OBJ_obj2txt(name, 256, sig_alg_oid, 1);
printf ("NAME %s", name);
printf ("NID = %d", OBJ_obj2nid(sig_alg_oid));
printf ("sn = %s", OBJ_nid2sn(OBJ_obj2nid(sig_alg_oid)));
printf ("OBJ_NAME_get = %p",
OBJ_NAME_get(OBJ_nid2sn(OBJ_obj2nid(sig_alg_oid)),OBJ_NAME_TYPE_MD_METH));
const EVP_MD* md = EVP_get_digestbyobj(sig_alg_oid);
if(md == NULL)
        printf ("EVP_get_digestbyobj failed");

When I call this with the RSA-SHA256 I get:
NAME 1.2.840.113549.1.1.11
NID = 668
sn = RSA-SHA256
OBJ_NAME_get = 0x7fe8846f1ee0

and the rest of the steps succeeed.
Then when I call the same code (in the same program, so I'm sure the
openssl library is correctly initialized) with
ecdsa-with-SHA256, I get:
NAME 1.2.840.10045.4.3.2
NID = 794
sn = ecdsa-with-SHA256
OBJ_NAME_get = (nil)
EVP_get_digestbyobj failed

So it looks like my sig_alg_oid is good, but OBJ_NAME_get fails.

I am using openssl 1.0.2d-0ubuntu1.5 in ubuntu 15.10

Am I doing something wrong, or could this be a bug in the library?
Any suggestions appreciated.

-- 
Chris Bare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20160707/58a4a96b/attachment.html>


More information about the openssl-users mailing list