bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
|
Functions | |
static int | bzrtp_getSelfZID_impl (void *dbPointer, const char *selfURI, uint8_t selfZID[12], bctbx_rng_context_t *RNGContext) |
int | bzrtp_getSelfZID (void *dbPointer, const char *selfURI, uint8_t selfZID[12], bctbx_rng_context_t *RNGContext) |
: retrieve ZID from cache ZID is randomly generated if cache is empty or inexistant ZID is randomly generated in case of cacheless implementation(db argument is NULL) | |
int | bzrtp_getSelfZID_lock (void *dbPointer, const char *selfURI, uint8_t selfZID[12], bctbx_rng_context_t *RNGContext, bctbx_mutex_t *zidCacheMutex) |
: retrieve ZID from cache ZID is randomly generated if cache is empty or inexistant ZID is randomly generated in case of cacheless implementation(db argument is NULL) this version of the function gets a mutex to lock the cache when accessing it | |
int | bzrtp_getPeerAssociatedSecrets (bzrtpContext_t *context, uint8_t peerZID[12]) |
Parse the cache to find secrets associated to the given ZID, set them and their length in the context if they are found Note: this function also retrieve zuid(set in the context) wich allow successive calls to cache operation to be faster. | |
int | bzrtp_cache_write_active (bzrtpContext_t *context, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) |
This is a convenience wrapper to the bzrtp_cache_write function which will also take care of setting the ziduri table 'active' flag to one for the current row and reset all other rows with matching peeruri. | |
int | bzrtp_cache_write (void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) |
Write(insert or update) data in cache, adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be inserted, lengths of theses values All three arrays must be the same lenght: columnsCount If the row isn't present in the given table, it will be inserted. | |
int | bzrtp_cache_write_lock (void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount, bctbx_mutex_t *zidCacheMutex) |
Write(insert or update) data in cache, adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be inserted, lengths of theses values All three arrays must be the same lenght: columnsCount If the row isn't present in the given table, it will be inserted this version of the function gets a mutex to lock the cache when accessing it. | |
int | bzrtp_cache_read (void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount) |
Read data from specified table/columns from cache adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be read, and the number of colums to be read Produce an array of values(uint8_t arrays) and a array of corresponding lengths Values memory is allocated by this function and must be freed by caller. | |
int | bzrtp_cache_read_lock (void *dbPointer, int zuid, const char *tableName, const char **columns, uint8_t **values, size_t *lengths, uint8_t columnsCount, bctbx_mutex_t *zidCacheMutex) |
Read data from specified table/columns from cache adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be read, and the number of colums to be read Produce an array of values(uint8_t arrays) and a array of corresponding lengths Values memory is allocated by this function and must be freed by caller this version of the function gets a mutex to lock the cache when accessing it. | |
int | bzrtp_cache_migration (void *cacheXml, void *cacheSqlite, const char *selfURI) |
Perform migration from xml version to sqlite3 version of cache Warning: new version of cache associate a ZID to each local URI, the old one did not the migration function will associate any data in the cache to the sip URI given in parameter which shall be the default URI. | |
int | bzrtp_cache_getPeerStatus_lock (void *dbPointer, const char *peerURI, bctbx_mutex_t *zidCacheMutex) |
Retrieve from bzrtp cache the trust status(based on the previously verified flag) of a peer URI. | |
int | bzrtp_cache_getZuid (void *dbPointer, const char *selfURI, const char *peerURI, const uint8_t peerZID[12], const uint8_t insertFlag, int *zuid, bctbx_mutex_t *zidCacheMutex) |
int bzrtp_cache_getPeerStatus_lock | ( | void * | dbPointer, |
const char * | peerURI, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
Retrieve from bzrtp cache the trust status(based on the previously verified flag) of a peer URI.
This function will return the SAS validation status of the active device associated to the given peerURI.
Important note about the active device:
This function is intended for use in a mono-device environment.
[in] | dbPointer | Pointer to an already opened sqlite db |
[in] | peerURI | The peer sip:uri we're interested in |
[in] | zidCacheMutex | Points to a mutex used to lock zidCache database access, ignored if NULL |
int bzrtp_cache_getZuid | ( | void * | dbPointer, |
const char * | selfURI, | ||
const char * | peerURI, | ||
const uint8_t | peerZID[12], | ||
const uint8_t | insertFlag, | ||
int * | zuid, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
int bzrtp_cache_migration | ( | void * | cacheXmlPtr, |
void * | cacheSqlite, | ||
const char * | selfURI | ||
) |
Perform migration from xml version to sqlite3 version of cache Warning: new version of cache associate a ZID to each local URI, the old one did not the migration function will associate any data in the cache to the sip URI given in parameter which shall be the default URI.
[in] | cacheXmlPtr | a pointer to an xmlDocPtr structure containing the old cache to be migrated |
[in,out] | cacheSqlite | a pointer to an sqlite3 structure containing a cache initialised using bzrtp_cache_init function |
[in] | selfURI | default sip URI for this end point, NULL terminated char |
int bzrtp_cache_read | ( | void * | dbPointer, |
int | zuid, | ||
const char * | tableName, | ||
const char ** | columns, | ||
uint8_t ** | values, | ||
size_t * | lengths, | ||
uint8_t | columnsCount | ||
) |
Read data from specified table/columns from cache adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be read, and the number of colums to be read Produce an array of values(uint8_t arrays) and a array of corresponding lengths Values memory is allocated by this function and must be freed by caller.
[in,out] | dbPointer | Pointer to an already opened sqlite db |
[in] | zuid | The DB internal id to adress the correct row(binding between local uri and peer ZID+URI) |
[in] | tableName | The name of the table to read in the db. Null terminated string |
[in] | columns | An array of null terminated strings containing the name of the columns to read, the array's length is columnsCount |
[out] | values | An array of uint8_t pointers, each one will be allocated to the read value and they must be freed by caller |
[out] | lengths | An array of integer containing the lengths of values array buffer read |
[in] | columnsCount | length common to columns,values and lengths arrays |
int bzrtp_cache_read_lock | ( | void * | dbPointer, |
int | zuid, | ||
const char * | tableName, | ||
const char ** | columns, | ||
uint8_t ** | values, | ||
size_t * | lengths, | ||
uint8_t | columnsCount, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
Read data from specified table/columns from cache adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be read, and the number of colums to be read Produce an array of values(uint8_t arrays) and a array of corresponding lengths Values memory is allocated by this function and must be freed by caller this version of the function gets a mutex to lock the cache when accessing it.
[in,out] | dbPointer | Pointer to an already opened sqlite db |
[in] | zuid | The DB internal id to adress the correct row(binding between local uri and peer ZID+URI) |
[in] | tableName | The name of the table to read in the db. Null terminated string |
[in] | columns | An array of null terminated strings containing the name of the columns to read, the array's length is columnsCount |
[out] | values | An array of uint8_t pointers, each one will be allocated to the read value and they must be freed by caller |
[out] | lengths | An array of integer containing the lengths of values array buffer read |
[in] | columnsCount | length common to columns,values and lengths arrays |
[in] | zidCacheMutex | Points to a mutex used to lock zidCache database access, ignored if NULL |
int bzrtp_cache_write | ( | void * | dbPointer, |
int | zuid, | ||
const char * | tableName, | ||
const char ** | columns, | ||
uint8_t ** | values, | ||
size_t * | lengths, | ||
uint8_t | columnsCount | ||
) |
Write(insert or update) data in cache, adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be inserted, lengths of theses values All three arrays must be the same lenght: columnsCount If the row isn't present in the given table, it will be inserted.
[in,out] | dbPointer | Pointer to an already opened sqlite db |
[in] | zuid | The DB internal id to adress the correct row(binding between local uri and peer ZID+URI) |
[in] | tableName | The name of the table to write in the db, must already exists. Null terminated string |
[in] | columns | An array of null terminated strings containing the name of the columns to update |
[in] | values | An array of buffers containing the values to insert/update matching the order of columns array |
[in] | lengths | An array of integer containing the lengths of values array buffer matching the order of columns array |
[in] | columnsCount | length common to columns,values and lengths arrays |
int bzrtp_cache_write_active | ( | bzrtpContext_t * | context, |
const char * | tableName, | ||
const char ** | columns, | ||
uint8_t ** | values, | ||
size_t * | lengths, | ||
uint8_t | columnsCount | ||
) |
This is a convenience wrapper to the bzrtp_cache_write function which will also take care of setting the ziduri table 'active' flag to one for the current row and reset all other rows with matching peeruri.
Write(insert or update) data in cache, adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be inserted, lengths of theses values All three arrays must be the same lenght: columnsCount If the row isn't present in the given table, it will be inserted
[in,out] | context | the current context, used to get the cache db pointer, zuid and cache mutex |
[in] | tableName | The name of the table to write in the db, must already exists. Null terminated string |
[in] | columns | An array of null terminated strings containing the name of the columns to update |
[in] | values | An array of buffers containing the values to insert/update matching the order of columns array |
[in] | lengths | An array of integer containing the lengths of values array buffer matching the order of columns array |
[in] | columnsCount | length common to columns,values and lengths arrays |
int bzrtp_cache_write_lock | ( | void * | dbPointer, |
int | zuid, | ||
const char * | tableName, | ||
const char ** | columns, | ||
uint8_t ** | values, | ||
size_t * | lengths, | ||
uint8_t | columnsCount, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
Write(insert or update) data in cache, adressing it by zuid (ZID/URI binding id used in cache) Get arrays of column names, values to be inserted, lengths of theses values All three arrays must be the same lenght: columnsCount If the row isn't present in the given table, it will be inserted this version of the function gets a mutex to lock the cache when accessing it.
[in,out] | dbPointer | Pointer to an already opened sqlite db |
[in] | zuid | The DB internal id to adress the correct row(binding between local uri and peer ZID+URI) |
[in] | tableName | The name of the table to write in the db, must already exists. Null terminated string |
[in] | columns | An array of null terminated strings containing the name of the columns to update |
[in] | values | An array of buffers containing the values to insert/update matching the order of columns array |
[in] | lengths | An array of integer containing the lengths of values array buffer matching the order of columns array |
[in] | columnsCount | length common to columns,values and lengths arrays |
[in] | zidCacheMutex | Points to a mutex used to lock zidCache database access, ignored if NULL |
int bzrtp_getPeerAssociatedSecrets | ( | bzrtpContext_t * | context, |
uint8_t | peerZID[12] | ||
) |
Parse the cache to find secrets associated to the given ZID, set them and their length in the context if they are found Note: this function also retrieve zuid(set in the context) wich allow successive calls to cache operation to be faster.
[in,out] | context | the current context, used to get the cache db pointer, self and peer URI and store results |
[in] | peerZID | a byte array of the peer ZID |
return 0 on succes, error code otherwise
int bzrtp_getSelfZID | ( | void * | db, |
const char * | selfURI, | ||
uint8_t | selfZID[12], | ||
bctbx_rng_context_t * | RNGContext | ||
) |
: retrieve ZID from cache ZID is randomly generated if cache is empty or inexistant ZID is randomly generated in case of cacheless implementation(db argument is NULL)
[in,out] | db | sqlite3 database(or NULL if we don't use cache at runtime) Use a void * to keep this API when building cacheless |
[in] | selfURI | the sip uri of local user, NULL terminated string |
[out] | selfZID | the ZID, retrieved from cache or randomly generated |
[in] | RNGContext | A RNG context used to generate ZID if needed |
|
static |
int bzrtp_getSelfZID_lock | ( | void * | db, |
const char * | selfURI, | ||
uint8_t | selfZID[12], | ||
bctbx_rng_context_t * | RNGContext, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
: retrieve ZID from cache ZID is randomly generated if cache is empty or inexistant ZID is randomly generated in case of cacheless implementation(db argument is NULL) this version of the function gets a mutex to lock the cache when accessing it
[in,out] | db | sqlite3 database(or NULL if we don't use cache at runtime) Use a void * to keep this API when building cacheless |
[in] | selfURI | the sip uri of local user, NULL terminated string |
[out] | selfZID | the ZID, retrieved from cache or randomly generated |
[in] | RNGContext | A RNG context used to generate ZID if needed |
[in] | zidCacheMutex | Points to a mutex used to lock zidCache database access, ignored if NULL |