bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
Loading...
Searching...
No Matches
Macros | Functions
zidCache.h File Reference

Go to the source code of this file.

Macros

#define BZRTP_ZIDCACHE_DONT_INSERT_ZUID   0
 get the cache internal id used to bind local uri(hence local ZID associated to it)<->peer uri/peer ZID. Providing a valid local URI(already present in cache), a peer ZID and peer URI will return the zuid creating it if needed and requested Any pair ZID/sipURI shall identify an account on a device.
 
#define BZRTP_ZIDCACHE_INSERT_ZUID   1
 

Functions

BZRTP_EXPORT 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.
 
BZRTP_EXPORT 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)
 
BZRTP_EXPORT 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.
 

Macro Definition Documentation

◆ BZRTP_ZIDCACHE_DONT_INSERT_ZUID

#define BZRTP_ZIDCACHE_DONT_INSERT_ZUID   0

get the cache internal id used to bind local uri(hence local ZID associated to it)<->peer uri/peer ZID. Providing a valid local URI(already present in cache), a peer ZID and peer URI will return the zuid creating it if needed and requested Any pair ZID/sipURI shall identify an account on a device.

Parameters
[in,out]dbPointerthe opened sqlite database pointer
[in]selfURIlocal URI, must be already associated to a ZID in the DB(association is performed by any call of getSelfZID on this URI)
[in]peerURIpeer URI
[in]peerZIDpeer ZID
[in]insertFlagA boolean managing insertion or not of a new row:
  • BZRTP_ZIDCACHE_DONT_INSERT_ZUID : if not found identity binding won't lead to insertion and return zuid will be 0
  • BZRTP_ZIDCACHE_INSERT_ZUID : if not found, insert a new row in ziduri table and return newly inserted zuid
[out]zuidthe internal db reference to the data row matching this particular pair of correspondant if identity binding is not found and insertFlag set to 0, this value is set to 0
[in]zidCacheMutexPoints to a mutex used to lock zidCache database access, ignored if NULL
Returns
0 on success, BZRTP_ERROR_CACHE_PEERNOTFOUND if peer was not in and the insert flag is not set to BZRTP_ZIDCACHE_INSERT_ZUID, error code otherwise

◆ BZRTP_ZIDCACHE_INSERT_ZUID

#define BZRTP_ZIDCACHE_INSERT_ZUID   1

Function Documentation

◆ bzrtp_cache_getZuid()

BZRTP_EXPORT 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 
)

◆ bzrtp_cache_write_active()

BZRTP_EXPORT 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

Parameters
[in,out]contextthe current context, used to get the cache db pointer, zuid and cache mutex
[in]tableNameThe name of the table to write in the db, must already exists. Null terminated string
[in]columnsAn array of null terminated strings containing the name of the columns to update
[in]valuesAn array of buffers containing the values to insert/update matching the order of columns array
[in]lengthsAn array of integer containing the lengths of values array buffer matching the order of columns array
[in]columnsCountlength common to columns,values and lengths arrays
Returns
0 on succes, error code otherwise

◆ bzrtp_getPeerAssociatedSecrets()

BZRTP_EXPORT 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.

Parameters
[in,out]contextthe current context, used to get the cache db pointer, self and peer URI and store results
[in]peerZIDa byte array of the peer ZID

return 0 on succes, error code otherwise