How do I set SECURITY-POLICY:SYMMETRIC-ENCRYPTION-IV

Posted by tfburns on 29-Sep-2009 19:11

In the OE Docs,

SECURITY-POLICY:SYMMETRIC-ENCRYPTION-IV  = ?

To set this, you need to pass a raw value to this.

SECURITY-POLICY:SYMMETRIC-ENCRYPTION-IV  = myRaw.

I'm told the IV is a 16 character value ie. "1234567890123456".

How does this get converted to RAW data type?

Thanks in advance.

All Replies

Posted by Admin on 30-Sep-2009 01:41

There's a kb entry for converting char to raw,

ID: P20135
Title: "What's the proper way to convert a CHARACTER datatype to a RAW data type ?"

Posted by Michael Jacobs on 30-Sep-2009 14:27

Technically, an encryption IV's value is a set of raw (8-bit) data bytes, which must be exactly the same when you use the ENCRYPT and DECRYPT functions. The number of bytes used as an IV by the ABL is related to the algorithm type you are using.  If you are using DES or DES3 the IV size is 8 bytes.  If you are using AES the IV size is 16 bytes.

Example of generating a new IV that can be included as static IV data for ENCRYPT/DECRYPT functions:

/* GenIV.p */
/* Generate the initial 16 byte IV value encode it for use in some source code module. */
MESSAGE "DEF VAR cIV    AS CHAR INITIAL " +

                  STRING(BASE64-ENCODE(GENERATE-UUID)) + ":U NO-UNDO.".

/* Encrypt.p */
/* Use the IV value generated by the GenIV.p module */
DEF VAR cIV     AS CHAR INITIAL "pAEAZCpRWZzeEeWtvkhTwe==":u NO-UNDO.
DEF VAR rIV     AS RAW NO-UNDO.

rIV = BASE64-DECODE(cIV).
IF ( "DES" = SUBSTRING(SECURITY-POLICY:SYMMETRIC-ENCRYPTION-ALGORITHM,1,3) )
THEN DO:
    /* Only 8 bytes are necessary */
    rIV = GET-BYTES(rIV, 8, 8).
END.
SECURITY-POLICY:SYMMETRIC-ENCRYPTION-IV = rIV.
/* ENCRYPT/DECRYPT(...). code here*/

Posted by tfburns on 30-Sep-2009 16:14

Thanks,  I'll give each a try.

This thread is closed