Calculate Hash (QC3CALHA, Qc3CalculateHash) API


  Required Parameter Group:


  Service Program Name: QC3HASH

  Default Public Authority: *USE

  Threadsafe: Yes

The Calculate Hash (OPM, QC3CALHA; ILE, Qc3CalculateHash) API uses a one-way hash function to produce a fixed-length output string from a variable-length input string. For all practical purposes, one-way hashes are irreversible. This property makes them useful for authentication purposes.

Information on cryptographic standards can be found in Create Algorithm Context (OPM, QC3CRTAX; ILE, Qc3CreateAlgorithmContext) API.


Authorities and Locks

Required API authority
*USE

Required device description authority
*USE


Required Parameter Group

Input data
INPUT; CHAR(*)

The data to hash.
The format of the input data is specified in the input data format name parameter

Length of input data
INPUT; BINARY(4)

For input data format DATA0100, this is the length of the data to hash.
For input data format DATA0200, this is the number of entries in the array.

Input data format name
INPUT; CHAR(8)

The format of the input data parameter.
The possible format names follow.

DATA0100
The input data parameter contains the data to hash.

DATA0200
The input data parameter contains an array of pointers and lengths to the data to hash.
See Input Data Formats for a description of this format.

Algorithm description
INPUT; CHAR(*)

The algorithm and associated parameters for hashing the data.
The format of the algorithm description is specified in the algorithm description format name parameter.

Algorithm description format name
INPUT; CHAR(8)

The format of the algorithm description.
The possible format names follow.

ALGD0100
The token for an algorithm context. This format must be used when performing the hash operation over multiple calls. After the last call (when the final operation flag is on), the context will reset to its initial state and can be used in another API.

ALGD0500
Parameters for a hash algorithm (MD5, SHA-1, SHA-256, SHA-384, SHA-512).

See Algorithm Description Formats for a description of these formats.

Cryptographic service provider
INPUT; CHAR(1)

The cryptographic service provider (CSP) that will perform the hash operation.


Cryptographic device name
INPUT; CHAR(10)

The name of a cryptographic device description.
This parameter is valid when the cryptographic service provider parameter specifies 2 (hardware CSP). Otherwise, this parameter must be blanks or the pointer to this parameter set to NULL.

Hash
OUTPUT; CHAR(*)

The area to store the hash. The length of hash is defined by the hash algorithm.


Error code
I/O; CHAR(*)

The structure in which to return error information.
For the format of the structure, see Error code parameter.


Input Data Formats

For detailed descriptions of the table fields, see Input Data Formats Field Descriptions.

DATA0200 Format



Input Data Formats Field Descriptions

Input data length
The length of data to hash.
Input data pointer
A space pointer to the data to hash.
Reserved
Must be null (binary 0s).

Algorithm Description Formats

For detailed descriptions of the table fields, see Algorithm Description Formats Field Descriptions.

ALGD0100 Format

ALGD0500 Format



Algorithm Description Formats Field Descriptions

Algorithm context token
A token for an algorithm context. The algorithm context is created by using the Create Algorithm Context (OPM, QC3CRTAX; ILE, Qc3CreateAlgorithmContext) API.

Hash algorithm
The hash algorithm. Following are the valid hash algorithms.

Final operation flag
The final processing indicator.


Error Messages




API introduced: V5R3

[ Back to top | Cryptographic Services APIs | APIs by category ]