Same encryption using c++ symbian & C# .net
| Tue, 2006-12-05 15:06 | |
|
Hi all.
I'm developing an application for symbian and it sends data to an internet pc server. I need to encrypt this data and i'm looking for an encription method common to use. Trying to use the ported Rijndael code found on internet i discovered a limitation of 32 chars maximum length, while in c# the RijndaelManaged class doesn't have this limitation. I tried to encrypt a small string of chars: encryption (symbian) -> decryption (symbian) works fine, but encryption (symbian) -> decryption (pc) doesn't work. I'm using the same cipherMode (BCB), same secret key and same Init vector. Does someone know a tested way to encrypt data in symbian (using c++) and decrypt it in a pc (using c#). Thank you very much. |
|






Forum posts: 16
Forum posts: 1094
Anyway, what's your application? The application usually decides which kind of encryption (weak, strong, very strong) is needed.
René Brunner
Forum posts: 1142
Seems your example implementation only handles one block, and you have to do the chaining yourself.
If you encrypt just one block with either pc or symbian version and same key and init vector, your result should be decryptable on both sides.
My guess is that the "managed" version not outputs just the block but some extra header information or such.
Forum posts: 3
rbrunner:
Encrypted data is encoded (Base64) just to avoid binary data format. Then i send it with a socket to a server over the internet.
While in debug i can see the encrypted buffer and i can see that is differend from the same source text encrypted from the pc server program using the RijndaelManaged class of .net
So, i don't think the transport could be the reason....maybe....
alh:
I found on internet that 32 bytes is the real limit os AES encryption ... so it seems you are on the right way...
RijdaelManaged class allow me to encrypt a longer string as surely manage the chaining of encrypted blocks...
As i don't know how this class separates encrypted blocks i think i will have to manage the chaining both in pc and symbian.
Now i will try to use the simple Rijndael class on .net ...
Later i will post the codes (pc and symbian) if i find a working solution.
Thank you very much by now!
Forum posts: 1142
If the output from your encryption with the managed class, isn't exactly 32 bytes, or a multiple of it, it means it has some more information in it.
To encrypt more then one block you use some kind of "chaining" wich is to use some information from block 1 to encrypt block 2, some from block 2 to encrypt block 3 etc, this to counter "known plain text" attacks. There are different techniques to do this chaining, where I think CBC is the most common. (havn't fiddled with crypto in a long time so I might be wrong though)
You should read up some on encryption theory, or you are bound to make some small mistakes that breaks the security.