SetKeyParam

Description: The SetKeyParam function customizes various aspects of a session key's operations. The values set by this function are not persisted to memory and can only be used with in a single session. It is the VTScada analog of the CryptoAPI SetKeyParam call.
Returns: Numeric, where 0 indicates success and a non-zero value indicates a system error code.
Usage: Script Only.
Function Groups: Cryptography
Related to: DeriveKey | Decrypt | Encrypt | ExportKey | GenerateKey | GetCryptoProvider | GetKeyParam | ImportKey
Format: SetKeyParam(Key, Param [, Value, Flags, Error])
Parameters:  
Key
Required. The handle to the key for which values are to be set.
Param

Required text or numeric. A parameter specifying the value to be set.

CAPI (Cryptography API) providers are specified using numeric identifiers. Values are defined in WinCrypt.h

CNG (Cryptography New Generation) algorithm providers are specified using text identifiers.

Value

An optional parameter containing the value to which the keys parameter is to be set. If omitted or invalid then the value 0 is used.

Warning: Accidentally passing a value that is meant to be a number but is actually stored as text, "42", will cause an error.

Flags
An optional parameter specifying the flags to be passed to CryptSetKeyParam. If omitted or invalid then the value 0 is used.
Error
Required. An optional variable in which the error code for the function is returned. It has the following meaning:

Error

Meaning

0

Key parameter successfully set.

1

Key or Param or Value parameters invalid.

X

Any other value is an error from CryptSetKeyParam.

Comments: The allowable values for Param vary with the key type.

Example:

[
  Constant KP_G = 12 { DSS/Diffie-Hellman G value };
]
Init [
  If 1 Main;
  [
    { Set the key parameter }
    SetKeyParam(Key2, KP_G, KeyG);
  ]
]