#include<stdio.h> |
#include<openssl/pem.h> |
#include<openssl/rsa.h> |
voidverifyRSASignature(unsignedchar *originalMessage, unsignedint om_length, |
unsignedchar *signature, unsigned siglen) |
{ |
int result; |
FILE *file; |
X509 *x509; |
EVP_PKEY *evp_pubkey; |
RSA *rsa_pubkey; |
file = fopen('developer_signer.pem', 'r'); |
x509 = PEM_read_X509(file, NULL, NULL, NULL); |
evp_pubkey = X509_get_pubkey(x509); |
rsa_pubkey = EVP_PKEY_get1_RSA(evp_pubkey); |
result = RSA_verify(NID_md5, originalMessage, om_length, |
signature, siglen, rsa_pubkey); |
printf('Signature is %sn', result 1 ? 'valid' : 'invalid'); |
RSA_free(rsa_pubkey); |
EVP_PKEY_free(evp_pubkey); |
X509_free(x509); |
fclose(file); |
} |
X509_get_pubkey
OpenSSL verify RSA signature, read RSA public key from X509 PEM certificate - openssl-verify-rsa-signature.c. Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
commented Aug 19, 2019
This function is wrong. |
#include<stdio.h> |
#include<openssl/pem.h> |
#include<openssl/rsa.h> |
voidverifyRSASignature(unsignedchar *originalMessage, unsignedint om_length, |
unsignedchar *signature, unsigned siglen) |
{ |
int result; |
FILE *file; |
X509 *x509; |
EVP_PKEY *evp_pubkey; |
RSA *rsa_pubkey; |
file = fopen('developer_signer.pem', 'r'); |
x509 = PEM_read_X509(file, NULL, NULL, NULL); |
evp_pubkey = X509_get_pubkey(x509); |
rsa_pubkey = EVP_PKEY_get1_RSA(evp_pubkey); |
result = RSA_verify(NID_md5, originalMessage, om_length, |
signature, siglen, rsa_pubkey); |
printf('Signature is %sn', result 1 ? 'valid' : 'invalid'); |
RSA_free(rsa_pubkey); |
EVP_PKEY_free(evp_pubkey); |
X509_free(x509); |
fclose(file); |
} |
X509_get_pubkey
OpenSSL verify RSA signature, read RSA public key from X509 PEM certificate - openssl-verify-rsa-signature.c. Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
commented Aug 19, 2019
This function is wrong. |
commented Aug 20, 2019
… On Tue, Aug 20, 2019 at 1:18 AM paxter ***@***.***> wrote: This function is wrong. originalMessage has to be the message digest. Check out the manpage: https://www.openssl.org/docs/man1.1.1/man3/RSA_verify.html — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or mute the thread . -- Regards.Afa.L ChengDisclaimer:This message contains confidential information and is intended only for theindividual named. If you are not the named addressee you should notdisseminate, distribute or copy this e-mail. Please notify the senderimmediately by e-mail if you have received this e-mail by mistake anddelete this e-mail from your system. E-mail transmission cannot beguaranteed to be secure or error-free as information could be intercepted,corrupted, lost, destroyed, arrive late or incomplete, or contain viruses.The sender therefore does not accept liability for any errors or omissionsin the contents of this message, which arise as a result of e-mailtransmission. If verification is required please request a hard-copyversion. |