3.8. Cryptographic Functions

Qore's cryptography support is provided by the OpenSSL library. Most of the encryption and decryption functions in this section accept an optional initialization vector, which is data used as initial input for the first block in chained encryption algorithms. Subsequent blocks take input from the last block encrypted/decrypted. If a function accepts an initialization vector and one is not supplied, then a default value of 8 zero bytes will be used.

Some functions require fixed-length keys, and some allow the use of variable-length keys. For functions requiring fixed-length keys any excess bytes are ignored. The same applies to initialization vector arguments.

The following is an example of a function that uses /dev/random to read in a random key for use with encryption functions:

# read a key from /dev/random and return the key
binary sub get_key(int $size) {
    # throw an exception if an invalid key size was passed
    if (!$size || $size < 0)
        throw "GET-KEY-ERROR", sprintf("invalid size = %n", $size);
    my File $f();
    # File::open2() will throw an exception if /dev/random cannot be opened for reading
    $f.open2("/dev/random");
    return $f.readBinary($size);
}

3.8.1. blowfish_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key and an optional initialization vector. Returns a binary object of the encrypted data.

Prototype

binaryblowfish_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = blowfish_encrypt_cbc("hello there", $key);

Table 3.179. Arguments and Return Values for blowfish_encrypt_cbc()

Argument Type

Return Type

Description

data$data, data$key, data$iv = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for the blowfish algorithm; accepts a variable-length key (recommended 16-bytes or more). The initialization vector must be at least 8 bytes long if present.


Table 3.180. Exceptions thrown by blowfish_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

BLOWFISH-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.2. blowfish_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. This function returns a binary object, for an equivalent function that decrypts to a string, see blowfish_decrypt_cbc_to_string().

Prototype

binaryblowfish_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = blowfish_decrypt_cbc($encrypted_binary_data, $key);

Table 3.181. Arguments and Return Values for blowfish_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key.


Table 3.182. Exceptions thrown by blowfish_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

BLOWFISH-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.3. blowfish_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key. This function returns a string, for an equivalent function that decrypts to a binary object, see blowfish_decrypt_cbc().

Prototype

stringblowfish_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = blowfish_decrypt_cbc_to_string($bin, $key);

Table 3.183. Arguments and Return Values for blowfish_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm using a variable-length key.


Table 3.184. Exceptions thrown by blowfish_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

BLOWFISH-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.4. des_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. Returns a binary object of the encrypted data.

Prototype

binarydes_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = des_encrypt_cbc($text, $key);

Table 3.185. Arguments and Return Values for des_encrypt_cbc()

Argument Type

Return Type

Description

data$data, data$key, data$iv = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for the DES algorithm. The key must be at least 8-bytes long (only the first 8 bytes will be used). If the init_vector is present it must also be at least 8 bytes long.


Table 3.186. Exceptions thrown by des_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.5. des_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8 byte key. This function returns a binary object, for an equivalent function that decrypts to a string, see des_decrypt_cbc_to_string().

Prototype

binarydes_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Table 3.187. Arguments and Return Values for des_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. If the init_vector is present it must also be at least 8 bytes long.


Table 3.188. Exceptions thrown by des_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.6. des_decrypt_cbc_to_string()

Synopsis

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. This function returns a string, for an equivalent function that decrypts to a binary object, see des_decrypt_cbc().

Prototype

stringdes_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Table 3.189. Arguments and Return Values for des_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data using the Cipher Block Chaining function for the DES algorithm using an 8-byte key. If the init_vector is present it must also be at least 8 bytes long.


Table 3.190. Exceptions thrown by des_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.7. des_ede_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). Returns a binary object of the encrypted data.

Prototype

binarydes_ede_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = des_ede_encrypt_cbc($text, $key);

Table 3.191. Arguments and Return Values for des_ede_encrypt_cbc()

Argument Type

Return Type

Description

data$data, data$key, data$iv = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long.


Table 3.192. Exceptions thrown by des_ede_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.8. des_ede_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). This function returns a binary object, for an equivalent function that decrypts to a string, see des_ede_decrypt_cbc_to_string().

Prototype

binarydes_ede_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = des_ede_decrypt_cbc($data, $key);

Table 3.193. Arguments and Return Values for des_ede_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long.


Table 3.194. Exceptions thrown by des_ede_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.9. des_ede_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm using two eight-byte keys (set by a single 16-byte key argument). This function returns a string, for an equivalent function that decrypts to a binary object, see des_ede_decrypt_cbc().

Prototype

stringdes_ede_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = des_ede_decrypt_cbc_to_string($data, $key);

Table 3.195. Arguments and Return Values for des_ede_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm. The key argument must be at least 16 bytes long; only the first 16 bytes of the key argument will be used for the two 8-byte keys. If the init_vector argument is present, it must be at least 8 bytes long.


Table 3.196. Exceptions thrown by des_ede_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.10. des_ede3_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binarydes_ede3_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = des_ede3_encrypt_cbc($data, $key);

Table 3.197. Arguments and Return Values for des_ede3_encrypt_cbc()

Argument Type

Return Type

Description

data$data, data$key, data$iv = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.


Table 3.198. Exceptions thrown by des_ede3_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.11. des_ede3_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see des_ede3_decrypt_cbc_to_string().

Prototype

binarydes_ede3_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = des_ede3_decrypt_cbc($data, $key);

Table 3.199. Arguments and Return Values for des_ede3_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm.


Table 3.200. Exceptions thrown by des_ede3_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.12. des_ede3_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see des_ede3_decrypt_cbc().

Prototype

stringdes_ede3_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = des_ede3_decrypt_cbc_to_string($data, $key);

Table 3.201. Arguments and Return Values for des_ede3_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm using three 8-byte keys (set by a single 24-byte key argument) and an optional 8-byte initialization vector.


Table 3.202. Exceptions thrown by des_ede3_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DES-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.13. desx_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binarydesx_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = desx_encrypt_cbc($data, $key);

Table 3.203. Arguments and Return Values for desx_encrypt_cbc()

Argument Type

Return Type

Description

data$data, data$key, data$iv = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector.


Table 3.204. Exceptions thrown by desx_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DESX-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.14. desx_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see desx_decrypt_cbc_to_string().

Prototype

binarydesx_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
my binary $bin = desx_decrypt_cbc($data, $key);

Table 3.205. Arguments and Return Values for desx_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector.


Table 3.206. Exceptions thrown by desx_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DESX-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.15. desx_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see desx_decrypt_cbc().

Prototype

stringdesx_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = desx_decrypt_cbc_to_string($data, $key);

Table 3.207. Arguments and Return Values for desx_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm using a 24-byte key and an optional 8-byte initialization vector.


Table 3.208. Exceptions thrown by desx_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

DESX-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.16. rc2_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binaryrc2_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = rc2_encrypt_cbc($data, $key);

Table 3.209. Arguments and Return Values for rc2_encrypt_cbc()

Argument Type

Return Type

Description

data, data, data = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.210. Exceptions thrown by rc2_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC2-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.17. rc2_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc2_decrypt_cbc_to_string().

Prototype

binaryrc2_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = rc2_decrypt_cbc($data, $key);

Table 3.211. Arguments and Return Values for rc2_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.212. Exceptions thrown by rc2_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC2-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.18. rc2_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc2_decrypt_cbc().

Prototype

stringrc2_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = rc2_decrypt_cbc_to_string($data, $key);

Table 3.213. Arguments and Return Values for rc2_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.214. Exceptions thrown by rc2_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC2-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.19. cast5_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binarycast5_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = cast5_encrypt_cbc($data, $key);

Table 3.215. Arguments and Return Values for cast5_encrypt_cbc()

Argument Type

Return Type

Description

data, data, data = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.216. Exceptions thrown by cast5_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

CAST5-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.20. cast5_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see cast5_decrypt_cbc_to_string().

Prototype

binarycast5_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = cast5_decrypt_cbc($data, $key);

Table 3.217. Arguments and Return Values for cast5_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.218. Exceptions thrown by cast5_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

CAST5-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.21. cast5_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see cast5_decrypt_cbc().

Prototype

stringcast5_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = cast5_decrypt_cbc_to_string($data, $key);

Table 3.219. Arguments and Return Values for cast5_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.220. Exceptions thrown by cast5_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

CAST5-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.22. rc4_encrypt()

Synopsis

Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binaryrc4_encrypt(data$data, data$key, data$iv = defaultIV)

Example
$bin = rc4_encrypt($data, $key);

Table 3.221. Arguments and Return Values for rc4_encrypt()

Argument Type

Return Type

Description

data, data, data = defaultIV

binary

Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.222. Exceptions thrown by rc4_encrypt()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC4-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.23. rc4_decrypt()

Synopsis

Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc4_decrypt_to_string().

Prototype

binaryrc4_decrypt(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = rc4_decrypt($data, $key);

Table 3.223. Arguments and Return Values for rc4_decrypt()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.224. Exceptions thrown by rc4_decrypt()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC4-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.24. rc4_decrypt_to_string()

Synopsis

Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc4_decrypt().

Prototype

stringrc4_decrypt_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = rc4_decrypt_to_string($data, $key);

Table 3.225. Arguments and Return Values for rc4_decrypt_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.226. Exceptions thrown by rc4_decrypt_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC4-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)


3.8.25. rc5_encrypt_cbc()

Synopsis

Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. Returns a binary object of the encrypted data.

Prototype

binaryrc5_encrypt_cbc(data$data, data$key, data$iv = defaultIV)

Example
$bin = rc5_encrypt_cbc($data, $key);
Platform Availability

HAVE_RC5

Table 3.227. Arguments and Return Values for rc5_encrypt_cbc()

Argument Type

Return Type

Description

data, data, data = defaultIV

binary

Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.228. Exceptions thrown by rc5_encrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC5-ENCRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_RC5 before calling this function.


3.8.26. rc5_decrypt_cbc()

Synopsis

Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a binary object, for an equivalent function that decrypts to a string, see rc5_decrypt_cbc_to_string().

Prototype

binaryrc5_decrypt_cbc(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$bin = rc5_decrypt_cbc($data, $key);
Platform Availability

HAVE_RC5

Table 3.229. Arguments and Return Values for rc5_decrypt_cbc()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

binary

Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.230. Exceptions thrown by rc5_decrypt_cbc()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC5-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_RC5 before calling this function.


3.8.27. rc5_decrypt_cbc_to_string()

Synopsis

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector. This function returns a string, for an equivalent function that decrypts to a binary object, see rc5_decrypt_cbc().

Prototype

stringrc5_decrypt_cbc_to_string(binary$encrypted_data, data$key, data$iv = defaultIV)

Example
$str = rc5_decrypt_cbc_to_string($data, $key);
Platform Availability

HAVE_RC5

Table 3.231. Arguments and Return Values for rc5_decrypt_cbc_to_string()

Argument Type

Return Type

Description

binary$encrypted_data, data$key, data$iv = defaultIV

string

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm using a variable-length key and an optional 8-byte initialization vector.


Table 3.232. Exceptions thrown by rc5_decrypt_cbc_to_string()

err

desc

PARAMETER-ERROR

missing data (string or binary) parameter to function, invalid data type (expecing string or binary)

RC5-DECRYPT-PARAM-ERROR

missing or invalid key parameter (ex: invalid size) or invalid initialization vector (less than 8 bytes, only raised if initialization vector present)

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_RC5 before calling this function.


There are no comments yet

Leave a Comment



?
? ?
?

 
Powered by TalkBack