Encryption in Clarion and Interoperability between platforms

Hi,
I am writing a socket application using Nettalk. For security, I was thinking of Cryptonite suite (Capesoft) to use AES256 with IV and a preshared key. The intented clients are Android tablets and iPads connected on same network.

My issue is, whatever encryption options I choose, I’ll pass those info to my Android and iOS developers for them to implement in their respective platforms. The Interoperability between platforms is not working for me. The result produced by clarion app is different to that of the various online encryption tools.

Encryption option used in Cryptonite

  • Microsoft Enhanced RSA and AES Cryptographic Provided (FULL RSA AES)
  • Provider type = AES
  • Algorithm = AES256
  • SHA1 (for hashing the password)

Is there anyone out there who could point me into the right direction? I am open to alternative ideas too. Very urgent

Thanks You

Mathew

Not an easy thing to get right, that is for sure!

I have used Cryptonite on a project that shared encryption between C# code and Clarion with success. It took a little work.

One trap I found for the interop in this scenario was byte order.

Encrypt RSA using OAEP:

encData = base64EncodedData
dataLen = Len(Clip(encData))
IF Crypto.EncryptA(Crypto.hExchangeKey, encData, dataLen, , cs:CRYPT_OAEP) <> Crypto:OK
  ! Deal with encryption failure
END
Str.SetValue(Sub(encData,1,dataLen))
Str.ReverseByteOrder()
Str.Base64Encode()
encData64 = Str.GetValue()

From memory that snippet was originally from the Cryptonite demo with adjustments to make it actually work in my particular scenario. The main point was the Str.ReverseByteOrder() which was needed to make it friendly to… well, the rest of the world. (Decrypting incoming encoded data obviously also needs the similar reverse magic) So if you have StringTheory then give that a go and if not then perhaps look at rolling your own ReverseByteOrder :slight_smile:

There was other hassles related to certificate stores but it depends on the specifics of your implementation if that is even relevant so I won’t get into that just yet. See if the above helps!

1 Like

Thanks Brahn,
I have StringTheory and I will give this a shot. It all looks scary…:scream:. I’ll get back with my findings.

Thanks

Hi All,
I found the solution to my problem and I would like to share the same with you all.

You will need the following templates:
Cryptonite 1.83 (Previous versions had issues)
StringTheory

Encryption used:
AES256 with IV (with interoperability with iOS and Android)

Sample Data to try:
Text to encrypt: Hello this is Cryptonite…
Key: bbC2H19lkVbQDfakxcrtNMQdd0FloLyw
IV: gqLOHUioQ0QjhuvI

Expected Base64 Result: hRCmPDanRwRudc/9truwXZtImNdqptk6dPHGOGwJ3hM=

The following options must be selected in Cryptionite demo app (Symmetric Encryption):

I am also attaching code sample in C#, iOS (Swift), Android as a PDF. Encryption Sample code.pdf (740.3 KB)

Thanks

Mathew

1 Like