Cipher Data (CPHDTA)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: No
Parameters
Examples
Error messages

The Cipher Data (CPHDTA) command is used to encrypt or decrypt a variable length of data.

Top

Parameters

Keyword Description Choices Notes
DATA Input data Character value Required, Positional 1
DTALEN Input data length 1-65528 Required, Positional 2
CPHK Cipher key Character value Required, Positional 3
RTNVAR CL var for returned value Character value Required, Positional 4
OPTION Option *ECPH, *DCPH, *SCPH Required, Positional 5
KTYPE Key type *CLEAR, *CIPHER Optional, Positional 6
CHAIN Chain option *NO, *YES Optional, Positional 7
ICV Initial chaining value Character value, *NONE Optional, Positional 8
PAD Pad option *NO, *YES Optional, Positional 9
PADCHAR Pad character Character value, X'00' Optional, Positional 10
RTNDTALEN CL var for returned length Decimal number Optional, Positional 11
Top

Input data (DATA)

Specifies the data or, a variable containing the data, to be encrypted or decrypted. The data must be at least as long as the length specified in the Input data length prompt (DTALEN parameter). If *SCPH (specific encryption) is specified in the Option prompt (OPTION parameter), only values 0-9 and A-F may be specified in this parameter. This is a required parameter.

Top

Input data length (DTALEN)

Specifies the length or a variable containing the length of the data to be encrypted or decrypted.

When encrypting data, the length must be a multiple of 8 bytes if *NO is specified for both the Pad option prompt (PAD parameter) and the Chain option parameter (CHAIN parameter). The length must be less than 65,528 if the Pad option prompt (PAD parameter) is specified as *YES. The length must be less than or equal to 65,528 if the Pad option prompt (PAD parameter) is specified as *NO. If *SCPH (specific encryption) is specified in the Option prompt (OPTION parameter), this value must be 16.

When decrypting data, the length must be a multiple of 8 bytes unless cipher block chaining was used when the data was encrypted. The length must be less than or equal to 65,528. This is a required parameter.

Top

Cipher key (CPHK)

Specifies an 8-byte value, or a variable containing an 8-byte value, to be used as the key for the Data Encryption Algorithm. There are no restrictions on the value of this parameter. This is a required parameter.

Top

CL var for returned value (RTNVAR)

Specifies a variable to receive the results of the cipher operation. If *YES is specified for the Pad option (PAD parameter) and *ECPH is specified for the Option (OPTION parameter), the variable must be at least as long as the next 8-byte multiple past the value specified for the Input data length prompt (DTALEN parameter). Otherwise, it must be at least as long as the value specified for the Input data length prompt (DTALEN parameter). This is a required parameter.

Top

Option (OPTION)

Specifies the cipher function to be performed. This is a required parameter.

The possible values are:

*ECPH
A copy of the data in the Input data prompt (DATA parameter) is encrypted and placed in the variable specified in the CL var for returned value prompt (RTNVAR parameter)
*SCPH
The Input data prompt (DATA parameter) contains 16 hexadecimal characters representing 8 bytes of data to encrypt (for example, 'C1' represents 'A'). A copy of these 16 hexadecimal characters is converted to an 8-byte field and encrypted. The resulting 8 bytes of ciphertext are converted back to 16 hexadecimal characters and placed in the CL var for returned value prompt (RTNVAR parameter).
*DCPH
A copy of the data in the Input data prompt (DATA parameter) is decrypted and placed in the variable specified in the CL var for returned value prompt (RTNVAR parameter).
Top

Key type (KTYPE)

Specifies the format of the key specified in the Cipher key prompt (CPHK parameter).

The possible values are:

*CLEAR
The cipher key is specified in plaintext. If *SCPH is specified for the Option prompt (OPTION parameter), the value specified must be *CLEAR.
*CIPHER
The cipher key is enciphered under the host master key. If *YES is specified for the Chain option prompt (CHAIN parameter) or the Pad option prompt (PAD parameter), the value specified must be *CIPHER.
Top

Chain option (CHAIN)

Specifies whether cipher block chaining is to be used during the cipher operation.

The possible values are:

*NO
Cipher block chaining will not be used. If *SCPH is specified for the Option prompt (OPTION parameter) or *CLEAR is specified for the Key type prompt (KTYPE parameter), *NO must be specified.
*YES
Cipher block chaining will be used.
Top

Initial chaining value (ICV)

Specifies an 8-byte value, or a variable containing an 8-byte value, to be used as the initial chaining value when performing cipher block chaining. This parameter is ignored if *NO is specified for the Chain option prompt (CHAIN option).

The possible values are:

*NONE
There is no initial chaining value.
initial-chaining-value
Specify the value to be used as the initial chaining value for cipher block chaining. There are no restrictions on the value for this parameter. A value must be specified if *YES is specified for the Chain option prompt (CHAIN option).
Top

Pad option (PAD)

Specifies whether padding is to be performed.

The possible values are:

*NO
Padding will not be performed. *NO must be specified if *SCPH is specified for the Option prompt (OPTION parameter).
*YES
Before encrypting, the data is padded out to the next 8-byte multiple using the pad character specified in the Pad character prompt (PADCHAR parameter). The last byte is then replaced with a count of the number of pad characters.

After the data is decrypted, the pad characters and count byte are left appended to the data. The length of the data without the pad characters is returned in the variable specified in the CL var for returned length prompt (RTNDTALEN parameter).

Top

Pad character (PADCHAR)

Specifies a 1-byte value, or a variable containing a 1-byte value, to be used as the pad character when *ECPH is specified for the Option prompt (OPTION parameter) and *YES is specified for the Pad option prompt (PAD parameter). The default (1-byte pad character) is hex 00.

Top

CL var for returned length (RTNDTALEN)

Specifies a variable to receive the length of the returned data. When *DCPH is specified for the Option prompt (OPTION parameter) and *YES is specified for the Pad option prompt (PAD parameter), this length is the length of the deciphered data without padding. Otherwise, this variable contains the length of the data placed in the variable specified in the CL var for returned value prompt (RTNVAR parameter).

Top

Examples

None
Top

Error messages

Unknown
Top