bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
|
Macros | |
#define | BITS_PRO_INT 8*sizeof(int) |
#define | BITMASK_256_SIZE 256/BITS_PRO_INT |
#define | BITMASK_256_SET_ZERO(bitmask) memset(bitmask, 0, sizeof(int)*BITMASK_256_SIZE) |
#define | BITMASK_256_SET(bitmask, value) bitmask[value/BITS_PRO_INT] |= 1 << (value % BITS_PRO_INT) |
#define | BITMASK_256_UNSET(bitmask, value) bitmask[value/BITS_PRO_INT] &= ~(1 << (value % BITS_PRO_INT)) |
#define | BITMASK_256_CHECK(bitmask, value) (bitmask[value/BITS_PRO_INT] & 1 << (value % BITS_PRO_INT)) |
Functions | |
uint8_t | bzrtpUtils_getAvailableCryptoTypes (uint8_t algoType, uint8_t availableTypes[7]) |
uint8_t | bzrtpUtils_getMandatoryCryptoTypes (uint8_t algoType, uint8_t mandatoryTypes[7]) |
int | bzrtp_keyDerivationFunction (const uint8_t *key, const size_t keyLength, const uint8_t *label, const size_t labelLength, const uint8_t *context, const size_t contextLength, const uint16_t hmacLength, void(*hmacFunction)(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t, uint8_t *), uint8_t *output) |
ZRTP Key Derivation Function as in rfc 4.5.1. More... | |
void | bzrtp_base32 (uint32_t sas, char *output, int outputSize) |
SAS rendering from 32 bits to 4 characters Function defined in rfc section 5.1.6. More... | |
void | bzrtp_base256 (uint32_t sas, char *output, int outputSize) |
SAS rendering from 32 bits to pgp word list Function defined in rfc section 5.1.6. More... | |
uint32_t | bzrtp_CRC32 (uint8_t *input, uint16_t length) |
CRC32 as defined in RFC4960 Appendix B - Polynomial is 0x1EDC6F41. More... | |
int | bzrtp_cryptoAlgoAgreement (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpHelloMessage_t *peerHelloMessage) |
select a key agreement algorithm from the one available in context and the one provided by peer in Hello Message as described in rfc section 4.1.2 More... | |
int | bzrtp_updateCryptoFunctionPointers (bzrtpChannelContext_t *zrtpChannelContext) |
Update context crypto function pointer according to related values of choosen algorithms fields (hashAlgo, cipherAlgo, etc..) More... | |
uint8_t | selectCommonAlgo (uint8_t masterArray[7], uint8_t masterArrayLength, uint8_t slaveArray[7], uint8_t slaveArrayLength, uint8_t commonArray[7]) |
Select common algorithm from the given array where algo are represented by their 4 chars string defined in rfc section 5.1.2 to 5.1.6 Master array is the one given the preference order All algo are designed by their uint8_t mapped values. More... | |
void | bzrtp_addMandatoryCryptoTypesIfNeeded (uint8_t algoType, uint8_t algoTypes[7], uint8_t *algoTypesCount) |
add mandatory crypto functions if they are not already included More... | |
uint8_t | bzrtp_cryptoAlgoTypeStringToInt (uint8_t algoType[4], uint8_t algoFamily) |
Map the string description of algo type to an int defined in cryptoWrapper.h. More... | |
void | bzrtp_cryptoAlgoTypeIntToString (uint8_t algoTypeInt, uint8_t algoTypeString[4]) |
Unmap the string description of algo type to an int defined in cryptoWrapper.h. More... | |
void | bzrtp_DestroyKey (uint8_t *key, uint8_t keyLength, void *rngContext) |
Destroy a key by setting it to a random number Key is not freed, caller must deal with memory management. Does nothing if the key pointer is NULL. More... | |
void | bzrtp_strToUint8 (uint8_t *outputBytes, uint8_t *inputString, uint16_t inputStringLength) |
Convert an hexadecimal string into the corresponding byte buffer. More... | |
void | bzrtp_int8ToStr (uint8_t *outputString, uint8_t *inputBytes, uint16_t inputBytesLength) |
Convert a byte buffer into the corresponding hexadecimal string. More... | |
uint8_t | bzrtp_charToByte (uint8_t inputChar) |
convert an hexa char [0-9a-fA-F] into the corresponding unsigned integer value Any invalid char will be converted to zero without any warning More... | |
uint8_t | bzrtp_byteToChar (uint8_t inputByte) |
convert a byte which value is in range [0-15] into an hexa char [0-9a-fA-F] More... | |
Variables | |
uint32_t | CRC32LookupTable [256] |
#define BITMASK_256_CHECK | ( | bitmask, | |
value | |||
) | (bitmask[value/BITS_PRO_INT] & 1 << (value % BITS_PRO_INT)) |
#define BITMASK_256_SET | ( | bitmask, | |
value | |||
) | bitmask[value/BITS_PRO_INT] |= 1 << (value % BITS_PRO_INT) |
#define BITMASK_256_SET_ZERO | ( | bitmask | ) | memset(bitmask, 0, sizeof(int)*BITMASK_256_SIZE) |
#define BITMASK_256_SIZE 256/BITS_PRO_INT |
#define BITMASK_256_UNSET | ( | bitmask, | |
value | |||
) | bitmask[value/BITS_PRO_INT] &= ~(1 << (value % BITS_PRO_INT)) |
#define BITS_PRO_INT 8*sizeof(int) |
void bzrtp_addMandatoryCryptoTypesIfNeeded | ( | uint8_t | algoType, |
uint8_t | algoTypes[7], | ||
uint8_t * | algoTypesCount | ||
) |
add mandatory crypto functions if they are not already included
[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,out] | algoTypes | mapped to uint8_t value of the 4 char strings giving the algo types as string according to rfc section 5.1.2 to 5.1.6 |
[in,out] | algoTypesCount | number of algo types |
void bzrtp_base256 | ( | uint32_t | sas, |
char * | output, | ||
int | outputSize | ||
) |
SAS rendering from 32 bits to pgp word list Function defined in rfc section 5.1.6.
[in] | sas | The 32 bits SAS |
[out] | output | The output list. Passed in array must be at least 32 bytes |
[in] | outputSize | size of the ouput buffer |
void bzrtp_base32 | ( | uint32_t | sas, |
char * | output, | ||
int | outputSize | ||
) |
SAS rendering from 32 bits to 4 characters Function defined in rfc section 5.1.6.
[in] | sas | The 32 bits SAS |
[out] | output | The 4 chars string to be displayed to user for vocal confirmation |
[in] | outputSize | size of the ouput buffer |
convert a byte which value is in range [0-15] into an hexa char [0-9a-fA-F]
[in] | inputByte | an integer which shall be in range [0-15] |
convert an hexa char [0-9a-fA-F] into the corresponding unsigned integer value Any invalid char will be converted to zero without any warning
[in] | inputChar | a char which shall be in range [0-9a-fA-F] |
CRC32 as defined in RFC4960 Appendix B - Polynomial is 0x1EDC6F41.
CRC is computed in reverse bit mode (least significant bit first within each byte) reversed value of polynom (0x82F63B78) was used to compute the lookup table (source http://en.wikipedia.org/wiki/Cyclic_redundancy_check#Commonly_used_and_standardized_CRCs)
[in] | input | input data |
[in] | length | length of data in bytes |
int bzrtp_cryptoAlgoAgreement | ( | bzrtpContext_t * | zrtpContext, |
bzrtpChannelContext_t * | zrtpChannelContext, | ||
bzrtpHelloMessage_t * | peerHelloMessage | ||
) |
select a key agreement algorithm from the one available in context and the one provided by peer in Hello Message as described in rfc section 4.1.2
[in] | zrtpContext | The context contains the list of available algo |
[out] | zrtpChannelContext | The bzrtp channel context to be updated |
[in] | peerHelloMessage | The peer hello message containing his set of available algos |
return 0 on succes, error code otherwise
Unmap the string description of algo type to an int defined in cryptoWrapper.h.
[in] | algoTypeInt | The integer algo type defined in crypoWrapper.h |
[in] | algoTypeString | The string code for the algorithm as defined in rfc 5.1.2 to 5.1.6 |
Map the string description of algo type to an int defined in cryptoWrapper.h.
[in] | algoType | A 4 chars string containing the algo type as listed in rfc sections 5.1.2 to 5.1.6 |
[in] | algoFamily | The integer mapped algo family (ZRTP_HASH_TYPE, ZRTP_CIPHERBLOCK_TYPE, ZRTP_AUTHTAG_TYPE, ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE) |
Destroy a key by setting it to a random number Key is not freed, caller must deal with memory management. Does nothing if the key pointer is NULL.
[in,out] | key | The key to be destroyed |
[in] | keyLength | The keyLength in bytes |
[in] | rngContext | The context for RNG |
Convert a byte buffer into the corresponding hexadecimal string.
[out] | outputString | The output string buffer, must have a length of twice the input bytes buffer |
[in] | inputBytes | The input bytes buffer |
[in] | inputBytesLength | The length in bytes buffer, output is twice this length |
int bzrtp_keyDerivationFunction | ( | const uint8_t * | key, |
const size_t | keyLength, | ||
const uint8_t * | label, | ||
const size_t | labelLength, | ||
const uint8_t * | context, | ||
const size_t | contextLength, | ||
const uint16_t | hmacLength, | ||
void(*)(const uint8_t *, size_t, const uint8_t *, size_t, uint8_t, uint8_t *) | hmacFunction, | ||
uint8_t * | output | ||
) |
ZRTP Key Derivation Function as in rfc 4.5.1.
KDF(KI, Label, Context, L) = HMAC(KI, i || Label || 0x00 || Context || L) where
[in] | key | The key for HMAC |
[in] | keyLength | Length of the key in bytes |
[in] | label | A string to be included in the hash |
[in] | labelLength | Length of the label in bytes |
[in] | context | a context string for the key derivation |
[in] | contextLength | Length of the context string in bytes |
[in] | hmacLength | The output of the KDF is the HMAC truncated to the leftmost L bytes |
[in] | hmacFunction | The hashmac function to be used to compute the KDF |
[out] | output | A buffer to store the hmacLength bytes of output |
Convert an hexadecimal string into the corresponding byte buffer.
[out] | outputBytes | The output bytes buffer, must have a length of half the input string buffer |
[in] | inputString | The input string buffer, must be hexadecimal(it is not checked by function, any non hexa char is converted to 0) |
[in] | inputStringLength | The length in chars of the string buffer, output is half this length |
int bzrtp_updateCryptoFunctionPointers | ( | bzrtpChannelContext_t * | zrtpChannelContext | ) |
Update context crypto function pointer according to related values of choosen algorithms fields (hashAlgo, cipherAlgo, etc..)
[in,out] | zrtpChannelContext | The bzrtp channel context to be updated |
Return available crypto functions. For now we have
Return mandatory crypto functions. For now we have
uint8_t selectCommonAlgo | ( | uint8_t | masterArray[7], |
uint8_t | masterArrayLength, | ||
uint8_t | slaveArray[7], | ||
uint8_t | slaveArrayLength, | ||
uint8_t | commonArray[7] | ||
) |
Select common algorithm from the given array where algo are represented by their 4 chars string defined in rfc section 5.1.2 to 5.1.6 Master array is the one given the preference order All algo are designed by their uint8_t mapped values.
[in] | masterArray | The ordered available algo, result will follow this ordering |
[in] | masterArrayLength | Number of valids element in the master array |
[in] | slaveArray | The available algo, order is not taken in account |
[in] | slaveArrayLength | Number of valids element in the slave array |
[out] | commonArray | Common algorithms found, max size 7 |
uint32_t CRC32LookupTable[256] |