<div dir="ltr">EVP_get_digestbyobj fails for ecdsa-with-SHA256<br><br>I'm trying to perform a standard signature verification using the EVP_* functions.<br>I think my code is correct, because it all runs fine if the digest is RSA-SHA256.<br>I have an ASN1_OBJECT that specifics the signature/disgest type.<br>Here is my code that dumps out all the intermediate steps called by EVP_get_digestbyobj:<br><br>ASN1_OBJECT * ;<br><br>OBJ_obj2txt(name, 256, sig_alg_oid, 1);<br>printf ("NAME %s", name);<br>printf ("NID = %d", OBJ_obj2nid(sig_alg_oid));<br>printf ("sn = %s", OBJ_nid2sn(OBJ_obj2nid(sig_alg_oid)));<br>printf ("OBJ_NAME_get = %p", OBJ_NAME_get(OBJ_nid2sn(OBJ_obj2nid(sig_alg_oid)),OBJ_NAME_TYPE_MD_METH));<br>const EVP_MD* md = EVP_get_digestbyobj(sig_alg_oid);<br>if(md == NULL)<br>        printf ("EVP_get_digestbyobj failed");<br><br>When I call this with the RSA-SHA256 I get:<br>NAME 1.2.840.113549.1.1.11<br>NID = 668<br>sn = RSA-SHA256<br>OBJ_NAME_get = 0x7fe8846f1ee0<br><br>and the rest of the steps succeeed.<br>Then when I call the same code (in the same program, so I'm sure the openssl library is correctly initialized) with<br>ecdsa-with-SHA256, I get:<br>NAME 1.2.840.10045.4.3.2<br>NID = 794<br>sn = ecdsa-with-SHA256<br>OBJ_NAME_get = (nil)<br>EVP_get_digestbyobj failed<br><br>So it looks like my sig_alg_oid is good, but OBJ_NAME_get fails.<br><br>I am using openssl 1.0.2d-0ubuntu1.5 in ubuntu 15.10<br><br>Am I doing something wrong, or could this be a bug in the library?<br>Any suggestions appreciated.<br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Chris Bare</div>
</div>