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 | |
uint16_t | computeKeyAgreementPrivateValueLength (uint8_t keyAgreementAlgo) |
uint8_t * | messageTypeInttoString (uint32_t messageType) |
Retrieve the 8 char string value message type from the int32_t code. More... | |
int32_t | messageTypeStringtoInt (uint8_t messageTypeString[8]) |
Map the 8 char string value message type to an int32_t. More... | |
void | zrtpMessageSetHeader (uint8_t *outputBuffer, uint16_t messageLength, uint8_t messageType[8]) |
Write the message header(preambule, length, message type) into the given output buffer. More... | |
bzrtpPacket_t * | bzrtp_packetCheck (const uint8_t *input, uint16_t inputLength, uint16_t lastValidSequenceNumber, 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) More... | |
int | bzrtp_packetParser (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, const uint8_t *input, uint16_t inputLength, bzrtpPacket_t *zrtpPacket) |
Parse the packet to extract the message and allocate the matching message structure if needed. More... | |
int | bzrtp_packetBuild (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber) |
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. More... | |
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. More... | |
void | bzrtp_freeZrtpPacket (bzrtpPacket_t *zrtpPacket) |
Deallocate zrtp Packet. More... | |
int | bzrtp_packetUpdateSequenceNumber (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 updated. More... | |
#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, | ||
uint16_t | sequenceNumber | ||
) |
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.
[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 |
[in] | sequenceNumber | Sequence number of this packet |
bzrtpPacket_t* bzrtp_packetCheck | ( | const uint8_t * | input, |
uint16_t | inputLength, | ||
uint16_t | lastValidSequenceNumber, | ||
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] | input | The string buffer storing the complete ZRTP packet |
[in] | inputLength | Input length in bytes |
[in] | lastValidSequenceNumber | If the sequence number of this packet is smaller than this param, packet will be discarded and an error code returned |
[out] | exitCode | 0 on success, error code otherwise |
int bzrtp_packetParser | ( | bzrtpContext_t * | zrtpContext, |
bzrtpChannelContext_t * | zrtpChannelContext, | ||
const uint8_t * | input, | ||
uint16_t | inputLength, | ||
bzrtpPacket_t * | zrtpPacket | ||
) |
Parse the packet to extract the message and allocate the matching message structure if needed.
[in] | zrtpContext | The current ZRTP context, some parameters(key agreement algorithm) may be needed to parse packet. |
[in] | zrtpChannelContext | The channel context this packet is intended to(channel context and packet must match peer SSRC). |
[in] | input | The string buffer storing the complete ZRTP packet |
[in] | inputLength | Input length in bytes |
[in] | zrtpPacket | The zrtpPacket structure allocated by previous call to bzrtpPacketCheck |
int bzrtp_packetUpdateSequenceNumber | ( | 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 updated.
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 new sequence number to insert in the packetString
return 0 on succes, error code otherwise
Return the variable private value length in bytes according to given key agreement algorythm
[in] | keyAgreementAlgo | The key agreement algo mapped to an integer as defined in cryptoWrapper.h |
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 |
void zrtpMessageSetHeader | ( | uint8_t * | outputBuffer, |
uint16_t | messageLength, | ||
uint8_t | messageType[8] | ||
) |
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) |