Answered Security-Policy AES-CBC-256-encryption

forgot to mention on my first post: OE11.7.2, Win 8

this problem gets a bit mysterious now (at least for me): although my encrypted string differs from the online-encryption, I still can decrypt it with the online-tool and get the same result. See screenshot attached.

Could anybody please explain ?
 

Attachments

  • _aes-HelloWorld-2.jpg
    _aes-HelloWorld-2.jpg
    96.1 KB · Views: 6

Cecil

19+ years progress programming and still learning.
You had an extra null byte in your mp-StringToEncrypt variable when setting the size of the memptr.

Try this:

Code:
DEFINE VARIABLE cTextToEncrypt      AS CHAR INIT "Hello World".
DEFINE VARIABLE cAES-Key            AS CHAR.
DEFINE VARIABLE vAES-Key            AS RAW.

DEFINE VARIABLE mp-StringToEncrypt  AS MEMPTR.
DEFINE VARIABLE mp-EncryptedString  AS MEMPTR.
            
             /* 12345678901234567890123456789012 */
    cAES-Key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".    /* 32 Bytes */
    PUT-STRING(vAES-Key, 1, LENGTH(cAES-Key)) = cAES-Key.

    SECURITY-POLICY:SYMMETRIC-ENCRYPTION-ALGORITHM = 'AES_CBC_256'.
    SECURITY-POLICY:SYMMETRIC-ENCRYPTION-KEY       = vAES-Key.
    SECURITY-POLICY:SYMMETRIC-ENCRYPTION-IV        = ?.

    SET-SIZE(mp-StringToEncrypt)     = LENGTH(cTextToEncrypt,'RAW').
    PUT-STRING(mp-StringToEncrypt,1, LENGTH(cTextToEncrypt,'RAW')) = cTextToEncrypt.

    mp-EncryptedString = ENCRYPT(mp-StringToEncrypt).
    
    MESSAGE STRING(BASE64-ENCODE(mp-EncryptedString))
        VIEW-AS ALERT-BOX.

    SET-SIZE(mp-StringToEncrypt) = 0.
    SET-SIZE(mp-EncryptedString) = 0.
 
Top