|
Loads private key or public key from file or string to
memory.
Syntax
xp_dsa_load_key { key_source, key_handle OUTPUT
[, password] }
Arguments
key_source
VARCHAR. Is the source of the key to be loaded. There are 3 types of
key source:
- Handle: Handle of the key which is already loaded into memory. The key of this type cannot be used here as a key source. Key
handle is returned as a result of the successful
loading. Using handles significantly increases speed of sign/verify
operation comparing to filename of key bodies. One disadvantage
is that you should explicitly free the key after the usage.
Using the filename or key body as a source does not require xp_dsa_free_key function, they are
loaded and freed automatically.
- Filename: This is a default source of the key. You can simply
specify the name of the file here or precede it with '<'
character. In the other functions you must explicitly precede file
names. Keys are stored in PEM format.
- Key body: This is the VARCHAR string which holds the content of
the key file. Sometimes it is very useful when you do not need
to store keys at the server side and simply load them from
your client connection. In this case your front end software
must read the key file and pass its content as a string. You must
preserve new lines and all semantics in this file.
key_handle
VARCHAR. This variable receives the handle of the loaded key. This
key handle refers to the real key loaded into memory and is valid only until you explicitly free it with xp_dsa_free_key
or restart the server. Declare key variable as VARCHAR (10).
password
VARCHAR. A password for loading the key from the source. Do not
provide passwords for the public keys or certificates. If a password is given
the key is considered as private, otherwise xp_dsa_load_key
will try to attempt to load the public key. If the pswd_cache option is set to yes and the given password is '?' XP_CRYPT will try
to load the key with the password stored in the session. See xp_crypt_set_option for more
information about pswd_cache option.
Permissions
Execute permissions default to the public role.
Return Code Values
0 - success, or Error code if failed.
key_handle IS NOT NULL (success) or key_handle IS NULL
(failure)
Example
-- Loading private key from file
exec xp_dsa_load_key 'privkey.pem', @PrivateKey output,
'SecurePassword'
-- Loading public key or certificate from file
exec xp_dsa_load_key 'pubkey.pem', @PubKey output
|
|