SEcube open-source SDK
Sefile_internal_functions

Functions for internal purposes of SEfile

You should not need to use these functions directly because they are used internally by the SEfile library.

uint16_t SEfile::secure_create (char *path, std::shared_ptr< SEFILE_HANDLE > hFile, int mode)
 This function creates a new secure file managed with SEfile. If the file already exists, it is overwritten with an empty one, all previous data are lost. More...
 
uint16_t SEfile::secure_key_check (uint16_t direction)
 This function is used to check if the key setup in the SEfile object can be used to encrypt or decrypt data. More...
 
uint16_t SEfile::get_filesize (uint32_t *length)
 This function is used to compute the total logic size of a file that is already open within a SEfile object. More...
 
uint16_t SEfile::crypt_header (void *buff1, void *buff2, size_t datain_len, uint16_t direction)
 This function encrypts a header buffer by exploiting the functions provided by L1.h. More...
 
uint16_t SEfile::crypt_sectors (void *buff_decrypt, void *buff_crypt, size_t datain_len, size_t current_offset, uint8_t *nonce_ctr, uint8_t *nonce_pbkdf2)
 This function encrypts the buff_decrypt data by exploiting the functions provided by L1.h. More...
 
uint16_t SEfile::decrypt_sectors (void *buff_crypt, void *buff_decrypt, size_t datain_len, size_t current_offset, uint8_t *nonce_ctr, uint8_t *nonce_pbkdf2)
 This function decrypts the buff_crypt data by exploiting the functions provided by L1.h. More...
 

Detailed Description

Function Documentation

◆ crypt_header()

uint16_t SEfile::crypt_header ( void *  buff1,
void *  buff2,
size_t  datain_len,
uint16_t  direction 
)

This function encrypts a header buffer by exploiting the functions provided by L1.h.

Parameters
[in]buff1Pointer to the header we want to encrypt/decrypt.
[out]buff2Pointer to an allocated header where to store the result.
[in]datain_lenHow big is the amount of data.
[in]directionSee SE3_DIR.
Returns
The function returns 0 in case of success. See error values for error list.

◆ crypt_sectors()

uint16_t SEfile::crypt_sectors ( void *  buff_decrypt,
void *  buff_crypt,
size_t  datain_len,
size_t  current_offset,
uint8_t *  nonce_ctr,
uint8_t *  nonce_pbkdf2 
)

This function encrypts the buff_decrypt data by exploiting the functions provided by L1.h.

Parameters
[in]buff_decryptThe plaintext data to be encrypted
[out]buff_cryptThe preallocated buffer where to store the encrypted data.
[in]datain_lenSpecify how many data we want to encrypt.
[in]current_offsetCurrent position inside the file expressed as number of cipher blocks
[in]nonce_ctrInitialization vector, see SEFILE_HEADER
[in]nonce_pbkdf2Initialization vector, see SEFILE_HEADER
Returns
The function returns 0 in case of success. See error values for error list.

◆ decrypt_sectors()

uint16_t SEfile::decrypt_sectors ( void *  buff_crypt,
void *  buff_decrypt,
size_t  datain_len,
size_t  current_offset,
uint8_t *  nonce_ctr,
uint8_t *  nonce_pbkdf2 
)

This function decrypts the buff_crypt data by exploiting the functions provided by L1.h.

Parameters
[in]buff_cryptThe cipher text data to be decrypted
[out]buff_decryptThe preallocated buffer where to store the decrypted data.
[in]datain_lenSpecify how many data we want to decrypt.
[in]current_offsetCurrent position inside the file expressed as number of cipher blocks
[in]nonce_ctrInitialization vector, see SEFILE_HEADER
[in]nonce_pbkdf2Initialization vector, see SEFILE_HEADER
Returns
The function returns 0 in case of success. See error values for error list.

◆ get_filesize()

uint16_t SEfile::get_filesize ( uint32_t *  length)

This function is used to compute the total logic size of a file that is already open within a SEfile object.

Parameters
[out]lengthWhere the logic size of the file is stored.
Returns
The function returns 0 in case of success. See error values for error list. This function works as SEfile::secure_getfilesize().

◆ secure_create()

uint16_t SEfile::secure_create ( char *  path,
std::shared_ptr< SEFILE_HANDLE hFile,
int  mode 
)

This function creates a new secure file managed with SEfile. If the file already exists, it is overwritten with an empty one, all previous data are lost.

Parameters
[in]pathSpecify the absolute/relative path where to create the file. No encrypted directory are allowed inside the path.
[out]hFileThe pointer in which the file handle to the new opened file is placed after a success, NULL in case of failure.
[in]modeThe mode in which the file should be created. See mode parameter for secure_open.
Returns
The function returns 0 in case of success. See error values for error list.

You do not need to call this function explicitly. Use secure_open() instead.

◆ secure_key_check()

uint16_t SEfile::secure_key_check ( uint16_t  direction)

This function is used to check if the key setup in the SEfile object can be used to encrypt or decrypt data.

Parameters
[in]directionCheck if the key can be used for encryption or decryption.
Returns
The function returns 0 in case of success. See error values for error list. This function works as SEfile::secure_getfilesize().