I got an error while trying to encrypt data using ISymmetricCipher Interface (DES/AES cipher) enabling CBC padding scheme.
- Code: Select all
ByteBuffer* input; // the input data, data length != cipher length, needs padding
ByteBuffer *pOutput = null;
DesCipher *pCipher;
pCipher = new DesCipher();
pCipher->Construct("CBC/RFC2630"); // RFC2630 is the only available padding scheme from the Crypto API
// set IV, Key, etc...
pOutput = pCipher->EncryptN(*input); // returns null
if (pOutput == null)
{
// error !
}
Exception raised: E_UNSUPPORTED_OPERATION (which souldn't be raised by Osp::Security::Crypto::ISymmetricCipher::EncryptN according to the API documentation).
Internal error message in console:
"0045.902,EXCEPTION,03,90,Osp::Security::Crypto::__SymmetricCipherPi::__DoCipherN (361) > [FSecurity Exception]:(res == noError): Check this!!!!!"
Notice the "Check this!!!!!"
I guess it's because the SDK is still a beta release...
Using "CBC/NOPADDING" with data length multiple of cipher block length works well though.
I guess I will need to implement my own C++ padding function, do somebody know one in the public domain (PKCS5 implementation would be great) ?

