bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
|
Macros | |
#define | ZRTP_MIN_PACKET_LENGTH 28 |
#define | ZRTP_MAX_PACKET_LENGTH 3072 |
#define | ZRTP_MESSAGE_HEADER_LENGTH 12 |
#define | ZRTP_HELLOMESSAGE_FIXED_LENGTH 88 |
#define | ZRTP_HELLOACKMESSAGE_FIXED_LENGTH 12 |
#define | ZRTP_COMMITMESSAGE_FIXED_LENGTH 84 |
#define | ZRTP_DHPARTMESSAGE_FIXED_LENGTH 84 |
#define | ZRTP_CONFIRMMESSAGE_FIXED_LENGTH 76 |
#define | ZRTP_CONF2ACKMESSAGE_FIXED_LENGTH 12 |
#define | ZRTP_ERRORMESSAGE_FIXED_LENGTH 16 |
#define | ZRTP_ERRORACKMESSAGE_FIXED_LENGTH 12 |
#define | ZRTP_GOCLEARMESSAGE_FIXED_LENGTH 20 |
#define | ZRTP_CLEARACKMESSAGE_FIXED_LENGTH 12 |
#define | ZRTP_SASRELAYMESSAGE_FIXED_LENGTH 76 |
#define | ZRTP_RELAYACKMESSAGE_FIXED_LENGTH 12 |
#define | ZRTP_PINGMESSAGE_FIXED_LENGTH 24 |
#define | ZRTP_PINGACKMESSAGE_FIXED_LENGTH 36 |
Functions | |
static uint8_t * | messageTypeInttoString (uint32_t messageType) |
Retrieve the 8 char string value message type from the int32_t code. | |
static int32_t | messageTypeStringtoInt (uint8_t messageTypeString[8]) |
Map the 8 char string value message type to an int32_t. | |
static void | zrtpMessageSetHeader (uint8_t *outputBuffer, uint16_t messageLength, uint8_t messageType[9]) |
Write the message header(preambule, length, message type) into the given output buffer. | |
static void | zrtpPacketSetHeader (bzrtpPacket_t *zrtpPacket) |
Write the packet header(preambule, MagicCookie, SSRC) in the zrtpPacket string. | |
bzrtpPacket_t * | bzrtp_packetCheck (uint8_t **inputPtr, uint16_t *inputLength, bzrtpChannelContext_t *zrtpChannelContext, int *exitCode) |
Parse a string which shall be a valid ZRTP packet Check validity and allocate the bzrtpPacket structure but do not parse the message except for type and length. messageData structure field is not allocated by this function (use then bzrtp_packetParse for that). The packet check and actual message parsing are split in two functions to avoid useless parsing when message is to be discarded as the check will give message type (in case of message repetition for example) | |
int | bzrtp_packetParser (BCTBX_UNUSED(bzrtpContext_t *zrtpContext), bzrtpChannelContext_t *zrtpChannelContext, const uint8_t *input, uint16_t inputLength, bzrtpPacket_t *zrtpPacket) |
int | bzrtp_packetBuild (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket) |
Create a ZRTP packet string from the ZRTP packet values present in the structure messageType, messageData and sourceIdentifier in zrtpPacket must have been correctly set before calling this function The packet is not ready to be sent at that stage, sequenceNumber and CRC must be set using bzrtp_packetSetSequenceNumber. | |
bzrtpPacket_t * | bzrtp_createZrtpPacket (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, uint32_t messageType, int *exitCode) |
Create an empty packet and allocate the messageData according to requested packetType. | |
void | bzrtp_freeZrtpPacket (bzrtpPacket_t *zrtpPacket) |
Deallocate zrtp Packet. | |
int | bzrtp_packetSetSequenceNumber (bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber) |
Modify the current sequence number of the packet in the packetString and sequenceNumber fields The CRC at the end of packetString is also computed. | |
#define ZRTP_CLEARACKMESSAGE_FIXED_LENGTH 12 |
#define ZRTP_COMMITMESSAGE_FIXED_LENGTH 84 |
#define ZRTP_CONF2ACKMESSAGE_FIXED_LENGTH 12 |
#define ZRTP_CONFIRMMESSAGE_FIXED_LENGTH 76 |
#define ZRTP_DHPARTMESSAGE_FIXED_LENGTH 84 |
#define ZRTP_ERRORACKMESSAGE_FIXED_LENGTH 12 |
#define ZRTP_ERRORMESSAGE_FIXED_LENGTH 16 |
#define ZRTP_GOCLEARMESSAGE_FIXED_LENGTH 20 |
#define ZRTP_HELLOACKMESSAGE_FIXED_LENGTH 12 |
#define ZRTP_HELLOMESSAGE_FIXED_LENGTH 88 |
#define ZRTP_MAX_PACKET_LENGTH 3072 |
#define ZRTP_MESSAGE_HEADER_LENGTH 12 |
#define ZRTP_MIN_PACKET_LENGTH 28 |
#define ZRTP_PINGACKMESSAGE_FIXED_LENGTH 36 |
#define ZRTP_PINGMESSAGE_FIXED_LENGTH 24 |
#define ZRTP_RELAYACKMESSAGE_FIXED_LENGTH 12 |
#define ZRTP_SASRELAYMESSAGE_FIXED_LENGTH 76 |
bzrtpPacket_t * bzrtp_createZrtpPacket | ( | bzrtpContext_t * | zrtpContext, |
bzrtpChannelContext_t * | zrtpChannelContext, | ||
uint32_t | messageType, | ||
int * | exitCode | ||
) |
Create an empty packet and allocate the messageData according to requested packetType.
[in] | zrtpContext | The current ZRTP context, some data (H chain or others, may be needed to create messages) |
[in] | zrtpChannelContext | The channel context this packet is intended to |
[in] | messageType | The 32bit integer mapped to the message type to be created |
[out] | exitCode | 0 on success, error code otherwise |
void bzrtp_freeZrtpPacket | ( | bzrtpPacket_t * | zrtpPacket | ) |
Deallocate zrtp Packet.
[in] | zrtpPacket | The packet to be freed |
int bzrtp_packetBuild | ( | bzrtpContext_t * | zrtpContext, |
bzrtpChannelContext_t * | zrtpChannelContext, | ||
bzrtpPacket_t * | zrtpPacket | ||
) |
Create a ZRTP packet string from the ZRTP packet values present in the structure messageType, messageData and sourceIdentifier in zrtpPacket must have been correctly set before calling this function The packet is not ready to be sent at that stage, sequenceNumber and CRC must be set using bzrtp_packetSetSequenceNumber.
[in] | zrtpContext | A zrtp context where to find H0-H3 to compute MAC requested by some paquets or encryption's key for commit/SASRelay packet |
[in] | zrtpChannelContext | The channel context this packet is intended to |
[in,out] | zrtpPacket | The zrtpPacket structure containing the message Data structure, output is stored in ->packetString |
bzrtpPacket_t * bzrtp_packetCheck | ( | uint8_t ** | inputPtr, |
uint16_t * | inputLength, | ||
bzrtpChannelContext_t * | zrtpChannelContext, | ||
int * | exitCode | ||
) |
Parse a string which shall be a valid ZRTP packet Check validity and allocate the bzrtpPacket structure but do not parse the message except for type and length. messageData structure field is not allocated by this function (use then bzrtp_packetParse for that). The packet check and actual message parsing are split in two functions to avoid useless parsing when message is to be discarded as the check will give message type (in case of message repetition for example)
[in/out] | inputPtr The string buffer storing the complete ZRTP packet. Modified if we complete a fragmented packet | |
[in/out] | inputLength Input length in bytes. Modified if we complete a fragmented packet | |
[in/out] | zrtpChannelContext The channel context this packet is intended to(channel context and packet must match peer SSRC). | |
[out] | exitCode | 0 on success, BZRTP_PARSER_INFO_PACKETFRAGMENT when a fragment of incomplete packet is received, error code otherwise |
int bzrtp_packetParser | ( | BCTBX_UNUSED(bzrtpContext_t *zrtpContext) | , |
bzrtpChannelContext_t * | zrtpChannelContext, | ||
const uint8_t * | input, | ||
uint16_t | inputLength, | ||
bzrtpPacket_t * | zrtpPacket | ||
) |
int bzrtp_packetSetSequenceNumber | ( | bzrtpPacket_t * | zrtpPacket, |
uint16_t | sequenceNumber | ||
) |
Modify the current sequence number of the packet in the packetString and sequenceNumber fields The CRC at the end of packetString is also computed.
Set the current sequence number of the packet in the packetString and sequenceNumber fields The CRC at the end of packetString is also computed.
param[in,out] zrtpPacket The zrtpPacket to modify, the packetString must have been generated by a call to bzrtp_packetBuild on this packet param[in] sequenceNumber The sequence number to insert in the packetString
return 0 on succes, error code otherwise
Retrieve the 8 char string value message type from the int32_t code.
[in] | messageType | The messageType code |
Map the 8 char string value message type to an int32_t.
[in] | messageTypeString | an 8 bytes string matching a zrtp message type |
|
static |
Write the message header(preambule, length, message type) into the given output buffer.
[out] | outputBuffer | Message starts at the begining of this buffer |
[in] | messageLength | Message length in bytes! To be converted into 32bits words before being inserted in the message header |
[in] | messageType | An 8 chars string for the message type (validity is not checked by this function) |
|
static |
Write the packet header(preambule, MagicCookie, SSRC) in the zrtpPacket string.
[in/out] | zrtpPacket the zrtp packet holding the stringBuffer |