Write Key Record (QC3WRTKR, Qc3WriteKeyRecord) API


  Required Parameter Group:


 Service Program Name: QC3KRWRT

 Default Public Authority: *USE

 Threadsafe: Yes

The Write Key Record (OPM, QC3WRTKR; ILE, Qc3WriteKeyRecord) API stores the specified key value in a keystore file.

For more information about cryptographic services keystore, see Cryptographic Services Key Management.


Authorities and Locks

Required file authority
*OBJOPR, *READ, *ADD


Required Parameter Group

Qualified keystore file name
INPUT; CHAR(20)

The keystore file where the key will be 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
INPUT; CHAR(32)

The label for 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).

Key string
INPUT; CHAR(*)

A binary string or a formatted structure containing 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 6 (PEM certificate) then the key length will be the length specified 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.

Key type
INPUT; BINARY(4)

The type of key.
Following are the valid values.


Disallowed function
INPUT; BINARY(4)

This parameter specifies the functions that cannot be used with this key record. The values listed below can be added together to disallow multiple functions. For example, to disallow everything but MACing, set the value to 11.


Key form
INPUT; CHAR(1)

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


Key-encrypting key context token
INPUT; CHAR(8)

The key context token specifying the key for decrypting the key string parameter. If the key string parameter is not encrypted (key form parameter is 0), this parameter must be set to blanks or the pointer to this parameter set to NULL.

Key-encrypting algorithm context token
INPUT; CHAR(8)

The algorithm context token specifying the algorithm for decrypting the key string parameter. If the key string parameter is not encrypted (key form parameter is 0), this parameter must be set to blanks or the pointer to this parameter set to NULL.

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: V5R4

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