int CRSA::RSA_md5_verify( const string &strInPublicKeyN , const string &strInPublicKeyE , const string &strInPlaintext , const string &strSigntext ) { string strMd5; string strPlainMd5; unsigned char szMd5[16] = { 0 }; MD5( (const unsigned char *)strInPlaintext.c_str() , ( unsigned long )strInPlaintext.size() , szMd5 ); strMd5.append( (char *)szMd5 , 16 ); int iResult = RSAPublicDecrypt( strInPublicKeyN , strInPublicKeyE , strSigntext , strPlainMd5 ); if( iResult ) return -1; else if( strMd5 == strPlainMd5 ) return 0; else return 1; }
static int rsaref_public_decrypt(int len, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { int i,outlen= -1; R_RSA_PUBLIC_KEY RSAkey; if (!RSAref_Public_eay2ref(rsa,&RSAkey)) goto err; if ((i=RSAPublicDecrypt(to,(unsigned int *)&outlen,(unsigned char *)from,len,&RSAkey)) != 0) { RSAREFerr(RSAREF_F_RSAREF_PUBLIC_DECRYPT,i); outlen= -1; } err: memset(&RSAkey,0,sizeof(RSAkey)); return(outlen); }
NEINT32 ne_RSAPublicDecrypt(NEINT8 *outbuf, NEINT32 *outlen, NEINT8 *inbuf, NEINT32 inlen,RSA_HANDLE h_rsa) { return RSAPublicDecrypt(outbuf, outlen, inbuf, inlen, &h_rsa->publicKey) ; }