Archived Forum Post

Index of archived forum posts


Issues with rsa_decrypt. I'm using chilkat c/c++ for android and sometimes meet this issues as below. Please tell me the cause and how to fix it !!!

May 30 '16 at 07:31

This is my code:

const char *decryptStr =
rsa.decryptStringENC(inputString.c_str(), true); if (decryptStr != NULL) {
_lastErrorCode = ErrorCode::SUCCESS ; _lastErrorText = ""; return decryptStr; } _lastErrorCode =
_lastErrorText = string(rsa.lastErrorText()); return

And this is Log when error happening.

ChilkatLog: DecryptStringENC:
DllDate: Mar 11 2016 ChilkatVersion: UnlockPrefix: XXXXXX Architecture: Little Endian; 32-bit Language: Android C/C++
VerboseLogging: 0 usePrivateKey: 1
rsaDecryptBytes: rsa_decrypt:
Pkcs1_5_decode: Invalid PKCS v1.5 PS length ps_len: 126
--Pkcs1_5_decode Packet:
7DB736ED6599DB674C40C8FAF1146E7FC1A52E49773094102E955D3C8D44 B521EF16523DC24333D77C8EC6D4F3316EEB78506623F9DA7746B152062B8211FFB859739EB98CBD0FB15B6AB27 BCF16FC5325F01EA03902EB597158F1FBE83B178EDBCA9B269196C25D7DE590EC4F513D45695FEB3DE464BA7201D1AC1785DF78BF --rsa_decrypt
--rsaDecryptBytes decrypt: Elapsed time: 34 millisec Failed.


Try setting the rsa.OaepPadding property = true. Maybe OAEP paddding (not PKCSv1.5) was used in the RSA encryption.

Otherwise, using the wrong private key will result in decryption that results in garbage (not the expected format for PCKSv1.5 or OAEP padding from which the original data is unpacked).


I checked privatekey is correct but still meet error. Data get from server in case meet error have short length is meet error above.


I have setted


But sometimes the above error still appears. I logged the private key everytime decrypt and they are same. So do you have another solution? Thank you.