Generate Symmetric Key (QC3GENSK, Qc3GenSymmetricKey)


  Required Parameter Group:


  Service Program Name: QC3KEYGN

  Default Public Authority: *USE

  Threadsafe: Yes

The Generate Symmetric Key (OPM, QC3GENSK; ILE, Qc3GenSymmetricKey) API generates a random key value that can be used with symmetric cipher algorithms DES, Triple DES, AES, RC2, and RC4-compatible, or the HMAC algorithms MD5, SHA-1, SHA-256, SHA-384, and SHA-512.

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


Authorities and Locks

Required device description authority
*USE


Required Parameter Group

Key type
INPUT; BINARY(4)

The type of key.
Following are the valid values.


Key size
INPUT; BINARY(4)

The length of key to generate in bytes.
Refer to the key type parameter for restrictions.

Key format
INPUT; CHAR(1)

The format in which to return the key.
Following are the valid values.

Key form
INPUT; CHAR(1)

The form in which to return the key.


Key-encrypting key
INPUT; CHAR(*)

For key form 0 (clear), this parameter must be set to blanks or the pointer to this parameter set to NULL.

For key form 1 (encrypted), this parameter specifies the key context token to use to encrypt the generated key.

For key form 2 (encrypted with a master key), this parameter has the following structure:



Master key ID
The master key IDs are


Reserved
Must be null (binary 0s).

Disallowed function
INPUT; BINARY(4)

This parameter specifies the functions that cannot be used with this key. The values listed below can be added together to disallow multiple functions. For example, to disallow everything but MACing, set the value to 11. This value should be saved along with the encrypted key value because it will be required when the encrypted key value is used on an API.


Master key KVV
The key verification value of the master key that was used to encrypt the key is returned in this field. This value should be saved along with the encrypted key value. When the encrypted key value is used on an API and the KVV is supplied, the API will be able to determine which version of the master key should be used to decrypt the key. This field must be null (binary 0s) on input.

Key-encrypting algorithm
INPUT; CHAR(8)

For key form 0 (clear) and 2 (encrypted with a master key), this parameter must be set to blanks or the pointer to this parameter set to NULL.

For key form 1 (encrypted), this parameter specifies the algorithm context token to use for encrypting the generated key.

Cryptographic service provider
INPUT; CHAR(1)

The cryptographic service provider (CSP) that will perform the key generate 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.

Key string
OUTPUT; CHAR(*)

The area to store the generated key string.

Length of area provided for key string
INPUT; BINARY(4)

The length of the key string parameter.
The length of the generated key string will be the length specified in the key size parameter. If the key form specifies 1 (encrypted), you must allow room for padding the encrypted key string to the next block length multiple. (e.g. Add an additional 8 bytes for DES.) For more information on block length, see Create Algorithm Context (OPM, QC3CRTAX; ILE, Qc3CreateAlgorithmContext) API.

Length of key string returned
OUTPUT; BINARY(4)

The length of the key string returned in the key string parameter.
If the length of area provided for the key string is too small, an error will be generated and no data will be returned in the key string parameter.

Error code
I/O; CHAR(*)

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


Error Messages



API introduced: V5R3

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