RXS_Crypt()

This subprocedure performs cryptographic operations like hashing and encryption. Currently supported operations are:

  • MD5
  • SHA1
  • SHA256
  • SHA384
  • SHA512

Subprocedure Prototype

D RXS_Crypt...
D                 PR                  Extproc('RXS_Crypt') Opdesc
D                                     Like(RXS_Var16Mv_t)
D                                     Rtnparm

Returns the output of the specified hashing/crytographic operation.

D   Input                             Like(RXS_Var16Mv_t) Const
D                                     Options(*Varsize)

Field to hold the input of the selected hashing/crytographic operation. You can pass a field smaller than 16M without any additional effort.

D   DS                                Like(RXS_Var64K_t)
D                                     Options(*Varsize)

Holds settings which control how RXS_Crypt operates. This parm can accomodate a number of possible data structures, outlined below.

D RXS_Crypt...
D                 PR                  Extproc('RXS_Crypt') Opdesc
 
D   Output                            Like(RXS_Var16Mv_t)
D                                     Options(*Varsize)

Field to hold the output of the selected hashing/crytographic operation. Note that if you pass a field smaller than 16M, you will need to specify the length of the Output in the subfield OutputLength.

D   Input                             Like(RXS_Var16Mv_t) Const
D                                     Options(*Varsize)

Field to hold the input of the selected hashing/crytographic operation. You can pass a field smaller than 16M without any additional effort.

D   DS                                Like(RXS_Var64K_t)
D                                     Options(*Varsize)

Holds settings which control how RXS_Crypt operates. This parm can accomodate a number of possible data structures, outlined below.

Example Code

*--------------------------------------------------------------
* This example code calculates an MD5 hash from a character field.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)

 /copy QRPGLECPY,RXSCB

D HashMD5DS       DS                  LikeDS(RXS_MD5CryptDS_t)
D                                     Inz(*LikeDS)
D Data            S                   Like(RXS_Var1Kv_t)
D Hash            S                   Like(RXS_Var1Kv_t)
 /free
   Data = 'Hello World';

   reset HashMD5DS;
   Hash = RXS_Crypt( Data : HashMD5DS );

   RXS_JobLog( 'Hash: %s' : Hash ); // Output: Hash: B10A8DB164E0754105B7A99BE72E3FE5

   *INLR = *ON;
 /end-free
*--------------------------------------------------------------
* This example code calculates an MD5 hash from a character field.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)

 /define RXSV6R1
 /copy QRPGLECPY,RXSCB

D HashMD5DS       DS                  LikeDS(RXS_MD5CryptDS_t)
D                                     Inz(*LikeDS)
D Data            S                   Like(RXS_Var1Kv_t)
D Hash            S                   Like(RXS_Var1Kv_t)
 /free
   Data = 'Hello World';

   reset HashMD5DS;
   RXS_Crypt( Hash : Data : HashMD5DS );

   RXS_JobLog( 'Hash: %s' : Hash ); // Output: Hash: B10A8DB164E0754105B7A99BE72E3FE5

   *INLR = *ON;
 /end-free

Data Structures

D RXS_MD5CryptDS_t...
D                 DS                  Qualified Template Inz
 
D   ReturnedErrorInfo...
D                                     LikeDS(RXS_ReturnedErrorInfoDS_t) Inz
 
D   OnErrorMessageType...
D                               10I 0
 
D   InputStmf                         Like(RXS_Var1Kv_t)

Optional IFS stream file to use as input data for hash operation.

D   InputCcsid                  10I 0 Inz(RXS_CCSID_JOB)

CCSID of input data. Used when the input data is of a different CCSID of the job CCSID. Not necessary if using InputStmf.

D   EncryptAsCcsid...
D                               10I 0 Inz(RXS_CCSID_ISO88591)

CCSID to convert the input data into before hashing. Note that this is typically going to be RXS_ISO88591 or RXS_UTF8.

D   InputPointer...
D                                 *

Internal use only

D   InputLength                 10I 0

Internal use only

D   OutputPointer...
D                                 *

Internal use only

D   OutputLength                10I 0

Internal use only

D   Reserved                  2048A

Internal use only

D RXS_SHACryptDS_t...
D                 DS                  Qualified Template Inz
 
D   ReturnedErrorInfo...
D                                     LikeDS(RXS_ReturnedErrorInfoDS_t) Inz
 
D   OnErrorMessageType...
D                               10I 0
 
D   Algorithm                    4P 3

Determines which SHA algorithm/block size to use when hashing.

Valid Values:

  • RXS_CRYPT_SHA1_ALGORITHM
  • RXS_CRYPT_SHA256_ALGORITHM
  • RXS_CRYPT_SHA384_ALGORITHM
  • RXS_CRYPT_SHA512_ALGORITHM

D   InputStmf                         Like(RXS_Var1Kv_t)

Optional IFS stream file to use as input data for hash operation.

D   InputCcsid                  10I 0 Inz(RXS_CCSID_JOB)

CCSID of input data. Used when the input data is of a different CCSID of the job CCSID. Not necessary if using InputStmf.

D   EncryptAsCcsid...
D                               10I 0 Inz(RXS_CCSID_ISO88591)

CCSID to convert the input data into before hashing. Note that this is typically going to be RXS_ISO88591 or RXS_UTF8.

D   InputPointer...
D                                 *

Internal use only

D   InputLength                 10I 0

Internal use only

D   OutputPointer...
D                                 *

Internal use only

D   OutputLength                10I 0

Internal use only

D   Reserved                  2049A

Internal use only