Home    XP_CRYPT Online Help Prev Next
How To use XP_CRYPT GUI
Introduction
What is XP_CRYPT
System requirements
Free version limitations
End user license agreement
Installing XP_CRYPT
Installation procedure
Activation
XP_CRYPT API
What's new
Encryption methods overview
Session
xp_crypt_set_var
xp_crypt_get_var
xp_crypt_close_session
xp_crypt_init_session
xp_crypt_set_option
Asymmetric keys
DSA
xp_dsa_free_key
xp_dsa_load_key
xp_dsa_save_key
xp_dsa_generate_couple
RSA
xp_rsa_generate_couple
xp_rsa_generate_pub_key
xp_rsa_load_key
xp_rsa_priv_dec
xp_rsa_pub_enc
xp_rsa_save_key
xp_rsa_free_key
Digital signatures
DSA
xp_dsa_verify
xp_dsa_sign
RSA
xp_rsa_sign
xp_rsa_verify
Hashing
xp_crypt
xp_md5
xp_sha1
Symmetric encryption
AES128
xp_aes128_decrypt
xp_aes128_encrypt
AES
xp_aes_decrypt
xp_aes_encrypt
DESX
xp_desx_decrypt
xp_desx_encrypt
RC4
xp_rc4_decrypt
xp_rc4_encrypt
Triple DES
xp_des3_encrypt
xp_des3_decrypt
Error codes
Tutorial
How to use GUI
Advanced technique (Old)
Table encryption (Old)
Troubleshooting
Troubleshooting overview

xp_rsa_load_key

The function loads a private key, a public key or x.509 certificate from a file or string into memory.  

Syntax

xp_rsa_load_key { key_source, key_handle OUTPUT [, password] }

Arguments

key_source

VARCHAR. 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. A key of this type cannot be used here as a key source. A key handle is returned as a result of the successful loading. Using handles significantly increases speed of the encryption/decryption operation comparing to filename of key bodies. One disadvantage is that you should explicitly free the key after the usage. The use of the filename or body as a source does not require xp_rsa_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 can be stored in PEM or x.509  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 a key file and pass its content as a string. You must preserve new lines and all semantic 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 only valid until you explicitly free it with xp_rsa_free_key or restart the server. Declare the key variable as varchar (20).

password

VARCHAR. A password which is used for loading the key from the source. Do not provide passwords for the public keys or certificates. If password is given, the key is considered as private one. Otherwise xp_rsa_load_key will attempt to load the public key or x.509 certificate. If the pswd_cache option is set to yes and the given password is '?'  XP_CRYPT will try to load the key with a 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_rsa_load_key 'privkey.pem', @PrivateKey output, 'SecurePassword'

-- Loading public key or certificate from file
exec xp_rsa_load_key 'pubkey.pem', @PubKey output

 
2004-2011 (c) Active Crypt Software. All rights reserved.

Browser Based Help. Published by chm2web software.