<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr"><br></div><br><br>





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-8487964261339457768WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Thanks Viktor for the help….<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Please find below the input format.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Still its not working.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<div>
<div>
<p class="MsoNormal">> On Aug 28, 2018, at 7:08 AM, Linta Maria <<a href="mailto:lintamaria194@gmail.com" target="_blank" rel="noreferrer">lintamaria194@gmail.com</a>> wrote:<br>
> <br>
> I have used below code, but it’s not working. Please help me to get the correct API.<br>
> <br>
> /*<br>
>  * NB: assumes verify_key, sig, siglen md and mdlen are already set up<br>
>  * and that verify_key is an RSA public key<br>
>  */<br>
<br>
In what form is the message digest?  Is it the raw digest octets,<br>
or some hex or base64 encoding?  In what form is the signature?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Message digest  and signature is given in hex format.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Msg ={</span><span style="background:yellow">
</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">0x8f,0x43,0x43,0x46,0x64,0x8f,0x6b,0x96,0xdf,0x89,0xdd,0xa9,0x1c,0x51,0x76,0xb1,0x0a,0x6d,0x83,0x96,0x1d,0xd3,0xc1,0xac,0x88,0xb5,0x9b,0x2d,0xc3,0x27,0xaa,0x4};<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Signature={</span><span style="background:yellow">
</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">0x24,0xb8,0xec,0xb4,0x4f,0x31,0xa6,0x8,0x72,0x61,0xc9,0xd3,0x1c,0xd0,0x9b,0xee,0x26,0x2d,0x3d,0xef,0xff,0x2c,0x5,0x78,0x4,0xd3,0xa3,0xff,0xdc,0x97,0x53,0xe6,0x6e,0x85,0x41,0x1b,0xb2,0x2c,0xed,0xbd,0xa6,0x5d,0x6f,0xac,0xbb,0xd5,0xb8,0xa0,0x9,0x2b,0xf1,0xf5,0xb6,0xce,0xdd,0x70,0x8a,0x1a,0xa1,0x20,0x11,0x2b,0xf0,0x17,0x41,0x83,0x80,0xf6,0x61,0xd4,0x6d,0x53,0x8f,0xf1,0x8c,0x19,0x42,0x93,0x96,0xa9,0xb6,0xf2,0x8f,0x27,0x9c,0x66,0x17,0xc5,0xca,0x3d,0xa9,0x3f,0xc5,0x76,0x5f,0x1b,0x31,0xf2,0xd3,0xe,0x78,0x53,0x97,0xcb,0x9d,0xc4,0xe6,0x41,0x61,0x58,0x44,0x5c,0xf5,0xc4,0x67,0x69,0x8,0xa,0x92,0xd5,0x7e,0x9c,0xb9,0x7e,0x54,0x8b,0x8a,0xb,0xa1,0x9a,0x63,0xbf,0xcc,0xed,0x63,0x2c,0xf8,0x14,0x25,0x6,0xa2,0x2,0x0,0x7,0x2e,0x1c,0xc1,0xeb,0x16,0x89,0xaa,0x69,0xe2,0x75,0x57,0x39,0x71,0x68,0xe,0xf,0xa4,0x7a,0xc5,0x14,0x97,0x88,0x67,0xd1,0x36,0x91,0x3b,0x49,0xe7,0xb4,0xf3,0xcb,0xca,0xf6,0xe9,0xb1,0x22,0xe9,0x85,0x89,0xab,0x2,0x4,0x3c,0x2e,0xbd,0x56,0x3,0x8a,0x8b,0x54,0xc6,0xe6,0xed,0x5b,0x4c,0xa4,0x9e,0x1b,0xaa,0x90,0xc6,0xb,0x27,0x54,0xc0,0x50,0x5f,0x58,0x97,0xc,0x99,0x5c,0x2,0x74,0xfc,0x9f,0x4c,0x78,0x4e,0xc3,0xb4,0x6d,0x14,0xa1,0xdc,0x62,0xc5,0xfe,0x27,0xb8,0x7d,0x98,0x79,0x82,0x50,0x3a,0xbe,0x6f,0x83,0x79,0xd,0x8a,0xb8,0x3e,0xac,0xa,0xeb,0x62,0xd5,0x5e,0x95}<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">PublicKey- In evp_pkey format</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="background:yellow">----BEGIN PUBLIC KEY-----<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzMjyWZfVfBpmNKmIm9HH<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">FnrhDLZaCmQvZz57uJHhBLwLk/UAJ+kLKV9Lox8eKfimzisPFBad/TUfwPUaQmji<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">bPKCp+or2EHvPFooOnPWjSd57zPCohDdo0nOLw7iTUOMCvoqvJcdor+t1zBb8MQK<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">yNTycuoGlT19lr8msJFtR+ulfKucj/zk5w/jr0SsxysqFsvtEfa62Wu/wSDYIfsq<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">lKlRGLTlqJNtQybtTVv2Uu2KFrbe0C8+FBkxgtBS+0MkhzpJ37/02J+mHFx1bsgN<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">09QnQY+T05te+6/mmlsHP3PYRqXqJOLl9AkLd/9kiMhSFshowFehKmls9PYt1xGf<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">5QIDAQAB<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">-----END PUBLIC KEY-----</span><br>
<br>
> ctx = EVP_PKEY_CTX_new(verify_key, NULL /* no engine */);<br>
> if (!ctx)<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><br>
>      /* Error occurred */<br>
> <br>
> if (EVP_PKEY_verify_init(ctx) <= 0)<br>
>      /* Error */<br>
> <br>
> if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)<br>
>      /* Error */<br>
> <br>
> if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)<br>
>      /* Error */<br>
<br>
Since you're verifying a hash, do not configure a message<br>
digest.<br>
<br>
> /* Perform operation */<br>
> <br>
> ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen);<br>
<br>
This is the right function for verifying public key<br>
signatures over some input.  For more help, post<br>
the *public* key used, the signature and the input<br>
digest.<br>
<br>
<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Message digest  and signature is given in hex format.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Msg ={</span><span style="background:yellow">
</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">0x8f,0x43,0x43,0x46,0x64,0x8f,0x6b,0x96,0xdf,0x89,0xdd,0xa9,0x1c,0x51,0x76,0xb1,0x0a,0x6d,0x83,0x96,0x1d,0xd3,0xc1,0xac,0x88,0xb5,0x9b,0x2d,0xc3,0x27,0xaa,0x4};<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">Signature={</span><span style="background:yellow">
</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;background:yellow">0x24,0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,0x14,0xa1,0xdc,0x62,0xc5,0xfe,0x27,0xb8,0x7d,0x98,0x79,0x82,0x50,0x3a,0xbe,0x6f,0x83,0x79,0xd,0x8a,0xb8,0x3e,0xac,0xa,0xeb,0x62,0xd5,0x5e,0x95}<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">PublicKey- In evp_pkey format</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="background:yellow">----BEGIN PUBLIC KEY-----<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzMjyWZfVfBpmNKmIm9HH<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">FnrhDLZaCmQvZz57uJHhBLwLk/UAJ+kLKV9Lox8eKfimzisPFBad/TUfwPUaQmji<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">bPKCp+or2EHvPFooOnPWjSd57zPCohDdo0nOLw7iTUOMCvoqvJcdor+t1zBb8MQK<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">yNTycuoGlT19lr8msJFtR+ulfKucj/zk5w/jr0SsxysqFsvtEfa62Wu/wSDYIfsq<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">lKlRGLTlqJNtQybtTVv2Uu2KFrbe0C8+FBkxgtBS+0MkhzpJ37/02J+mHFx1bsgN<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">09QnQY+T05te+6/mmlsHP3PYRqXqJOLl9AkLd/9kiMhSFshowFehKmls9PYt1xGf<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">5QIDAQAB<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:yellow">-----END PUBLIC KEY-----</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><br>
You can find similar code in the source code of the<br>
rsautl and pkeyutl commands.<br>
<br>
-- <br>
        Viktor.<br>
<br>
-- <br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" target="_blank" rel="noreferrer">
https://mta.openssl.org/mailman/listinfo/openssl-users</a><u></u><u></u></p>
</div>
</div>
</div>
</div>

</div></div></div>