Create Key Context (QC3CRTKX, Qc3CreateKeyContext) API


  Required Parameter Group:


  Service Program Name: QC3CTX

  Default Public Authority: *USE

  Threadsafe: Yes

The Create Key Context (OPM, QC3CRTKX; ILE, Qc3CreateKeyContext) API creates a temporary area for holding a cryptographic key. The API returns a token which can be used on subsequent cryptographic APIs when specifying a key. The key context can not be shared between jobs. It should be destroyed by using the Destroy Key Context (OPM, QC3DESKX; ILE, Qc3DestroyKeyContext) API. If the key context is not destroyed before relinquishing control, it could be used by other users of the job. If not explicitly destroyed, the key context will be destroyed at job end.

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


Authorities and Locks

Required file authority
*OBJOPR, *READ

Required Parameter Group

Key string
INPUT; CHAR(*)

A binary string, a formatted structure containing the key, or a reference to the location of the key. The exact format of the key string is specified in the key format parameter.

Length of key string
INPUT; BINARY(4)

Length of the key string specified in the key string parameter.

Note this is not the same thing as key length. Key length is determined based on the other parameters. Following are some examples:

  • If key format is 0 (binary string) and
    • the key form is 0 (clear) then the key length equals the length of key string.
    • the key form is 1 (encrypted) then the key length will be the decrypted key string length.
  • If key format is 1 (BER string) then the key length will be the length specified within the BER string.
  • If key format is 4 (a stored key) then the key length is obtained from the stored key record.
  • If key format is 5 (a PKCS5 key) then the key length is the specified derived key length.
  • If key format is 6 (PEM certificate) then the key length will be the length specified in the certificate.
  • If key format is 7 or 8 (a key from certificate store) then the key length will be the length stored in the certificate.

Most algorithms have key length requirements. Refer to the key type parameter for restrictions on key length.

Key format
INPUT; CHAR(1)

Format of the key string parameter.
Following are the valid values.


Qualified keystore file name
The keystore file where the key is stored. The first 10 characters contain the file name. The second 10 characters contain the name of the library where the keystore file is located. You can use the following special values for the library name.
Record label
The label of the key record. The label will be converted from the job CCSID, or if 65535, the job default CCSID (DFTCCSID) job attribute to CCSID 1200 (Unicode UTF-16).

Reserved
Must be null (binary 0s).


Reserved
Must be null (binary 0s).

Derived key length
The length of key requested. The minimum allowed length is 1.

Iteration count
Used to greatly increase the cost of an exhaustive search while modestly increasing the cost of key derivation. The minimum allowed value is 1. The standard recommends a minimum of 1,000. The maximum allowed length is 100,000.

Salt length
The length of salt. The length must be in the range of 1 to 16.

Salt
Used to help thwart attacks by producing a large set of keys for each passphrase. The standard recommends the salt be generated at random and be at least 8 bytes long. You can use the Generate Pseudorandom Numbers (OPM, QC3GENPRN; ILE, Qc3GenPRNs) API to obtain a random value. Additionally, data that distinguishes between various operations can be added to the salt for additional security. Refer to the standard for more information.

Passphrase CCSID
INPUT; BINARY(4)

The CCSID of the passphrase. The passphrase will be converted from the specified CCSID to Unicode before calling the PKCS5 algorithm.


Passphrase length
The length of passphrase. The length must be in the range of 1 to 256.

Passphrase
A text string.


Key type
INPUT; BINARY(4)

The type of key.
Following are the valid values.


Key form
INPUT; CHAR(1)

An indicator specifying if the key string parameter is in encrypted form.


Key-encrypting key
INPUT; CHAR(*)

The key under which the key string parameter is encrypted

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 8-byte key context token to use for decrypting the key string parameter.

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



Master key ID
The master key to use for decrypting the key string parameter. The master key IDs are


Disallowed function
INPUT; BINARY(4)

This parameter specifies the functions that are not allowed to be used with this key. This value was XOR'd into the master key when this key was encrypted and therefore must be used when creating a key context for 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.


Master key KVV
The master key verification value. The master key version with a KVV that matches this value will be used to decrypt the key. If this value is null, the current version of the master key will be used.

Reserved
Must be null (binary 0s).

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 decrypting the key string parameter.

Key context token
OUTPUT; CHAR(8)

The area to store the token for the created key context.
Each token will contain an authentication value. If the token is used on a subsequent API but with an incorrect authentication value, the user will be subjected to a 10 second penalty wait. For each authentication error in that job, the penalty wait will increase 10 seconds up to a maximum of 10 minutes.

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 ]