Purpose: The ExportKey function exports a cryptographic key or a key pair from a CSP in a secure manner as a Key BLOB. It is the VTS analog of the Crypto API ExportKey call.
Returns: Text
Usage: Script
Format: ExportKey(Key, BlobType [, EncryptKey, Flags, Error])
Parameters: Key { handle } { required } { no default: }
The handle to the key which is to be exported.
BlobType { numeric } { required } { no default: }
A parameter specifying the type of key BLOB to be exported. Values are defined in WinCrypt.h
EncryptKey { handle } { required } { no default: }
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. Flags values are defined in WinCrypt.h.
Error { numeric } { 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 exported. |
|
1 |
Key or BlobType parameters invalid. |
|
x |
Any other value is an error from CryptExportKey. |
Comments: The exported key is returned as a text string. If an error occurs, the return value is invalid.
EncryptKey is not required if BlobType is PUBLICKEYBLOB.
Example:
[
PubKey1;
Constant PUBLICKEYBLOB = 0x6;
]
Init [
If 1 Main;
[
{ Export the public key }
PubKey1 = ExportKey(Key1, PUBLICKEYBLOB);
]
]
See Also:
DeriveKey | Decrypt | Encrypt | GenerateKey | GetCryptoProvider | GetKeyParam | ImportKey | SetKeyParam