Description: The ImportKey function transfers a cryptographic key from a key BLOB into a CSP. It is the VTS analog of the CryptoAPI ImportKey call.
Returns: Key
Usage: Script
Format: ImportKey(CSP, BlobType, KeyBLOB [, DecryptKey, Flags, Error])
Parameters: CSP { handle } { required } { no default }
The handle to the CSP which is receive the imported key.
BlobType { numeric } { required } { no default }
A parameter specifying the type of key BLOB to be imported. Values are defined in WinCrypt.h
KeyBLOB { text } { required } { no default }
Text string containing the KeyBLOB to be imported.
EncryptKey { handle } { optional } { default: NULL }
An optional parameter containing a Key handle for a key to be used to encrypt the exported key so that it may only be encrypted by the destination user. If omitted or invalid, then the value NULL is used.
Flags { numeric } { optional } { default: 0 }
An optional parameter specifying the flags to be passed to CryptExportKey. If omitted or invalid then the value 0 is used.
Error { numeric (return value) } { optional } { no default }
An optional variable in which the error code for the function is returned. It has the following meaning:
|
Error |
Meaning |
|
0 |
Key successfully imported. |
|
1 |
CSP, BlobType or KeyBLOB parameters invalid. |
|
X |
Any other value is an error from CryptImportKey. |
Comments: The new key is returned as a Key handle. If an error occurs, the return value is invalid.
Example:
[
Constant PUBLICKEYBLOB = 0x6;
Key3;
]
Init [
If 1 Main;
[
{ Import the public key }
Key3 = ImportKey(CSP, PUBLICKEYBLOB, PubKey1, Key2);
]
]
See Also:
DeriveKey | Decrypt | Encrypt | ExportKey | GenerateKey | GetCryptoProvider | GetKeyParam | SetKeyParam