rsa_free
rsa_free( rsa var )
Frees memory associated with a previously loaded RSA keypair.
Returns 1 on success, 0 on error.
 rsa = a handle returned by one of the rsa_load_xxx functions

rsa_generate_keypair
rsa_generate_keypair( pubkey_file, privkey_file, bits, e, passphrase )
Generates an RSA keypair, saving the public key in pubkey_file, the private key in privkey_file, and encrypting the private key with passphrase.
Returns 1 on success, 0 on error.
 pubkey_file = The name of the file in which the generated public key is stored
 privkey_file = The name of the file in which the generated private key is stored
 bits = The RSA modulus size, in bits
 e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
 passphrase = The passphrase used to encrypt the private key

rsa_generate_keypair_mem
rsa_generate_keypair_mem( pubkey var, privkey var, bits, e, passphrase )
Generates an RSA keypair, returning the public and private keys in variables, and encrypting the private key with passphrase.
Returns 1 on success, 0 on error.
 pubkey = The variable which receives the generated public key
 privkey = The variable which receives the generated private key
 bits = The RSA modulus size, in bits
 e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
 passphrase = The passphrase used to encrypt the private key

rsa_generate_keypair_mem_cipher
rsa_generate_keypair_mem_cipher( pubkey var, privkey var, bits, e, passphrase, ciphername )
Behaves identical to the legacy counterpart rsa_generate_keypair_mem() except that it allows the caller to specify the cipher used to encrypt the private key (the legacy function always uses desede3cbc).
Returns 1 on success or 0 on error.
 pubkey = The variable which receives the generated public key
 privkey = The variable which receives the generated private key
 bits = The RSA modulus size, in bits
 e = The public key exponent. Must be an odd number, typically 3, 17 or 65537
 passphrase = The passphrase used to encrypt the private key
 ciphername = an OpenSSL cipher identifier, such as "aes128cbc"

rsa_load_privatekey
rsa_load_privatekey( privkey_file, rsa var, passphrase )
Load an encrypted RSA private key from a PKCS#8 file specified by privkey_file, and decrypt it using passphrase.
Returns 1 on success, 0 on error.
 privkey_file = The name of the file containing the encrypted private key
 rsa = A variable which receives an internal reference to the loaded RSA key
 passphrase = The passphrase used to decrypt the private key

rsa_load_privatekey_engine
rsa_load_privatekey_engine( engine, key_id, rsa var )
Load an encryption key based on a key id.
Return value: 1 on success, 0 on failure.
 engine = Name of the encryption engine to use.

key_id = identifier of the key to load

rsa = RSA private key associated with the engine and key ID.

rsa_load_privatekey_mem
rsa_load_privatekey_mem( privkey, rsa var, passphrase )
Loads an encrypted RSA private key from a memory buffer containing PKCS#8 data
Returns 1 on success, 0 on error.
 privkey = The encrypted private key information in PKCS#8 format
 rsa = A variable which receives an internal reference to the loaded RSA key
 passphrase = The passphrase used to decrypt the private key

rsa_load_publickey
rsa_load_publickey( pubkey_file, rsa var )
Load an RSA public key from a PKCS#1 file specified by "pubkey_file".
Returns 1 on success, 0 on error.
 pubkey_file = The name of the file containing the public key
 rsa = A variable which receives an internal reference to the loaded RSA key

rsa_load_publickey_engine
rsa_load_publickey_engine( engine, key_id, rsa var )
Load an encryption key based on a key id.
Return value: 1 on success, 0 on failure.
 engine = Name of the encryption engine to use.

key_id = identifier of the key to load

rsa = RSA public key associated with the engine and key ID.

rsa_load_publickey_mem
rsa_load_publickey_mem( pubkey, rsa var )
Loads an RSA public key from a memory buffer containing PKCS#1 data
Returns 1 on success, 0 on error.
 pubkey = The public key in PKCS#1 format
 rsa = A variable which receives an internal reference to the loaded RSA key

rsa_private_decrypt
rsa_private_decrypt( rsa, encrypted, plaintext var )
Decrypts data previously encrypted using the public key portion of an RSA keypair.
Returns 1 on success, 0 on error.
 rsa = The internal reference to the RSA private key used for decryption
 encrypted = The encrypted ciphertext, in raw binary format
 plaintext = A variable which receives the decrypted plaintext

rsa_private_encrypt
rsa_private_encrypt( rsa, plaintext, encrypted var )
Encrypts data using the private key portion of an RSA keypair.
Returns 1 on success, 0 on error.
 rsa = The internal reference to the RSA private key used for encryption
 plaintext = The data to be encrypted
 encrypted = A variable which receives the encrypted ciphertext in raw binary format

rsa_public_decrypt
rsa_public_decrypt( rsa, encrypted, plaintext var )
Decrypts data previously encrypted using the private key portion of an RSA keypair.
Returns 1 on success, 0 on error.
 rsa = The internal reference to the RSA public key used for decryption
 encrypted = The encrypted ciphertext, in raw binary format
 plaintext = A variable which receives the decrypted plaintext

rsa_public_encrypt
rsa_public_encrypt( rsa, plaintext, encrypted var )
Encrypts data using the public key portion of an RSA keypair.
Returns 1 on success, 0 on error.
 rsa = The internal reference to the RSA public key used for encryption
 plaintext = The data to be encrypted
 encrypted = A variable which receives the encrypted ciphertext in raw binary format

rsa_save_privatekey
rsa_save_privatekey( privkey_file, rsa var, passphrase )
Encrypts and writes a previously loaded RSA private key to a file in PKCS#8 format
Returns 1 on success, 0 on error.
 privkey_file = The name of the file in which the private key is to be stored
 rsa = The internal reference to the RSA private key to be saved
 passphrase = The passphrase used to encrypt the private key

rsa_save_privatekey_mem
rsa_save_privatekey_mem( privkey var, rsa var, passphrase )
Encrypts a previously loaded RSA private key and stores it into a variable in PKCS#8 format
Returns 1 on success, 0 on error.
 privkey = The variable which will receive the encrypted private key
 rsa = The internal reference to the RSA private key to be saved
 passphrase = The passphrase used to encrypt the private key

rsa_save_privatekey_mem_cipher
rsa_save_privatekey_mem_cipher( privkey var, rsa var, passphrase, ciphername )
Behaves identical to the legacy counterpart rsa_save_privatekey_mem() except that it allows the caller to specify the cipher used to encrypt the private key (the legacy function always uses desede3cbc).
 ciphername = an OpenSSL cipher identifier that specifies the cipher to be used. Note that OpenSSL only permits a subset of its supported ciphers to be used for RSA key encryption. For example, only CBC mode ciphers are permitted.

rsa_sign
rsa_sign( rsa, buffer, signature var )
Generates a digital signature using SHA1 and an RSA private key
Returns 1 on success, 0 on failure. Requires OpenSSL 0.9.7 or greater.
 rsa = The internal reference to the RSA private key to be used
 buffer = The data to be signed
 signature = A variable which receives the signature in raw binary format

rsa_verify
rsa_verify( rsa, buffer, signature )
Verifies a digital signature previously generated by rsa_sign
Returns 1 on success, 0 on verification failure or error. Requires OpenSSL 0.9.7 or greater.
 rsa = The internal reference to the RSA public key used for verification
 buffer = The data for which the signature is to be verified
 signature = The signature to verify, in raw binary format
