This is completely the result of trial... First of all, the base64 text needs to be converted
sign = base64.decodestring(sign)
Then the first input parameter of RSA_decrypt is wrong, it should be:
ret = RSA_private_decrypt(rsa_size, sign, rsa, key, 1)
See official website definition:
int RSA_private_decrypt(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
Here flen is the key length, which I thought was from_len before. ret>0 means decryption is successful, the result is taken from rsa.value, and the fifth parameter is the padding mode, which should be RSA_PKCS1_PADDING, but this constant seems not to be found in libcrypto.so.6, I go from 0 to 5 I tried it out one by one. I guess 1 is RSA_PKCS1_PADDING and 2 is SSLV23_PADDING (not necessarily spelled this way). Because I have tried other libraries before, these two padding modes can be solved.
This is completely the result of trial...
First of all, the base64 text needs to be converted
Then the first input parameter of RSA_decrypt is wrong, it should be:
See official website definition:
Here flen is the key length, which I thought was from_len before.
ret>0 means decryption is successful, the result is taken from rsa.value, and the fifth parameter is the padding mode, which should be RSA_PKCS1_PADDING, but this constant seems not to be found in libcrypto.so.6, I go from 0 to 5 I tried it out one by one. I guess 1 is RSA_PKCS1_PADDING and 2 is SSLV23_PADDING (not necessarily spelled this way). Because I have tried other libraries before, these two padding modes can be solved.