int CRSA::RSA_md5_sign( const string &strInPublicKeyN , const string &strInPublicKeyE , const string &strInPrivateKeyD , const string &strInPlaintext , string &strSigntext ) { string strMd5; unsigned char szMd5[16] = { 0 }; MD5( (const unsigned char *)strInPlaintext.c_str() , ( unsigned long )strInPlaintext.size() , szMd5 ); strMd5.append( (char *)szMd5 , 16 ); return RSAPrivateEncrypt( strInPublicKeyN , strInPublicKeyE , strInPrivateKeyD , strMd5 , strSigntext ); }
static int rsaref_private_encrypt(int len, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { int i,outlen= -1; R_RSA_PRIVATE_KEY RSAkey; if (padding != RSA_PKCS1_PADDING) { RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE); goto err; } if (!RSAref_Private_eay2ref(rsa,&RSAkey)) goto err; if ((i=RSAPrivateEncrypt(to,(unsigned int *)&outlen,(unsigned char *)from,len,&RSAkey)) != 0) { RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT,i); outlen= -1; } err: memset(&RSAkey,0,sizeof(RSAkey)); return(outlen); }
NEINT32 ne_RSAPrivateEncrypt(NEINT8 *outbuf, NEINT32 *outlen, NEINT8 *inbuf, NEINT32 inlen,RSA_HANDLE h_rsa) { return RSAPrivateEncrypt(outbuf, outlen, inbuf, inlen, &h_rsa->privateKey) ; }