23#include "bctoolbox/list.h"
47#define ZRTP_PACKET_HEADER_LENGTH 12
77#define ZRTP_FRAGMENTEDPACKET_HEADER_LENGTH 20
78#define ZRTP_PACKET_CRC_LENGTH 4
79#define ZRTP_PACKET_OVERHEAD (ZRTP_PACKET_HEADER_LENGTH + ZRTP_PACKET_CRC_LENGTH)
80#define ZRTP_FRAGMENTEDPACKET_OVERHEAD (ZRTP_FRAGMENTEDPACKET_HEADER_LENGTH + ZRTP_PACKET_CRC_LENGTH)
82#define BZRTP_PARSER_ERROR_INVALIDCRC 0xa001
83#define BZRTP_PARSER_ERROR_INVALIDPACKET 0xa002
84#define BZRTP_PARSER_ERROR_OUTOFORDER 0xa004
85#define BZRTP_PARSER_ERROR_INVALIDMESSAGE 0xa008
86#define BZRTP_PARSER_ERROR_INVALIDCONTEXT 0xa010
87#define BZRTP_PARSER_ERROR_UNMATCHINGCONFIRMMAC 0xa020
88#define BZRTP_PARSER_ERROR_UNMATCHINGSSRC 0xa040
89#define BZRTP_PARSER_ERROR_UNMATCHINGHASHCHAIN 0xa080
90#define BZRTP_PARSER_ERROR_UNMATCHINGMAC 0xa100
91#define BZRTP_PARSER_ERROR_UNEXPECTEDMESSAGE 0xa200
92#define BZRTP_PARSER_ERROR_UNMATCHINGHVI 0xa400
93#define BZRTP_PARSER_INFO_PACKETFRAGMENT 0xa800
95#define BZRTP_BUILDER_ERROR_INVALIDPACKET 0x5001
96#define BZRTP_BUILDER_ERROR_INVALIDMESSAGE 0x5002
97#define BZRTP_BUILDER_ERROR_INVALIDMESSAGETYPE 0x5004
98#define BZRTP_BUILDER_ERROR_UNKNOWN 0x5008
99#define BZRTP_BUILDER_ERROR_INVALIDCONTEXT 0x5010
100#define BZRTP_BUILDER_ERROR_UNABLETOFRAGMENT 0x5020
102#define BZRTP_CREATE_ERROR_INVALIDMESSAGETYPE 0x0a01
103#define BZRTP_CREATE_ERROR_UNABLETOCREATECRYPTOCONTEXT 0x0a02
104#define BZRTP_CREATE_ERROR_INVALIDCONTEXT 0x0a04
107#define MSGTYPE_INVALID 0x00
108#define MSGTYPE_HELLO 0x01
109#define MSGTYPE_HELLOACK 0x02
110#define MSGTYPE_COMMIT 0x03
111#define MSGTYPE_DHPART1 0x04
112#define MSGTYPE_DHPART2 0x05
113#define MSGTYPE_CONFIRM1 0x06
114#define MSGTYPE_CONFIRM2 0x07
115#define MSGTYPE_CONF2ACK 0x08
116#define MSGTYPE_ERROR 0x10
117#define MSGTYPE_ERRORACK 0x11
118#define MSGTYPE_GOCLEAR 0x12
119#define MSGTYPE_CLEARACK 0x13
120#define MSGTYPE_SASRELAY 0x14
121#define MSGTYPE_RELAYACK 0x15
122#define MSGTYPE_PING 0x16
123#define MSGTYPE_PINGACK 0x17
124#define MSGTYPE_FRAGMENT 0xff
202#define ZRTP_KEMPART2_NONCE_SIZE 16
#define BZRTP_EXPORT
Definition bzrtp.h:41
struct bzrtpCommitMessage_struct bzrtpCommitMessage_t
Hello ACK Message rfc 5.3 This message contains no data but only a length and message type which are ...
struct bzrtpPingAckMessage_struct bzrtpPingAckMessage_t
PingAck Message The Ping and PingACK messages are unrelated to the rest of the ZRTP protocol....
struct bzrtpDHPartMessage_struct bzrtpDHPartMessage_t
DHPart Message rfc 5.5 and rfc 5.6 DHPart1 and DHPart2 message have the same structure DHPart1 is gen...
struct bzrtpHelloMessage_struct bzrtpHelloMessage_t
Hello Message rfc 5.2.
BZRTP_EXPORT 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,...
Definition packetParser.c:848
BZRTP_EXPORT void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket)
Deallocate zrtp Packet.
Definition packetParser.c:1654
BZRTP_EXPORT 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 structu...
Definition packetParser.c:95
struct bzrtpConfirmMessage_struct bzrtpConfirmMessage_t
Confirm Message rfc 5.7 Confirm1 and Confirm2 messages have the same structure Confirm1 is generated ...
struct bzrtpPacket_struct bzrtpPacket_t
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
BZRTP_EXPORT 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.
BZRTP_EXPORT 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.
Definition packetParser.c:1307
BZRTP_EXPORT int bzrtp_packetSetSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber)
Set the current sequence number of the packet in the packetString and sequenceNumber fields The CRC a...
Definition packetParser.c:1705
struct bzrtpPingMessage_struct bzrtpPingMessage_t
Relay ACK Message rfc 5.14 This message contains no data but only a length and message type which are...
struct bzrtpGoClearMessage_struct bzrtpGoClearMessage_t
Conf2 ACK Message rfc 5.8 This message contains no data but only a length and message type which are ...
struct bzrtpSASRelayMessage_struct bzrtpSASRelayMessage_t
Clear ACK Message rfc 5.12 This message contains no data but only a length and message type which are...
unsigned short uint16_t
Definition stdint.h:79
unsigned int uint32_t
Definition stdint.h:80
unsigned char uint8_t
Definition stdint.h:78
The zrtp context of a channel.
Definition typedef.h:157
Hello ACK Message rfc 5.3 This message contains no data but only a length and message type which are ...
Definition packetParser.h:185
uint8_t authTagAlgo
Definition packetParser.h:190
uint8_t nonce[16]
Definition packetParser.h:194
uint8_t MAC[8]
Definition packetParser.h:197
uint8_t keyAgreementAlgo
Definition packetParser.h:191
uint8_t keyID[8]
Definition packetParser.h:195
uint8_t hvi[32]
Definition packetParser.h:193
uint8_t H2[32]
Definition packetParser.h:186
uint8_t * pv
Definition packetParser.h:196
uint8_t hashAlgo
Definition packetParser.h:188
uint8_t sasAlgo
Definition packetParser.h:192
uint8_t ZID[12]
Definition packetParser.h:187
uint8_t cipherAlgo
Definition packetParser.h:189
Confirm Message rfc 5.7 Confirm1 and Confirm2 messages have the same structure Confirm1 is generated ...
Definition packetParser.h:226
uint8_t V
Definition packetParser.h:232
uint8_t signatureBlockType[4]
Definition packetParser.h:236
uint8_t * signatureBlock
Definition packetParser.h:237
uint16_t sig_len
Definition packetParser.h:230
uint32_t cacheExpirationInterval
Definition packetParser.h:235
uint8_t CFBIV[16]
Definition packetParser.h:228
uint8_t E
Definition packetParser.h:231
uint8_t A
Definition packetParser.h:233
uint8_t confirm_mac[8]
Definition packetParser.h:227
uint8_t H0[32]
Definition packetParser.h:229
uint8_t D
Definition packetParser.h:234
structure of the ZRTP engine context Store current state, timers, HMAC and encryption keys
Definition typedef.h:235
DHPart Message rfc 5.5 and rfc 5.6 DHPart1 and DHPart2 message have the same structure DHPart1 is gen...
Definition packetParser.h:209
uint8_t MAC[8]
Definition packetParser.h:216
uint8_t auxsecretID[8]
Definition packetParser.h:213
uint8_t * pv
Definition packetParser.h:215
uint8_t H1[32]
Definition packetParser.h:210
uint8_t pbxsecretID[8]
Definition packetParser.h:214
uint8_t rs1ID[8]
Definition packetParser.h:211
uint8_t rs2ID[8]
Definition packetParser.h:212
Conf2 ACK Message rfc 5.8 This message contains no data but only a length and message type which are ...
Definition packetParser.h:264
uint8_t clear_mac[8]
Definition packetParser.h:265
Hello Message rfc 5.2.
Definition packetParser.h:152
uint8_t kc
Definition packetParser.h:166
uint8_t supportedSas[7]
Definition packetParser.h:169
uint8_t supportedAuthTag[7]
Definition packetParser.h:165
uint8_t MAC[8]
Definition packetParser.h:170
uint8_t cc
Definition packetParser.h:162
uint8_t ac
Definition packetParser.h:164
uint8_t supportedKeyAgreement[7]
Definition packetParser.h:167
uint8_t supportedHash[7]
Definition packetParser.h:161
uint8_t hc
Definition packetParser.h:160
uint8_t H3[32]
Definition packetParser.h:155
uint8_t ZID[12]
Definition packetParser.h:156
uint8_t version[4]
Definition packetParser.h:153
uint8_t P
Definition packetParser.h:159
uint8_t sc
Definition packetParser.h:168
uint8_t supportedCipher[7]
Definition packetParser.h:163
uint8_t clientIdentifier[17]
Definition packetParser.h:154
uint8_t M
Definition packetParser.h:158
uint8_t S
Definition packetParser.h:157
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
Definition packetParser.h:134
uint8_t * packetString
Definition packetParser.h:140
void * messageData
Definition packetParser.h:139
bctbx_list_t * fragments
Definition packetParser.h:141
uint16_t messageLength
Definition packetParser.h:138
uint8_t messageType
Definition packetParser.h:137
uint16_t sequenceNumber
Definition packetParser.h:135
uint32_t sourceIdentifier
Definition packetParser.h:136
PingAck Message The Ping and PingACK messages are unrelated to the rest of the ZRTP protocol....
Definition packetParser.h:315
uint8_t endpointHash[8]
Definition packetParser.h:317
uint32_t SSRC
Definition packetParser.h:319
uint8_t endpointHashReceived[8]
Definition packetParser.h:318
uint8_t version[4]
Definition packetParser.h:316
Relay ACK Message rfc 5.14 This message contains no data but only a length and message type which are...
Definition packetParser.h:305
uint8_t version[4]
Definition packetParser.h:306
uint8_t endpointHash[8]
Definition packetParser.h:307
Clear ACK Message rfc 5.12 This message contains no data but only a length and message type which are...
Definition packetParser.h:281
uint8_t signatureBlockType
Definition packetParser.h:290
uint8_t CFBIV[16]
Definition packetParser.h:283
uint8_t renderingScheme[4]
Definition packetParser.h:288
uint8_t A
Definition packetParser.h:286
uint16_t sig_len
Definition packetParser.h:284
uint8_t * signatureBlock
Definition packetParser.h:291
uint8_t relayedSasHash[32]
Definition packetParser.h:289
uint8_t D
Definition packetParser.h:287
uint8_t V
Definition packetParser.h:285
uint8_t MAC[8]
Definition packetParser.h:282