Hi, this post might be better suited for General C++ questions... but I'll try to post it here first..
I've used the crytography api which was published aug 2007, and run into some problems..
Say for instance.. I use a weak protection like RC2. I cannot use the CRC2 class due to the reason you cannot supply an IV (initial vector to it), so i've used CPBEncryptorElement and CPBEncryptor with the ECipherRC2_CBC_128_16 encryption..
It works fine encrypting and decrypting with this on a symbian device.. But i face problems if i try to decrypt it on a windows mobile in c++ or in c# on server.. The problem is the padding i guess... Say I want to encrypt a single TChar.. using only i.e. 0x31 or '1' .. This will produce a ciphertext of 8 bytes (block size 64bits = 8byte) .. When i try to decode this in C# on a server.. I get the 0x31 and in addition a 0x06 ... so the encryption on symbian adds another byte.... I've figured out that if i encode '12' .. then the additional byte will be 0x05 ..so this additional seems to describe how many bytes is has padded to encrypt the block. So on server side.. i can just neglect that last byte, since it will always occure when receiveing encrypted ciphertexts from a symbian device.
However.. if the string i want to encrypt i 7 TChars long .. this will produce an exception on my server and not decrypt the message at all.. So as a workaround .. i check the input length and assure that it is (Length() %8) > 1 or else i pad it with a known hex value myself, which I can remove on server side..
But this workaround is kind of dirty, since it will lead to an additional block of padding of 8 bytes..
This does not occur when i encode in C# or when i encode in unmanaged c++ on windows mobile using the wincrypt.lib
So,finally, here is my question.. Is this a bug in the cryptography library on Symbian? Or is this an implemention that does not conflict with the specifications of RC2 standard?
Has anyone else used the cryptography library and encrypted / decrypted messages cross platform(C#, WM and Symbian)
Thanks in advance