SEcube open-source SDK
Sekey_other_functions

Other functions of SEkey

These functions are used by SEkey for internal purposes but they can also be used by higher levels if needed. Always check the documentation and the source code before using them.

time_t sekey_gettime ()
 SEkey interface to retrieve the timestamp to be set for any KMS need. This API should be customized in order to meet the security requirements of the environment integrating the SEcube. The basic version simply retrieves the current system time, a customized version may require to get the time from an authoritative time server.
 
int sekey_update_userdata ()
 Synchronize the data of SEkey stored on the SEcube of the user with the data stored on the SEcube of the administrator. Available only for the users. More...
 
int sekey_check_expired_keys ()
 Check for expired keys inside SEkey. Expired keys which are still flagged as active will be deactivated. More...
 
int sekey_recovery_request (std::string &user_id, std::string &serial_number)
 Explicitly request to SEkey to execute the recovery procedure for a specific user, given his serial number. Available only for the administrator. More...
 
std::string epoch_to_localtime (time_t t)
 Convert an integer (epoch time) to the local time as readable string. More...
 
std::string cryptoperiod_to_days (uint32_t n)
 Convert an integer to number of days, hours, minutes and seconds into a readable string. More...
 
uint32_t stoul_wrap (std::string &s)
 Wrapper around stoul() function. More...
 
std::string statusmap (se_key_status s)
 Convert a key status to the corresponding string. May throw exceptions.
 
std::string keytypemap (se_key_type t)
 Convert a key type to the corresponding string.
 
std::string algomap (uint32_t algorithm)
 Map an algorithm (expressed as integer) to the corresponding algorithm expressed as string. More...
 
uint32_t algolen (uint32_t algorithm)
 Return the length (in byte) of the key, given the algorithm. Return 0 if algorithm is unknown.
 

Detailed Description

Function Documentation

◆ algomap()

std::string algomap ( uint32_t  algo)

Map an algorithm (expressed as integer) to the corresponding algorithm expressed as string.

Parameters
[in]algoThe algorithm to be mapped.
Returns
The string of the corresponding algorithm. May throw exceptions.

◆ cryptoperiod_to_days()

std::string cryptoperiod_to_days ( uint32_t  n)

Convert an integer to number of days, hours, minutes and seconds into a readable string.

Parameters
[in]nThe integer to be converted into days, hours, minutes, seconds format.
Returns
The string with the integer converted to the required format.

◆ epoch_to_localtime()

std::string epoch_to_localtime ( time_t  t)

Convert an integer (epoch time) to the local time as readable string.

Parameters
[in]tThe epoch time to be converted.
Returns
The string with the epoch time converted to local time.

◆ sekey_check_expired_keys()

int sekey_check_expired_keys ( )

Check for expired keys inside SEkey. Expired keys which are still flagged as active will be deactivated.

Returns
Returns SEKEY_OK upon success, a value from sekey_error otherwise. This API will be run automatically by many APIs of the KMS and of SEfile; it can be used also inside the higher level application if needed.

◆ sekey_recovery_request()

int sekey_recovery_request ( std::string &  user_id,
std::string &  serial_number 
)

Explicitly request to SEkey to execute the recovery procedure for a specific user, given his serial number. Available only for the administrator.

Parameters
[in]user_idThe ID of the user who needs to recovery his database.
[in]serial_numberThe serial number assigned to the SEcube of the user.
Returns
Returns SEKEY_OK upon success, a value from sekey_error otherwise. This API is useful when the user requests to the administrator a recovery, possibly because the user is not able to complete successfully the SEkey update. So the administrator can satisfy the request of the specific user running this API. Notice that this API has been written in order to be called explicitly by the higher level application which is expected to handle the communication between users and administrator (out of bound, with a server in the middle, a message broker or something else).

◆ sekey_update_userdata()

int sekey_update_userdata ( )

Synchronize the data of SEkey stored on the SEcube of the user with the data stored on the SEcube of the administrator. Available only for the users.

Returns
Returns SEKEY_OK upon success, a value from sekey_error otherwise.

This function updates the data of SEkey stored inside the SEcube of a user fetching the latest updates prepared for him by the administrator. If the update fails the KMS for the user is blocked until the update is completed or a full recovery of the data is performed.

◆ stoul_wrap()

uint32_t stoul_wrap ( std::string &  s)

Wrapper around stoul() function.

Parameters
[in]sThe string to convert to integer.
Returns
The string converted into the corresponding integer if the integer fits in 32 bits unsigned.

This wrapper is used to avoid stoul() returning values bigger than UINT32_MAX. If the converted value does not fit in 32 bits, this function throws an out of range exception.