Commit 548e34fa authored by Ghislain MARY's avatar Ghislain MARY

Fix build on Windows.

parent 40faa2f3
......@@ -65,7 +65,7 @@ uint8_t bzrtpUtils_getAvailableCryptoTypes(uint8_t algoType, uint8_t availableTy
*
* @return 0 on succes, error code otherwise
*/
int bzrtp_keyDerivationFunction(uint8_t *key, uint16_t keyLength,
BZRTP_EXPORT int bzrtp_keyDerivationFunction(uint8_t *key, uint16_t keyLength,
uint8_t *label, uint16_t labelLength,
uint8_t *context, uint16_t contextLength,
uint16_t hmacLength,
......@@ -106,7 +106,7 @@ void bzrtp_base256(uint32_t sas, char *output, int outputSize);
* @return the 32 bits CRC value
*
*/
uint32_t bzrtp_CRC32(uint8_t *input, uint16_t length);
BZRTP_EXPORT uint32_t bzrtp_CRC32(uint8_t *input, uint16_t length);
/* error code for the cryptoAlgoAgreement and function pointer update functions */
#define ZRTP_CRYPTOAGREEMENT_INVALIDCONTEXT 0x1001
......@@ -131,7 +131,7 @@ uint32_t bzrtp_CRC32(uint8_t *input, uint16_t length);
* return 0 on succes, error code otherwise
*
*/
int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpHelloMessage_t *peerHelloMessage);
BZRTP_EXPORT int bzrtp_cryptoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpHelloMessage_t *peerHelloMessage);
/**
* @brief Update context crypto function pointer according to related values of choosen algorithms fields (hashAlgo, cipherAlgo, etc..)
......@@ -140,7 +140,7 @@ int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
*
* @return 0 on succes
*/
int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext);
BZRTP_EXPORT int bzrtp_updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext);
/**
* @brief 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
......@@ -169,7 +169,7 @@ uint8_t selectCommonAlgo(uint8_t masterArray[7], uint8_t masterArrayLength, uint
* @param[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
* @param[in/out] algoTypesCount number of algo types
*/
void addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uint8_t *algoTypesCount);
BZRTP_EXPORT void bzrtp_addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uint8_t *algoTypesCount);
/**
* @brief Map the string description of algo type to an int defined in cryptoWrapper.h
......@@ -179,7 +179,7 @@ void addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uin
* ZRTP_KEYAGREEMENT_TYPE or ZRTP_SAS_TYPE)
* @return The int value mapped to the algo type, ZRTP_UNSET_ALGO on error
*/
uint8_t cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily);
BZRTP_EXPORT uint8_t bzrtp_cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily);
/**
* @brief Unmap the string description of algo type to an int defined in cryptoWrapper.h
......@@ -187,7 +187,7 @@ uint8_t cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily);
* @param[in] algoTypeInt The integer algo type defined in crypoWrapper.h
* @param[in] algoFamily The string code for the algorithm as defined in rfc 5.1.2 to 5.1.6
*/
void cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]);
BZRTP_EXPORT void bzrtp_cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]);
/**
* @brief Destroy a key by setting it to a random number
......@@ -198,7 +198,7 @@ void cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]);
* @param[in] keyLength The keyLength in bytes
* @param[in] rngContext The context for RNG
*/
void bzrtp_DestroyKey(uint8_t *key, uint8_t keyLength, void *rngContext);
BZRTP_EXPORT void bzrtp_DestroyKey(uint8_t *key, uint8_t keyLength, void *rngContext);
/**
* @brief Convert an hexadecimal string into the corresponding byte buffer
......
......@@ -277,7 +277,7 @@ typedef struct bzrtpPingAckMessage_struct {
*
* @return The create bzrtpPacket structure(to be freed using bzrtp_freeZrtpPacket). NULL on error
*/
bzrtpPacket_t *bzrtp_packetCheck(const uint8_t * input, uint16_t inputLength, uint16_t lastValidSequenceNumber, int *exitCode);
BZRTP_EXPORT bzrtpPacket_t *bzrtp_packetCheck(const uint8_t * input, uint16_t inputLength, uint16_t lastValidSequenceNumber, int *exitCode);
/**
......@@ -291,7 +291,7 @@ bzrtpPacket_t *bzrtp_packetCheck(const uint8_t * input, uint16_t inputLength, ui
*
* @return 0 on sucess, error code otherwise
*/
int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, const uint8_t * input, uint16_t inputLength, bzrtpPacket_t *zrtpPacket);
BZRTP_EXPORT int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, const uint8_t * input, uint16_t inputLength, bzrtpPacket_t *zrtpPacket);
/**
......@@ -304,7 +304,7 @@ int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
*
* @return An empty packet initialised to get data for the requested paquet tyep. NULL on error
*/
bzrtpPacket_t *bzrtp_createZrtpPacket(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, uint32_t messageType, int *exitCode);
BZRTP_EXPORT bzrtpPacket_t *bzrtp_createZrtpPacket(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, uint32_t messageType, int *exitCode);
/**
......@@ -319,7 +319,7 @@ bzrtpPacket_t *bzrtp_createZrtpPacket(bzrtpContext_t *zrtpContext, bzrtpChannelC
* @return 0 on success, error code otherwise
*
*/
int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber);
BZRTP_EXPORT int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber);
/**
......@@ -328,7 +328,7 @@ int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
* @param[in] zrtpPacket The packet to be freed
*
*/
void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket);
BZRTP_EXPORT void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket);
/**
* @brief Modify the current sequence number of the packet in the packetString and sequenceNumber fields
......@@ -340,5 +340,5 @@ void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket);
*
* return 0 on succes, error code otherwise
*/
int bzrtp_packetUpdateSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber);
BZRTP_EXPORT int bzrtp_packetUpdateSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber);
#endif /* PACKETPARSER_H */
......@@ -54,7 +54,7 @@ int bzrtp_getSelfZID(bzrtpContext_t *context, uint8_t selfZID[12]);
*
* return 0 on succes, error code otherwise
*/
int bzrtp_getPeerAssociatedSecretsHash(bzrtpContext_t *context, uint8_t peerZID[12]);
BZRTP_EXPORT int bzrtp_getPeerAssociatedSecretsHash(bzrtpContext_t *context, uint8_t peerZID[12]);
/* Define for write peer flags */
/* define positions for bit into the flags */
......
......@@ -48,7 +48,7 @@ if(ENABLE_STATIC)
endif()
if(ENABLE_SHARED)
add_library(bzrtp SHARED ${SOURCE_FILES})
target_compile_definitions(bzrtp PRIVATE "-DZRTP_EXPORTS")
target_compile_definitions(bzrtp PRIVATE "-DBZRTP_EXPORTS")
set_target_properties(bzrtp PROPERTIES VERSION 0)
target_include_directories(bzrtp PUBLIC ${BCTOOLBOX_CORE_INCLUDE_DIRS})
target_link_libraries(bzrtp PRIVATE ${LIBS})
......
......@@ -661,23 +661,23 @@ void bzrtp_setSupportedCryptoTypes(bzrtpContext_t *zrtpContext, uint8_t algoType
switch(algoType) {
case ZRTP_HASH_TYPE:
zrtpContext->hc = selectCommonAlgo(supportedTypes, supportedTypesCount, implementedTypes, implementedTypesCount, zrtpContext->supportedHash);
addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedHash, &zrtpContext->hc);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedHash, &zrtpContext->hc);
break;
case ZRTP_CIPHERBLOCK_TYPE:
zrtpContext->cc = selectCommonAlgo(supportedTypes, supportedTypesCount, implementedTypes, implementedTypesCount, zrtpContext->supportedCipher);
addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedCipher, &zrtpContext->cc);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedCipher, &zrtpContext->cc);
break;
case ZRTP_AUTHTAG_TYPE:
zrtpContext->ac = selectCommonAlgo(supportedTypes, supportedTypesCount, implementedTypes, implementedTypesCount, zrtpContext->supportedAuthTag);
addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedAuthTag, &zrtpContext->ac);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedAuthTag, &zrtpContext->ac);
break;
case ZRTP_KEYAGREEMENT_TYPE:
zrtpContext->kc = selectCommonAlgo(supportedTypes, supportedTypesCount, implementedTypes, implementedTypesCount, zrtpContext->supportedKeyAgreement);
addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedKeyAgreement, &zrtpContext->kc);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedKeyAgreement, &zrtpContext->kc);
break;
case ZRTP_SAS_TYPE:
zrtpContext->sc = selectCommonAlgo(supportedTypes, supportedTypesCount, implementedTypes, implementedTypesCount, zrtpContext->supportedSas);
addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedSas, &zrtpContext->sc);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, zrtpContext->supportedSas, &zrtpContext->sc);
break;
}
}
......@@ -817,7 +817,7 @@ int bzrtp_setPeerHelloHash(bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8
zrtpChannelContext->keyAgreementAlgo = ZRTP_UNSET_ALGO;
zrtpChannelContext->sasAlgo = ZRTP_UNSET_ALGO;
updateCryptoFunctionPointers(zrtpChannelContext);
bzrtp_updateCryptoFunctionPointers(zrtpChannelContext);
/* restart channel */
bzrtp_startChannelEngine(zrtpContext, selfSSRC);
......@@ -1001,7 +1001,7 @@ static int bzrtp_initChannelContext(bzrtpContext_t *zrtpContext, bzrtpChannelCon
zrtpChannelContext->keyAgreementAlgo = ZRTP_UNSET_ALGO;
zrtpChannelContext->sasAlgo = ZRTP_UNSET_ALGO;
updateCryptoFunctionPointers(zrtpChannelContext);
bzrtp_updateCryptoFunctionPointers(zrtpChannelContext);
/* initialise key buffers */
zrtpChannelContext->s0 = NULL;
......
......@@ -286,7 +286,7 @@ uint32_t bzrtp_CRC32(uint8_t *input, uint16_t length) {
* return 0 on succes, error code otherwise
*
*/
int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpHelloMessage_t *peerHelloMessage) {
int bzrtp_cryptoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpHelloMessage_t *peerHelloMessage) {
uint8_t selfCommonKeyAgreementType[7];
uint8_t peerCommonKeyAgreementType[7];
uint8_t commonKeyAgreementTypeNumber = 0;
......@@ -422,7 +422,7 @@ int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
zrtpChannelContext->sasAlgo = commonSasType[0];
/* update the function pointers */
return updateCryptoFunctionPointers(zrtpChannelContext);
return bzrtp_updateCryptoFunctionPointers(zrtpChannelContext);
}
/*
......@@ -433,7 +433,7 @@ int crypoAlgoAgreement(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
*
* @return 0 on succes
*/
int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext) {
int bzrtp_updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext) {
if (zrtpChannelContext==NULL) {
return ZRTP_CRYPTOAGREEMENT_INVALIDCONTEXT;
}
......@@ -569,7 +569,7 @@ uint8_t selectCommonAlgo(uint8_t masterArray[7], uint8_t masterArrayLength, uint
* @param[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
* @param[in/out] algoTypesCount number of algo types
*/
void addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uint8_t *algoTypesCount)
void bzrtp_addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uint8_t *algoTypesCount)
{
int i, j;
int algosBitmask[BITMASK_256_SIZE];
......@@ -620,7 +620,7 @@ void addMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t algoTypes[7], uin
*
* @return The int value mapped to the algo type, ZRTP_UNSET_ALGO on error
*/
uint8_t cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily) {
uint8_t bzrtp_cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily) {
switch (algoFamily) {
case ZRTP_HASH_TYPE:
{
......@@ -713,7 +713,7 @@ uint8_t cryptoAlgoTypeStringToInt(uint8_t algoType[4], uint8_t algoFamily) {
* @param[in] algoTypeInt The integer algo type defined in crypoWrapper.h
* @param[in] algoFamily The string code for the algorithm as defined in rfc 5.1.2 to 5.1.6
*/
void cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]) {
void bzrtp_cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]) {
switch (algoTypeInt) {
case ZRTP_HASH_S256:
memcpy(algoTypeString, "S256", 4);
......
......@@ -258,31 +258,31 @@ int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
/* parse the variable length part: algorithms types */
for (i=0; i<messageData->hc; i++) {
messageData->supportedHash[i] = cryptoAlgoTypeStringToInt(messageContent, ZRTP_HASH_TYPE);
messageData->supportedHash[i] = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_HASH_TYPE);
messageContent +=4;
}
for (i=0; i<messageData->cc; i++) {
messageData->supportedCipher[i] = cryptoAlgoTypeStringToInt(messageContent, ZRTP_CIPHERBLOCK_TYPE);
messageData->supportedCipher[i] = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_CIPHERBLOCK_TYPE);
messageContent +=4;
}
for (i=0; i<messageData->ac; i++) {
messageData->supportedAuthTag[i] = cryptoAlgoTypeStringToInt(messageContent, ZRTP_AUTHTAG_TYPE);
messageData->supportedAuthTag[i] = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_AUTHTAG_TYPE);
messageContent +=4;
}
for (i=0; i<messageData->kc; i++) {
messageData->supportedKeyAgreement[i] = cryptoAlgoTypeStringToInt(messageContent, ZRTP_KEYAGREEMENT_TYPE);
messageData->supportedKeyAgreement[i] = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_KEYAGREEMENT_TYPE);
messageContent +=4;
}
for (i=0; i<messageData->sc; i++) {
messageData->supportedSas[i] = cryptoAlgoTypeStringToInt(messageContent, ZRTP_SAS_TYPE);
messageData->supportedSas[i] = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_SAS_TYPE);
messageContent +=4;
}
addMandatoryCryptoTypesIfNeeded(ZRTP_HASH_TYPE, messageData->supportedHash, &messageData->hc);
addMandatoryCryptoTypesIfNeeded(ZRTP_CIPHERBLOCK_TYPE, messageData->supportedCipher, &messageData->cc);
addMandatoryCryptoTypesIfNeeded(ZRTP_AUTHTAG_TYPE, messageData->supportedAuthTag, &messageData->ac);
addMandatoryCryptoTypesIfNeeded(ZRTP_KEYAGREEMENT_TYPE, messageData->supportedKeyAgreement, &messageData->kc);
addMandatoryCryptoTypesIfNeeded(ZRTP_SAS_TYPE, messageData->supportedSas, &messageData->sc);
bzrtp_addMandatoryCryptoTypesIfNeeded(ZRTP_HASH_TYPE, messageData->supportedHash, &messageData->hc);
bzrtp_addMandatoryCryptoTypesIfNeeded(ZRTP_CIPHERBLOCK_TYPE, messageData->supportedCipher, &messageData->cc);
bzrtp_addMandatoryCryptoTypesIfNeeded(ZRTP_AUTHTAG_TYPE, messageData->supportedAuthTag, &messageData->ac);
bzrtp_addMandatoryCryptoTypesIfNeeded(ZRTP_KEYAGREEMENT_TYPE, messageData->supportedKeyAgreement, &messageData->kc);
bzrtp_addMandatoryCryptoTypesIfNeeded(ZRTP_SAS_TYPE, messageData->supportedSas, &messageData->sc);
memcpy(messageData->MAC, messageContent, 8);
......@@ -344,13 +344,13 @@ int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
memcpy(messageData->ZID, messageContent, 12);
messageContent +=12;
messageData->hashAlgo = cryptoAlgoTypeStringToInt(messageContent, ZRTP_HASH_TYPE);
messageData->hashAlgo = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_HASH_TYPE);
messageContent += 4;
messageData->cipherAlgo = cryptoAlgoTypeStringToInt(messageContent, ZRTP_CIPHERBLOCK_TYPE);
messageData->cipherAlgo = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_CIPHERBLOCK_TYPE);
messageContent += 4;
messageData->authTagAlgo = cryptoAlgoTypeStringToInt(messageContent, ZRTP_AUTHTAG_TYPE);
messageData->authTagAlgo = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_AUTHTAG_TYPE);
messageContent += 4;
messageData->keyAgreementAlgo = cryptoAlgoTypeStringToInt(messageContent, ZRTP_KEYAGREEMENT_TYPE);
messageData->keyAgreementAlgo = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_KEYAGREEMENT_TYPE);
messageContent += 4;
/* commit message length depends on the key agreement type choosen (and set in the zrtpContext->keyAgreementAlgo) */
switch(messageData->keyAgreementAlgo) {
......@@ -376,7 +376,7 @@ int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpC
free(messageData);
return BZRTP_PARSER_ERROR_INVALIDMESSAGE;
}
messageData->sasAlgo = cryptoAlgoTypeStringToInt(messageContent, ZRTP_SAS_TYPE);
messageData->sasAlgo = bzrtp_cryptoAlgoTypeStringToInt(messageContent, ZRTP_SAS_TYPE);
messageContent += 4;
/* if it is a multistream or preshared commit, get the 16 bytes nonce */
......@@ -793,23 +793,23 @@ int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpCh
/* now set optionnal supported algorithms */
for (i=0; i<messageData->hc; i++) {
cryptoAlgoTypeIntToString(messageData->supportedHash[i], messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedHash[i], messageString);
messageString +=4;
}
for (i=0; i<messageData->cc; i++) {
cryptoAlgoTypeIntToString(messageData->supportedCipher[i], messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedCipher[i], messageString);
messageString +=4;
}
for (i=0; i<messageData->ac; i++) {
cryptoAlgoTypeIntToString(messageData->supportedAuthTag[i], messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedAuthTag[i], messageString);
messageString +=4;
}
for (i=0; i<messageData->kc; i++) {
cryptoAlgoTypeIntToString(messageData->supportedKeyAgreement[i], messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedKeyAgreement[i], messageString);
messageString +=4;
}
for (i=0; i<messageData->sc; i++) {
cryptoAlgoTypeIntToString(messageData->supportedSas[i], messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedSas[i], messageString);
messageString +=4;
}
......@@ -873,15 +873,15 @@ int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpCh
messageString += 32;
memcpy(messageString, messageData->ZID, 12);
messageString += 12;
cryptoAlgoTypeIntToString(messageData->hashAlgo, messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->hashAlgo, messageString);
messageString += 4;
cryptoAlgoTypeIntToString(messageData->cipherAlgo, messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->cipherAlgo, messageString);
messageString += 4;
cryptoAlgoTypeIntToString(messageData->authTagAlgo, messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->authTagAlgo, messageString);
messageString += 4;
cryptoAlgoTypeIntToString(messageData->keyAgreementAlgo, messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->keyAgreementAlgo, messageString);
messageString += 4;
cryptoAlgoTypeIntToString(messageData->sasAlgo, messageString);
bzrtp_cryptoAlgoTypeIntToString(messageData->sasAlgo, messageString);
messageString += 4;
/* if it is a multistream or preshared commit insert the 16 bytes nonce */
......
......@@ -1545,7 +1545,7 @@ int bzrtp_turnIntoResponder(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *
zrtpChannelContext->authTagAlgo = commitMessage->authTagAlgo;
zrtpChannelContext->keyAgreementAlgo = commitMessage->keyAgreementAlgo;
zrtpChannelContext->sasAlgo = commitMessage->sasAlgo;
updateCryptoFunctionPointers(zrtpChannelContext);
bzrtp_updateCryptoFunctionPointers(zrtpChannelContext);
/* if we have a self DHPart packet (means we are in DHM mode) we must rebuild the self DHPart packet to be responder and not initiator */
/* as responder we must swap the aux shared secret between responder and initiator as they are computed using the H3 and not a constant string */
......@@ -1632,7 +1632,7 @@ int bzrtp_responseToHelloMessage(bzrtpContext_t *zrtpContext, bzrtpChannelContex
}
/* now check we have some algo in common. zrtpChannelContext will be updated with common algos if found */
retval = crypoAlgoAgreement(zrtpContext, zrtpChannelContext, helloMessage);
retval = bzrtp_cryptoAlgoAgreement(zrtpContext, zrtpChannelContext, helloMessage);
if(retval != 0) {
bzrtp_freeZrtpPacket(zrtpPacket);
return retval;
......
......@@ -26,13 +26,6 @@ set(TEST_SOURCES
bzrtpConfigsTest.c
bzrtpTest.c
testUtils.c
../src/bzrtp.c
../src/cryptoUtils.c
../src/packetParser.c
../src/pgpwords.c
../src/stateMachine.c
../src/zidCache.c
)
bc_apply_compile_flags(TEST_SOURCES STRICT_OPTIONS_CPP)
......@@ -41,6 +34,11 @@ add_executable(bzrtpTest ${TEST_SOURCES})
set_target_properties(bzrtpTest PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
set_target_properties(bzrtpTest PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(bzrtpTest PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIR})
if(ENABLE_STATIC)
target_link_libraries(bzrtpTest bzrtp-static)
else()
target_link_libraries(bzrtpTest bzrtp)
endif()
target_link_libraries(bzrtpTest ${BCTOOLBOX_LIBRARIES})
if(HAVE_SQRT)
target_link_libraries(bzrtpTest m)
......
......@@ -468,7 +468,7 @@ void test_cacheless_exchange(void) {
{{ZRTP_CIPHER_AES3},1,{ZRTP_HASH_S256},1,{ZRTP_KEYAGREEMENT_DH2k},1,{ZRTP_SAS_B256},1,{ZRTP_AUTHTAG_HS32},1},
{{ZRTP_CIPHER_AES3},1,{ZRTP_HASH_S256},1,{ZRTP_KEYAGREEMENT_DH2k},1,{ZRTP_SAS_B256},1,{ZRTP_AUTHTAG_HS80},1},
{{},0,{},0,{},0,{},0,{},0}, /* this pattern will end the run because cipher nb is 0 */
{{0},0,{0},0,{0},0,{0},0,{0},0}, /* this pattern will end the run because cipher nb is 0 */
};
pattern = &patterns[0]; /* pattern is a pointer to current pattern */
......@@ -484,7 +484,7 @@ void test_cacheless_exchange(void) {
void test_loosy_network(void) {
int i,j;
resetGlobalParams();
srand(time(NULL));
srand((unsigned int)time(NULL));
/* run through all the configs 10 times to maximise chance to spot a random error based on a specific packet lost sequence */
for (j=0; j<10; j++) {
......
......@@ -184,7 +184,7 @@ static int testAlgoType(uint8_t algoType, uint8_t *packetTypes, uint8_t packetTy
setHelloMessageAlgo(helloMessage, algoType, packetTypes, packetTypesCount);
}
BC_ASSERT_FALSE(crypoAlgoAgreement(zrtpContext, zrtpContext->channelContext[0], helloPacket->messageData));
BC_ASSERT_FALSE(bzrtp_cryptoAlgoAgreement(zrtpContext, zrtpContext->channelContext[0], helloPacket->messageData));
retval = compareAllAlgoTypesWithExpectedChangedOnly(zrtpContext->channelContext[0], algoType, expectedType);
bzrtp_freeZrtpPacket(helloPacket);
......@@ -432,7 +432,7 @@ void test_algoSetterGetter(void) {
#define ZRTP_AUTHTAG_FAKE_5 0x45
static int testAddMandatoryCryptoTypesIfNeeded(uint8_t algoType, uint8_t *algoTypes, uint8_t algoTypesCount, uint8_t *expectedTypes, uint8_t expectedTypesCount) {
addMandatoryCryptoTypesIfNeeded(algoType, algoTypes, &algoTypesCount);
bzrtp_addMandatoryCryptoTypesIfNeeded(algoType, algoTypes, &algoTypesCount);
return compareAlgoTypes(algoTypes, algoTypesCount, expectedTypes, expectedTypesCount);
}
......
......@@ -142,8 +142,8 @@ void test_parser_param(uint8_t hvi_trick) {
context87654321->channelContext[0]->hashAlgo = ZRTP_HASH_S256;
context12345678->channelContext[0]->hashAlgo = ZRTP_HASH_S256;
updateCryptoFunctionPointers(context87654321->channelContext[0]);
updateCryptoFunctionPointers(context12345678->channelContext[0]);
bzrtp_updateCryptoFunctionPointers(context87654321->channelContext[0]);
bzrtp_updateCryptoFunctionPointers(context12345678->channelContext[0]);
/* set the zrtp and mac keys */
context87654321->channelContext[0]->mackeyi = (uint8_t *)malloc(32);
......@@ -465,7 +465,7 @@ void test_parserComplete() {
/* determine crypto Algo to use */
alice_HelloFromBob_message = (bzrtpHelloMessage_t *)alice_HelloFromBob->messageData;
retval = crypoAlgoAgreement(contextAlice, contextAlice->channelContext[0], contextAlice->channelContext[0]->peerPackets[HELLO_MESSAGE_STORE_ID]->messageData);
retval = bzrtp_cryptoAlgoAgreement(contextAlice, contextAlice->channelContext[0], contextAlice->channelContext[0]->peerPackets[HELLO_MESSAGE_STORE_ID]->messageData);
if (retval == 0) {
bzrtp_message ("Alice selected algo %x\n", contextAlice->channelContext[0]->keyAgreementAlgo);
memcpy(contextAlice->peerZID, alice_HelloFromBob_message->ZID, 12);
......@@ -492,7 +492,7 @@ void test_parserComplete() {
/* determine crypto Algo to use */
bob_HelloFromAlice_message = (bzrtpHelloMessage_t *)bob_HelloFromAlice->messageData;
retval = crypoAlgoAgreement(contextBob, contextBob->channelContext[0], contextBob->channelContext[0]->peerPackets[HELLO_MESSAGE_STORE_ID]->messageData);
retval = bzrtp_cryptoAlgoAgreement(contextBob, contextBob->channelContext[0], contextBob->channelContext[0]->peerPackets[HELLO_MESSAGE_STORE_ID]->messageData);
if (retval == 0) {
bzrtp_message ("Bob selected algo %x\n", contextBob->channelContext[0]->keyAgreementAlgo);
memcpy(contextBob->peerZID, bob_HelloFromAlice_message->ZID, 12);
......@@ -1328,7 +1328,7 @@ void test_parserComplete() {
contextAlice->channelContext[1]->keyAgreementAlgo = ZRTP_KEYAGREEMENT_Mult;
contextAlice->channelContext[1]->keyAgreementLength = 0; /* no public values exchanged in Multi channel mode */
updateCryptoFunctionPointers(contextAlice->channelContext[1]);
bzrtp_updateCryptoFunctionPointers(contextAlice->channelContext[1]);
} else {
bzrtp_message("ERROR : Alice found that Bob doesn't support multi channel\n");
}
......@@ -1368,7 +1368,7 @@ void test_parserComplete() {
contextBob->channelContext[1]->keyAgreementAlgo = ZRTP_KEYAGREEMENT_Mult;
contextBob->channelContext[1]->keyAgreementLength = 0; /* no public values exchanged in Multi channel mode */
updateCryptoFunctionPointers(contextBob->channelContext[1]);
bzrtp_updateCryptoFunctionPointers(contextBob->channelContext[1]);
} else {
bzrtp_message("ERROR : Bob found that Alice doesn't support multi channel\n");
}
......
......@@ -134,27 +134,27 @@ void packetDump(bzrtpPacket_t *zrtpPacket, uint8_t addRawMessage) {
printf ("S : %d - M : %d - P : %d\nhc : %x - cc : %x - ac : %x - kc : %x - sc : %x\n", messageData->S, messageData->M, messageData->P, messageData->hc, messageData->cc, messageData->ac, messageData->kc, messageData->sc);
printf ("hc ");
for (j=0; j<messageData->hc; j++) {
cryptoAlgoTypeIntToString(messageData->supportedHash[j], algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedHash[j], algoTypeString);
printf("%.4s, ", algoTypeString);
}
printf ("\ncc ");
for (j=0; j<messageData->cc; j++) {
cryptoAlgoTypeIntToString(messageData->supportedCipher[j], algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedCipher[j], algoTypeString);
printf("%.4s, ", algoTypeString);
}
printf ("\nac ");
for (j=0; j<messageData->ac; j++) {
cryptoAlgoTypeIntToString(messageData->supportedAuthTag[j], algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedAuthTag[j], algoTypeString);
printf("%.4s, ", algoTypeString);
}
printf ("\nkc ");
for (j=0; j<messageData->kc; j++) {
cryptoAlgoTypeIntToString(messageData->supportedKeyAgreement[j], algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedKeyAgreement[j], algoTypeString);
printf("%.4s, ", algoTypeString);
}
printf ("\nsc ");
for (j=0; j<messageData->sc; j++) {
cryptoAlgoTypeIntToString(messageData->supportedSas[j], algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->supportedSas[j], algoTypeString);
printf("%.4s, ", algoTypeString);
}
printHex("\nMAC", messageData->MAC, 8);
......@@ -177,15 +177,15 @@ void packetDump(bzrtpPacket_t *zrtpPacket, uint8_t addRawMessage) {
messageData = (bzrtpCommitMessage_t *)zrtpPacket->messageData;
printHex("H2", messageData->H2, 32);
printHex("ZID", messageData->ZID, 12);
cryptoAlgoTypeIntToString(messageData->hashAlgo, algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->hashAlgo, algoTypeString);
printf("Hash Algo: %.4s\n", algoTypeString);
cryptoAlgoTypeIntToString(messageData->cipherAlgo, algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->cipherAlgo, algoTypeString);
printf("Cipher Algo: %.4s\n", algoTypeString);
cryptoAlgoTypeIntToString(messageData->authTagAlgo, algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->authTagAlgo, algoTypeString);
printf("Auth tag Algo: %.4s\n", algoTypeString);
cryptoAlgoTypeIntToString(messageData->keyAgreementAlgo, algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->keyAgreementAlgo, algoTypeString);
printf("Key agreement Algo: %.4s\n", algoTypeString);
cryptoAlgoTypeIntToString(messageData->sasAlgo, algoTypeString);
bzrtp_cryptoAlgoTypeIntToString(messageData->sasAlgo, algoTypeString);
printf("Sas Algo: %.4s\n", algoTypeString);
/* if it is a multistream or preshared commit, get the 16 bytes nonce */
if ((messageData->keyAgreementAlgo == ZRTP_KEYAGREEMENT_Prsh) || (messageData->keyAgreementAlgo == ZRTP_KEYAGREEMENT_Mult)) {
......@@ -276,15 +276,15 @@ void dumpContext(char *title, bzrtpContext_t *zrtpContext) {
printHex(" ", channelContext->peerH[j], 32);
}
cryptoAlgoTypeIntToString(channelContext->hashAlgo, buffer);
bzrtp_cryptoAlgoTypeIntToString(channelContext->hashAlgo, buffer);
printf(" Selected algos\n - Hash: %.4s\n", buffer);
cryptoAlgoTypeIntToString(channelContext->cipherAlgo, buffer);
bzrtp_cryptoAlgoTypeIntToString(channelContext->cipherAlgo, buffer);
printf(" - cipher: %.4s\n", buffer);
cryptoAlgoTypeIntToString(channelContext->authTagAlgo, buffer);
bzrtp_cryptoAlgoTypeIntToString(channelContext->authTagAlgo, buffer);
printf(" - auth tag: %.4s\n", buffer);
cryptoAlgoTypeIntToString(channelContext->keyAgreementAlgo, buffer);
bzrtp_cryptoAlgoTypeIntToString(channelContext->keyAgreementAlgo, buffer);
printf(" - key agreement: %.4s\n", buffer);
cryptoAlgoTypeIntToString(channelContext->sasAlgo, buffer);
bzrtp_cryptoAlgoTypeIntToString(channelContext->sasAlgo, buffer);
printf(" - sas: %.4s\n", buffer);
printHex(" initiator auxID", channelContext->initiatorAuxsecretID, 8);
printHex(" responder auxID", channelContext->responderAuxsecretID, 8);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment