AES Encryption
Trying to use AES encryption for a url. I have a plain text string, a 16-byte key and a initialization vector. I am trying to match a C# implementation that uses RijndaelManaged class with a BlockSize = 128, Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7. The output of the $SYSTEM.Encryption.AESCBCEncrypt(text,key,IV), doesn't match what is coming out of C#. All inputs into the $SYSTEM.Encryption.AESCBCEncrypt(text,key,IV) are converted to UTF8 as in the documentation.
I can encrypt / decrypt in Caché as specified in the documentation, but the string is differet from the C#, so the url fails.
Thanks in advance.
Can you post some examples of input and expected output?
Edit: here's an example from StackOverflow that gets the same output:
USER>s (key,iv)="0123456789ABCDEF" USER>zzdump $system.Encryption.AESCBCEncrypt("1234567890",key,iv) 0000: 60 2C AE 14 35 8D 0A C5 C9 6E 2D 46 D1 7E 58 E3
https://stackoverflow.com/questions/28592989/aes-pkcs7-padding
where do you verify the result and where do you see the error ?
ok, sorry guys was on a brief vacation.
The C# console shows this:
However the Cache
will output:
The Base64Encoded and the Temp Vector 64 from C# match. However if I try to put the Base64Encoded into $SYSTEM.Encryption.AESCBCEncrypt, I get an ILLEGAL VALUE as that function requires UTF8. It still fails if I convert it to UTF8 before the AESCBCEncrypt.
I notice two things:
I thought maybe C# is using UTF-16, but I I haven't managed to replicate its output using $zconvert with "UnicodeLittle" or "UnicodeBig".
Edit: the first sixteen bytes of the output appear to be the first eight bytes of the initialization vector converted to Base-64, then UTF-16.
You are UTF-8 encoding the binary ciphertext, which scrambles it, before Base64 encoding it: