C API Reference guide

Functions

Total number of functions: 7. Functions supported are:

crypt_set_output_type(type)
crypt_set_simple_mode(enable)
crypt_set_password(salt, password, vector_multiplier)
crypt_cleanup()
crypt_encrypt(block, size, id, new_size)
crypt_decrypt(block, size, id, new_size, read_size)
crypt_encrypt_file(filename1, filename2, salt, password, vector_multiplier)
crypt_decrypt_file(filename1, filename2, salt, password, vector_multiplier)

crypt_set_output_type

crypt_set_output_type(type)

[Since version 0.0.1]

This function is used to set type of output encoding.

@type [int]: type number, can be either OUTPUT_TYPE_BINARY (i.e. no encoding) or OUTPUT_TYPE_BASE64 to use base64 encoding
Returns: 0 for no error, otherwise error code (1 for unsupported encoding and 2 for enabling simple mode for non-binary encoding)

crypt_set_simple_mode

crypt_set_simple_mode(enable)

[Since version 0.0.1]

This function is used to enable or disable simple mode on the decryption phase. Simple mode is the mode where CRC-32 checking and read size checking are disabled. Other encoding than binary encoding cannot work in this mode..

@enable [int]: enable (1) or disable (0) simple mode checking code for decryption phase
Returns: 0 on success, 1 on error (trying to set simple mode on non-binary encoding)

crypt_set_password

crypt_set_password(salt, password, vector_multiplier)

[Since version 0.0.1]

This function is used to calculate initialization vectors (IV) from the password and salt values.

@salt [string]: salt value to be used for the IV generation
@password [string]: password to be used for IV generation
@vector_multiplier [int]: value to extend the vector by multiplicating it's size
Returns: None

crypt_cleanup

crypt_cleanup()

[Since version 0.0.1]

This function is used to cleanup all the memory allocated by crypt_set_password() function.

Returns: None

crypt_encrypt

crypt_encrypt(block, size, id, new_size)

[Since version 0.0.1]

Main function for the data encryption. Takes the block, size and id as input arguments with returning new size.

@block [buffer]: buffer of data to be encrypted/decrypted
@size [int]: size of buffer
@id [int]: identifier of the chunk to be encoded
@new_size [size_t]: output integer value for the output buffer size
Returns: output buffer of new_size bytes

crypt_decrypt

crypt_decrypt(block, size, id, new_size, read_size)

[Since version 0.0.1]

Main function for the data decryption. Takes the block, size and id as input arguments with returning both decrypted encoded and decrypted decoded (raw) size.

@block [buffer]: buffer of data to be encrypted/decrypted
@size [int]: size of buffer
@id [int]: identifier of the chunk to be encoded
@new_size [size_t]: output integer value for the output buffer size
@read_size [int]: output integer value for the decoded output buffer size (different from new_size in case of base64 encoding)
Returns: output buffer of read_size bytes

crypt_encrypt_file

crypt_encrypt_file(filename1, filename2, salt, password, vector_multiplier)

[Since version 0.0.1]

Function for the entire file encryption. Takes the input and output files, salt, password and vector_multiplier value.

@filename1 [string]: input (original) file
@filename2 [string]: output (encrypted) file
@salt [string]: salt value to be used, may be NULL to use already set IVs if applicable, used only with conjuction password
@password [string]: password value to be used, may be NULL to use already set IVs if applicable, used only with conjuction salt
@vector_multiplier [int]: vector multiplier value, can be 0, used only if salt and password are set
Returns: 0 for no error, otherwise error code

crypt_decrypt_file

crypt_decrypt_file(filename1, filename2, salt, password, vector_multiplier)

[Since version 0.0.1]

Function for the entire file decryption. Takes the input and output files, salt, password and vector_multiplier value.

@filename1 [string]: input (encrypted) file
@filename2 [string]: output (decrypted) file
@salt [string]: salt value to be used, may be NULL to use already set IVs if applicable, used only with conjuction password
@password [string]: password value to be used, may be NULL to use already set IVs if applicable, used only with conjuction salt
@vector_multiplier [int]: vector multiplier value, can be 0, used only if salt and password are set
Returns: 0 for no error, otherwise error code