RXS_Crypt()
This subprocedure performs cryptographic operations like hashing and encryption. Currently supported operations are:
- MD5
- SHA1
- SHA256
- SHA384
- SHA512
- AES128
- AES192
- AES256
For AES encryption, block modes ECB, CBC, and CTR are supported.
Subprocedure Prototype
|
Returns the output of the specified hashing/crytographic operation. |
|
Field to hold the input of the selected hashing/crytographic operation. You can pass a field smaller than 16M without any additional effort. |
|
Holds settings which control how RXS_Crypt operates. This parm can accomodate a number of possible data structures, listed 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';
RXS_ResetDS( HashMD5DS : RXS_DS_TYPE_MD5CRYPT );
Hash = RXS_Crypt( Data : HashMD5DS );
RXS_JobLog( 'Hash: %s' : Hash ); // Output: Hash: B10A8DB164E0754105B7A99BE72E3FE5
*INLR = *ON;
/end-free
*--------------------------------------------------------------
* This example code performs AES128 encryption on a string.
*--------------------------------------------------------------
H DFTACTGRP(*NO) BNDDIR('RXSBND') ACTGRP(*CALLER)
/copy QRPGLECPY,RXSCB
D AESDS DS LikeDS(RXS_AESCryptDS_t)
D Input S Like(RXS_Var1Kv_t)
D Output S Like(RXS_Var1Kv_t)
/free
Input = 'abc';
RXS_ResetDS( AESDS : RXS_DS_TYPE_AESCRYPT );
AESDS.PadInput = RXS_YES;
AESDS.Algorithm = RXS_CRYPT_AES128_ALGORITHM;
AESDS.BlockMode = RXS_CRYPT_AESBLOCKMODE_CBC;
AESDS.EncryptDecrypt = RXS_ENCRYPT;
AESDS.EncryptAsCcsid = RXS_CCSID_EBCDIC;
AESDS.Key128 = x'00000000000000000000000000000000';
AESDS.KeyFormat = RXS_CRYPT_AESKEYFORMAT_BIN;
AESDS.OutputPadOption = RXS_CRYPT_PADOUTPUT_NONE;
AESDS.InitializationVector = x'00000000000000000000000000000000';
Output = RXS_Crypt( Input : AESDS );
RXS_JobLog( 'Encrypted output: %s' : Output ); // Encrypted output: 81743865f4a9ce13349d67f5642fd971
*INLR = *ON;
/end-free
Data Structures
|
|
|
|
|
|
|
|
|
Optional IFS stream file to use as input data for hash operation. |
|
CCSID of input data. Used when the input data is of a different CCSID of the job CCSID. Not necessary if using InputStmf. Default Value: |
|
CCSID to convert the input data into before hashing. Note that this is typically going to be RXS_ISO88591 or RXS_UTF8. Default Value: |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
|
|
|
|
|
|
|
|
Determines which SHA algorithm/block size to use when hashing. Valid Values:
|
|
Optional IFS stream file to use as input data for hash operation. |
|
CCSID of input data. Used when the input data is of a different CCSID of the job CCSID. Not necessary if using InputStmf. Default Value: |
|
CCSID to convert the input data into before hashing. Note that this is typically going to be RXS_ISO88591 or RXS_UTF8. Default Value: |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
|
|
|
|
|
|
|
|
Determines which AES algorithm to use when encrypting. Valid Values:
|
|
Determines which AES block mode to use when encrypting. Valid Values:
|
|
Specifies whether input data should be encrypted or decrypted. Valid Values:
|
|
AES standard requires that input data be exactly divisible into block lengths of 16 - specify this value as RXS_YES if you'd like RXS to perform this padding automatically, or to RXS_NO if you are manually padding the input data. Valid Values:
|
|
If PadInput is set to RXS_YES, the hex byte value in this field will be used for padding the input data. Default Value: |
|
Specifies if output data should be padded, and which padding method to use. Valid Values:
Default Value: |
|
If OutputPadOption is set to RXS_CRYPT_PADOUTPUT_CHAR, the hex byte value in this field will be used for padding the output data. Default Value: |
|
The data format of the encryption key. Currently only binary keys are fully supported. Valid Values:
Default Value: |
|
The encryption key to be used for AES256. Only the Key### field matching your AES algorithm needs to be specified. |
|
The encryption key to be used for AES192. Only the Key### field matching your AES algorithm needs to be specified. |
|
The encryption key to be used for AES128. Only the Key### field matching your AES algorithm needs to be specified. |
|
Initialization vector used for optional additional randomization. If this value is not null, both the encrypting party and the decrypting party need to know this value. |
|
CCSID of input data. Used when the input data is of a different CCSID than the job CCSID. Not necessary if using InputStmf. Default Value: |
|
When performing encryption, this field will specify the CCSID in which the data should be encrypted. If this value is different than the InputCcsid value, the data will be converted before encryption. When performing decryption, this field will specify the CCSID of the data that was encrypted. Default Value: |
|
Specify the CCSID of the encryption key. Used when the key is of a different CCSID than the job CCSID. If this value is different than the EncryptAsCcsid value, the data will be converted before encryption/decryption. Default Value: |
|
Optional IFS stream file to use as input data for encryption/decryption. |
|
Optional IFS stream file where encrypted/decrypted output will be written. |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |
|
Internal use only |