bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
|
Macros | |
#define | BZRTP_ERROR_INVALIDCHANNELCONTEXT 0x8001 |
Functions | |
static int | bzrtp_initChannelContext (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, uint32_t selfSSRC, uint8_t isMain) |
Initialise the context of a channel and create and store the Hello packet Initialise some vectors. | |
static void | bzrtp_destroyChannelContext (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext) |
Destroy the context of a channel Free allocated buffers, destroy keys. | |
static bzrtpChannelContext_t * | getChannelContext (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Look in the given ZRTP context for a channel referenced with given SSRC. | |
static uint8_t | copyCryptoTypes (uint8_t destination[7], uint8_t source[7], uint8_t size) |
bzrtpContext_t * | bzrtp_createBzrtpContext (void) |
int | bzrtp_setZIDCache (bzrtpContext_t *context, void *zidCache, const char *selfURI, const char *peerURI) |
Set the pointer allowing cache access. | |
int | bzrtp_setZIDCache_lock (bzrtpContext_t *context, void *zidCache, const char *selfURI, const char *peerURI, bctbx_mutex_t *zidCacheMutex) |
Set the pointer allowing cache access, this version of the function get a mutex to lock the cache when accessing it. | |
int | bzrtp_initBzrtpContext (bzrtpContext_t *context, uint32_t selfSSRC) |
Perform some initialisation which can't be done without some callback functions: This function is called once per session when the first channel is created. It must be called after the cache access pointer have been set. | |
int | bzrtp_destroyBzrtpContext (bzrtpContext_t *context, uint32_t selfSSRC) |
int | bzrtp_setCallbacks (bzrtpContext_t *context, const bzrtpCallbacks_t *cbs) |
Allocate a function pointer to the callback function identified by his id. | |
int | bzrtp_addChannel (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Add a channel to an existing context, this can be done only if the first channel has concluded a DH key agreement. | |
int | bzrtp_startChannelEngine (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Start the state machine of the specified channel To be able to start an addional channel, we must be in secure state. | |
int | bzrtp_iterate (bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint64_t timeReference) |
Send the current time to a specified channel, it will check if it has to trig some timer. | |
int | bzrtp_setClientData (bzrtpContext_t *zrtpContext, uint32_t selfSSRC, void *clientData) |
Set the client data pointer in a channel context This pointer is returned to the client by the callbacks function, used to store associated contexts (RTP session) | |
int | bzrtp_processMessage (bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8_t *zrtpPacketString, uint16_t zrtpPacketStringLength) |
Process a received message. | |
void | bzrtp_SASVerified (bzrtpContext_t *zrtpContext) |
Called by user when the SAS has been verified. | |
void | bzrtp_resetSASVerified (bzrtpContext_t *zrtpContext) |
Called by user when the SAS has been set to unverified. | |
int | bzrtp_exportKey (bzrtpContext_t *zrtpContext, char *label, size_t labelLength, uint8_t *derivedKey, size_t *derivedKeyLength) |
int | bzrtp_resetRetransmissionTimer (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Reset the retransmission timer of a given channel. Packets will be sent again if appropriate: | |
uint8_t | bzrtp_getSupportedCryptoTypes (bzrtpContext_t *zrtpContext, uint8_t algoType, uint8_t supportedTypes[7]) |
Get the supported crypto types. | |
int | bzrtp_setSupportedCryptoTypes (bzrtpContext_t *zrtpContext, uint8_t algoType, uint8_t supportedTypes[7], uint8_t supportedTypesCount) |
set the supported crypto types | |
int | bzrtp_setFlags (bzrtpContext_t *zrtpContext, uint8_t flagId, uint8_t value) |
Set the selfAcceptGoClear flag. | |
int | bzrtp_setPeerHelloHash (bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8_t *peerHelloHashHexString, size_t peerHelloHashHexStringLength) |
Set the peer hello hash given by signaling to a ZRTP channel. | |
int | bzrtp_getSelfHelloHash (bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8_t *output, size_t outputLength) |
Get the self hello hash from ZRTP channel. | |
int | bzrtp_setAuxiliarySharedSecret (bzrtpContext_t *zrtpContext, const uint8_t *auxSecret, size_t auxSecretLength) |
Set Auxiliary Secret for this channel(shall be used only on primary audio channel) The given auxSecret is appended to any aux secret found in ZIDcache This function must be called before reception of peerHello packet. | |
uint8_t | bzrtp_getAuxiliarySharedSecretMismatch (bzrtpContext_t *zrtpContext) |
Get the ZRTP auxiliary shared secret mismatch status. | |
int | bzrtp_getChannelStatus (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Get the channel status. | |
const char * | bzrtp_algoToString (uint8_t algo) |
Retrieve the name of the algo in string. | |
int | bzrtp_set_MTU (bzrtpContext_t *zrtpContext, size_t mtu) |
set the maximum size of a ZRTP packet generated locally MTU must be at least 600 bytes to avoid useless fragmentation of small packets | |
size_t | bzrtp_get_MTU (bzrtpContext_t *zrtpContext) |
get the maximum size of a ZRTP packet generated locally | |
int | bzrtp_sendGoClear (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Create a GoClear event and send it to the state machine The user is in secure state. He decided to change his encryption mode by clicking on a button for example. The end point continues to send SRTP packets. On ClearACK reception the end point deletes all key materials. | |
int | bzrtp_confirmGoClear (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Create a acceptGoClear event and send it to the state machine The user received a valid GoClear packet and sent a ClearACK message (so the end point stops to send SRTP packets). He agrees to change the encryption mode by clicking on a button for example. The the sending of RTP packets may begin. | |
int | bzrtp_backToSecureMode (bzrtpContext_t *zrtpContext, uint32_t selfSSRC) |
Create a BackToSecure event and send it to the state machine The user has a clear channel. He decided to resume the secure mode by clicking on a button for example. | |
#define BZRTP_ERROR_INVALIDCHANNELCONTEXT 0x8001 |
int bzrtp_addChannel | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Add a channel to an existing context, this can be done only if the first channel has concluded a DH key agreement.
Add a channel to an existing context.
[in,out] | zrtpContext | The zrtp context who will get the additionnal channel. Must be in secure state. |
[in] | selfSSRC | The SSRC given to the channel context |
const char * bzrtp_algoToString | ( | uint8_t | algo | ) |
Retrieve the name of the algo in string.
[in] | algo | Id of the algo |
int bzrtp_backToSecureMode | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Create a BackToSecure event and send it to the state machine The user has a clear channel. He decided to resume the secure mode by clicking on a button for example.
zrtpContext | The ZRTP context we're dealing with |
selfSSRC | The SSRC identifying the channel |
int bzrtp_confirmGoClear | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Create a acceptGoClear event and send it to the state machine The user received a valid GoClear packet and sent a ClearACK message (so the end point stops to send SRTP packets). He agrees to change the encryption mode by clicking on a button for example. The the sending of RTP packets may begin.
[in] | context | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel |
bzrtpContext_t * bzrtp_createBzrtpContext | ( | void | ) |
Create context structure and initialise it
int bzrtp_destroyBzrtpContext | ( | bzrtpContext_t * | context, |
uint32_t | selfSSRC | ||
) |
Free memory of context structure to a channel, if all channels are freed, free the global zrtp context
[in] | context | Context hosting the channel to be destroyed.(note: the context zrtp context itself is destroyed with the last channel) |
[in] | selfSSRC | The SSRC identifying the channel to be destroyed |
|
static |
Destroy the context of a channel Free allocated buffers, destroy keys.
[in] | zrtpContext | The zrtpContext hosting this channel, needed to acces the RNG |
[in] | zrtpChannelContext | The channel context to be destroyed |
int bzrtp_exportKey | ( | bzrtpContext_t * | zrtpContext, |
char * | label, | ||
size_t | labelLength, | ||
uint8_t * | derivedKey, | ||
size_t * | derivedKeyLength | ||
) |
size_t bzrtp_get_MTU | ( | bzrtpContext_t * | zrtpContext | ) |
get the maximum size of a ZRTP packet generated locally
[in] | zrtpContext | The ZRTP context we're dealing with |
uint8_t bzrtp_getAuxiliarySharedSecretMismatch | ( | bzrtpContext_t * | zrtpContext | ) |
Get the ZRTP auxiliary shared secret mismatch status.
[in] | zrtpContext | The ZRTP context we're dealing with |
int bzrtp_getChannelStatus | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Get the channel status.
[in] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel |
int bzrtp_getSelfHelloHash | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC, | ||
uint8_t * | output, | ||
size_t | outputLength | ||
) |
Get the self hello hash from ZRTP channel.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel |
[out] | output | A NULL terminated string containing the hexadecimal form of the hash received in signaling, contain ZRTP version as header. Buffer must be allocated by caller. |
[in] | outputLength | Length of output buffer, shall be at least 70 : 5 chars for version, 64 for the hash itself, SHA256), NULL termination |
uint8_t bzrtp_getSupportedCryptoTypes | ( | bzrtpContext_t * | zrtpContext, |
uint8_t | algoType, | ||
uint8_t | supportedTypes[7] | ||
) |
Get the supported crypto types.
[in] | zrtpContext | The ZRTP context we're dealing with |
[in] | algoType | mapped to defines, must be in [ZRTP_HASH_TYPE, ZRTP_CIPHERBLOCK_TYPE, ZRTP_AUTHTAG_TYPE, ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE] |
[out] | supportedTypes | mapped to uint8_t value of the 4 char strings giving the supported types as string according to rfc section 5.1.2 to 5.1.6 |
int bzrtp_initBzrtpContext | ( | bzrtpContext_t * | context, |
uint32_t | selfSSRC | ||
) |
Perform some initialisation which can't be done without some callback functions: This function is called once per session when the first channel is created. It must be called after the cache access pointer have been set.
Perform initialisation which can't be done without ZIDcache acces.
[in] | context | The context to initialise |
[in] | selfSSRC | SSRC of the first channel |
|
static |
Initialise the context of a channel and create and store the Hello packet Initialise some vectors.
[in] | zrtpContext | The zrtpContext hosting this channel, needed to acces the RNG |
[out] | zrtpChannelContext | The channel context to be initialised |
[in] | selfSSRC | The SSRC allocated to this channel |
[in] | isMain | This channel is channel 0 or an additional channel |
int bzrtp_iterate | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC, | ||
uint64_t | timeReference | ||
) |
Send the current time to a specified channel, it will check if it has to trig some timer.
[in,out] | zrtpContext | The ZRTP context hosting the channel |
[in] | selfSSRC | The SSRC identifying the channel |
[in] | timeReference | The current time in ms |
int bzrtp_processMessage | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC, | ||
uint8_t * | zrtpPacketString, | ||
uint16_t | zrtpPacketStringLength | ||
) |
Process a received message.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel receiving the message |
[in] | zrtpPacketString | The packet received |
[in] | zrtpPacketStringLength | Length of the packet in bytes |
int bzrtp_resetRetransmissionTimer | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Reset the retransmission timer of a given channel. Packets will be sent again if appropriate:
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel to reset |
void bzrtp_resetSASVerified | ( | bzrtpContext_t * | zrtpContext | ) |
Called by user when the SAS has been set to unverified.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
void bzrtp_SASVerified | ( | bzrtpContext_t * | zrtpContext | ) |
Called by user when the SAS has been verified.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
int bzrtp_sendGoClear | ( | bzrtpContext_t * | context, |
uint32_t | selfSSRC | ||
) |
Create a GoClear event and send it to the state machine The user is in secure state. He decided to change his encryption mode by clicking on a button for example. The end point continues to send SRTP packets. On ClearACK reception the end point deletes all key materials.
[in] | context | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel |
int bzrtp_set_MTU | ( | bzrtpContext_t * | zrtpContext, |
size_t | mtu | ||
) |
set the maximum size of a ZRTP packet generated locally MTU must be at least 600 bytes to avoid useless fragmentation of small packets
[in] | zrtpContext | The ZRTP context we're dealing with |
[in] | mtu | The size in bytes of the maximum allowed for a ZRTP packet. If this parameter is less than 600, the actual MTU is set to 600 |
int bzrtp_setAuxiliarySharedSecret | ( | bzrtpContext_t * | zrtpContext, |
const uint8_t * | auxSecret, | ||
size_t | auxSecretLength | ||
) |
Set Auxiliary Secret for this channel(shall be used only on primary audio channel) The given auxSecret is appended to any aux secret found in ZIDcache This function must be called before reception of peerHello packet.
[in] | zrtpContext | The ZRTP context we're dealing with |
[in] | auxSecret | A buffer holding the auxiliary shared secret to use (see RFC 6189 section 4.3) |
[in] | auxSecretLength | lenght of the previous buffer |
int bzrtp_setCallbacks | ( | bzrtpContext_t * | context, |
const bzrtpCallbacks_t * | cbs | ||
) |
Allocate a function pointer to the callback function identified by his id.
[in,out] | context | The zrtp context to set the callback function |
[in] | cbs | A structure containing all the callbacks to supply. |
int bzrtp_setClientData | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC, | ||
void * | clientData | ||
) |
Set the client data pointer in a channel context This pointer is returned to the client by the callbacks function, used to store associated contexts (RTP session)
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel to be linked to the client Data |
[in] | clientData | The clientData pointer, casted to a (void *) |
int bzrtp_setFlags | ( | bzrtpContext_t * | zrtpContext, |
uint8_t | flagId, | ||
uint8_t | value | ||
) |
Set the selfAcceptGoClear flag.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | flagId | mapped to defines, must be BZRTP_SELF_ACCEPT_GOCLEAR |
[in] | value | Flag value |
int bzrtp_setPeerHelloHash | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC, | ||
uint8_t * | peerHelloHashHexString, | ||
size_t | peerHelloHashHexStringLength | ||
) |
Set the peer hello hash given by signaling to a ZRTP channel.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | selfSSRC | The SSRC identifying the channel |
[out] | peerHelloHashHexString | A NULL terminated string containing the hexadecimal form of the hash received in signaling, may contain ZRTP version as header. |
[in] | peerHelloHashHexStringLength | Length of hash string (shall be at least 64 as the hash is a SHA256 so 32 bytes, more if it contains the version header) |
int bzrtp_setSupportedCryptoTypes | ( | bzrtpContext_t * | zrtpContext, |
uint8_t | algoType, | ||
uint8_t | supportedTypes[7], | ||
uint8_t | supportedTypesCount | ||
) |
set the supported crypto types
set the supported crypto types. This function must be called before the context is initialised, just after creation.
[in,out] | zrtpContext | The ZRTP context we're dealing with |
[in] | algoType | mapped to defines, must be in [ZRTP_HASH_TYPE, ZRTP_CIPHERBLOCK_TYPE, ZRTP_AUTHTAG_TYPE, ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE] |
[in] | supportedTypes | mapped to uint8_t value of the 4 char strings giving the supported types as string according to rfc section 5.1.2 to 5.1.6 |
[in] | supportedTypesCount | number of supported crypto types |
int bzrtp_setZIDCache | ( | bzrtpContext_t * | context, |
void * | zidCache, | ||
const char * | selfURI, | ||
const char * | peerURI | ||
) |
Set the pointer allowing cache access.
[in,out] | context | The ZRTP context we're dealing with |
[in] | zidCache | Used by internal function to access cache: turn into a sqlite3 pointer if cache is enabled |
[in] | selfURI | Local URI used for this communication, needed to perform cache operation, NULL terminated string, duplicated by this function |
[in] | peerURI | Peer URI used for this communication, needed to perform cache operation, NULL terminated string, duplicated by this function |
int bzrtp_setZIDCache_lock | ( | bzrtpContext_t * | context, |
void * | zidCache, | ||
const char * | selfURI, | ||
const char * | peerURI, | ||
bctbx_mutex_t * | zidCacheMutex | ||
) |
Set the pointer allowing cache access, this version of the function get a mutex to lock the cache when accessing it.
[in,out] | context | The ZRTP context we're dealing with |
[in] | zidCache | Used by internal function to access cache: turn into a sqlite3 pointer if cache is enabled |
[in] | selfURI | Local URI used for this communication, needed to perform cache operation, NULL terminated string, duplicated by this function |
[in] | peerURI | Peer URI used for this communication, needed to perform cache operation, NULL terminated string, duplicated by this function |
[in] | zidCacheMutex | Points to a mutex used to lock zidCache database access |
int bzrtp_startChannelEngine | ( | bzrtpContext_t * | zrtpContext, |
uint32_t | selfSSRC | ||
) |
Start the state machine of the specified channel To be able to start an addional channel, we must be in secure state.
[in,out] | zrtpContext | The ZRTP context hosting the channel to be started |
[in] | selfSSRC | The SSRC identifying the channel to be started(will start sending Hello packets and listening for some) |
|
static |
Look in the given ZRTP context for a channel referenced with given SSRC.
[in] | zrtpContext | The zrtp context which shall contain the channel context we are looking for |
[in] | selfSSRC | The SSRC identifying the channel context |