Question:
I'm trying to encrypt/decrypt using RSA-4096 over GRPC (a communication protocol) to a Java SE7 server using javax/crypto/Cipher algorithm's, specifically: RSA/ECB/PKCS1Padding
However over the span of a few hours of trial & erroring, the server is reporting a 'padding error'.
I'm starting to believe it's either the way I'm setting up CkRsa or perhaps the way I'm converting the const unsigned chars to const chars.
I'm setting out my C++ like this:
CkRsa rsa;
rsa.put_littleEndian(false); // Prior to using Chilkat we were using OpenSSL
rsa.put_OAEPPadding(false); // Uses PKCS#1.5 padding (Confused since Java's cipher says only PKCS1)
// ... setup CkPrivateKey/CkPublicKey with keys via CkStringBuilder
// Encryption
CkByteData outData;
string dump = GetJSONInfo(); // Just returns a JSON string
rsa.EncryptString(dump.c_str(), false, outData); // Encrypt using public key
// GRPC requires the message to be in const string& or const char*
string msg = string(reinterpret_cast<const char*>(const_cast<unsigned char*>(outData.getBytes())), outData.getSize());
// ... Send GRPC request