Commit 2c042d0c authored by jehan's avatar jehan

rename bctoolbox_ to bctbx_

parent bdb6a10d
......@@ -189,8 +189,8 @@ struct bzrtpChannelContext_struct {
struct bzrtpContext_struct {
void *ZIDCacheData; /**< this is a pointer provided by the client which is then resent as a parameter of the ZID cache related callbacks functions. */
/* contexts */
bctoolbox_rng_context_t *RNGContext; /**< context for random number generation */
bctoolbox_DHMContext_t *DHMContext; /**< context for the Diffie-Hellman-Merkle operations. Only one DHM computation may be done during a call, so this belongs to the general context and not the channel one */
bctbx_rng_context_t *RNGContext; /**< context for random number generation */
bctbx_DHMContext_t *DHMContext; /**< context for the Diffie-Hellman-Merkle operations. Only one DHM computation may be done during a call, so this belongs to the general context and not the channel one */
/* flags */
uint8_t isInitialised; /**< this flag is set once the context was initialised : self ZID retrieved from cache or generated, used to unlock the creation of addtional channels */
......
......@@ -54,7 +54,7 @@ bzrtpContext_t *bzrtp_createBzrtpContext(void) {
memset(context, 0, sizeof(bzrtpContext_t));
/* start the random number generator */
context->RNGContext = bctoolbox_rng_context_new(); /* TODO: give a seed for the RNG? */
context->RNGContext = bctbx_rng_context_new(); /* TODO: give a seed for the RNG? */
/* set the DHM context to NULL, it will be created if needed when creating a DHPart packet */
context->DHMContext = NULL;
......@@ -167,7 +167,7 @@ int bzrtp_destroyBzrtpContext(bzrtpContext_t *context, uint32_t selfSSRC) {
/* We have no more channel, destroy the zrtp context */
/* DHM context shall already been destroyed after s0 computation, but just in case */
if (context->DHMContext != NULL) {
bctoolbox_DestroyDHMContext(context->DHMContext);
bctbx_DestroyDHMContext(context->DHMContext);
context->DHMContext = NULL;
}
......@@ -206,7 +206,7 @@ int bzrtp_destroyBzrtpContext(bzrtpContext_t *context, uint32_t selfSSRC) {
#endif
/* destroy the RNG context at the end because it may be needed to destroy some keys */
bctoolbox_rng_context_free(context->RNGContext);
bctbx_rng_context_free(context->RNGContext);
context->RNGContext = NULL;
free(context);
return 0;
......@@ -725,7 +725,7 @@ int bzrtp_setPeerHelloHash(bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8
if (zrtpChannelContext->peerPackets[HELLO_MESSAGE_STORE_ID] != NULL) {
uint8_t computedPeerHelloHash[32];
/* compute hash using implicit hash function: SHA256, skip packet header in the packetString buffer as the hash must be computed on message only */
bctoolbox_sha256(zrtpChannelContext->peerPackets[HELLO_MESSAGE_STORE_ID]->packetString+ZRTP_PACKET_HEADER_LENGTH,
bctbx_sha256(zrtpChannelContext->peerPackets[HELLO_MESSAGE_STORE_ID]->packetString+ZRTP_PACKET_HEADER_LENGTH,
zrtpChannelContext->peerPackets[HELLO_MESSAGE_STORE_ID]->messageLength,
32,
computedPeerHelloHash);
......@@ -853,7 +853,7 @@ int bzrtp_getSelfHelloHash(bzrtpContext_t *zrtpContext, uint32_t selfSSRC, uint8
}
/* compute hash using implicit hash function: SHA256, skip packet header in the packetString buffer as the hash must be computed on message only */
bctoolbox_sha256(zrtpChannelContext->selfPackets[HELLO_MESSAGE_STORE_ID]->packetString+ZRTP_PACKET_HEADER_LENGTH,
bctbx_sha256(zrtpChannelContext->selfPackets[HELLO_MESSAGE_STORE_ID]->packetString+ZRTP_PACKET_HEADER_LENGTH,
zrtpChannelContext->selfPackets[HELLO_MESSAGE_STORE_ID]->messageLength,
32,
helloHash);
......@@ -970,10 +970,10 @@ static int bzrtp_initChannelContext(bzrtpContext_t *zrtpContext, bzrtpChannelCon
zrtpChannelContext->role = INITIATOR;
/* create H0 (32 bytes random) and derive using implicit Hash(SHA256) H1,H2,H3 */
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpChannelContext->selfH[0], 32);
bctoolbox_sha256(zrtpChannelContext->selfH[0], 32, 32, zrtpChannelContext->selfH[1]);
bctoolbox_sha256(zrtpChannelContext->selfH[1], 32, 32, zrtpChannelContext->selfH[2]);
bctoolbox_sha256(zrtpChannelContext->selfH[2], 32, 32, zrtpChannelContext->selfH[3]);
bctbx_rng_get(zrtpContext->RNGContext, zrtpChannelContext->selfH[0], 32);
bctbx_sha256(zrtpChannelContext->selfH[0], 32, 32, zrtpChannelContext->selfH[1]);
bctbx_sha256(zrtpChannelContext->selfH[1], 32, 32, zrtpChannelContext->selfH[2]);
bctbx_sha256(zrtpChannelContext->selfH[2], 32, 32, zrtpChannelContext->selfH[3]);
/* initialisation of packet storage */
for (i=0; i<PACKET_STORAGE_CAPACITY; i++) {
......@@ -983,7 +983,7 @@ static int bzrtp_initChannelContext(bzrtpContext_t *zrtpContext, bzrtpChannelCon
zrtpChannelContext->peerHelloHash = NULL;
/* initialise the self Sequence number to a random and peer to 0 */
bctoolbox_rng_get(zrtpContext->RNGContext, (uint8_t *)&(zrtpChannelContext->selfSequenceNumber), 2);
bctbx_rng_get(zrtpContext->RNGContext, (uint8_t *)&(zrtpChannelContext->selfSequenceNumber), 2);
zrtpChannelContext->selfSequenceNumber &= 0x0FFF; /* first 4 bits to zero in order to avoid reaching FFFF and turning back to 0 */
zrtpChannelContext->selfSequenceNumber++; /* be sure it is not initialised to 0 */
zrtpChannelContext->peerSequenceNumber = 0;
......
......@@ -441,8 +441,8 @@ int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext) {
/* Hash algo */
switch (zrtpChannelContext->hashAlgo) {
case ZRTP_HASH_S256 :
zrtpChannelContext->hashFunction = bctoolbox_sha256;
zrtpChannelContext->hmacFunction = bctoolbox_hmacSha256;
zrtpChannelContext->hashFunction = bctbx_sha256;
zrtpChannelContext->hmacFunction = bctbx_hmacSha256;
zrtpChannelContext->hashLength = 32;
break;
case ZRTP_UNSET_ALGO :
......@@ -458,13 +458,13 @@ int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext) {
/* CipherBlock algo */
switch (zrtpChannelContext->cipherAlgo) {
case ZRTP_CIPHER_AES1 :
zrtpChannelContext->cipherEncryptionFunction = bctoolbox_aes128CfbEncrypt;
zrtpChannelContext->cipherDecryptionFunction = bctoolbox_aes128CfbDecrypt;
zrtpChannelContext->cipherEncryptionFunction = bctbx_aes128CfbEncrypt;
zrtpChannelContext->cipherDecryptionFunction = bctbx_aes128CfbDecrypt;
zrtpChannelContext->cipherKeyLength = 16;
break;
case ZRTP_CIPHER_AES3 :
zrtpChannelContext->cipherEncryptionFunction = bctoolbox_aes256CfbEncrypt;
zrtpChannelContext->cipherDecryptionFunction = bctoolbox_aes256CfbDecrypt;
zrtpChannelContext->cipherEncryptionFunction = bctbx_aes256CfbEncrypt;
zrtpChannelContext->cipherDecryptionFunction = bctbx_aes256CfbDecrypt;
zrtpChannelContext->cipherKeyLength = 32;
break;
case ZRTP_UNSET_ALGO :
......@@ -800,7 +800,7 @@ void cryptoAlgoTypeIntToString(uint8_t algoTypeInt, uint8_t algoTypeString[4]) {
*/
void bzrtp_DestroyKey(uint8_t *key, uint8_t keyLength, void *rngContext) {
if (key != NULL) {
bctoolbox_rng_get(rngContext, key, keyLength);
bctbx_rng_get(rngContext, key, keyLength);
}
}
......
This diff is collapsed.
......@@ -571,7 +571,7 @@ int state_keyAgreement_sendingCommit(bzrtpEvent_t event) {
/* Compute the shared DH secret */
zrtpContext->DHMContext->peer = (uint8_t *)malloc(zrtpChannelContext->keyAgreementLength*sizeof(uint8_t));
memcpy (zrtpContext->DHMContext->peer, dhPart1Message->pv, zrtpChannelContext->keyAgreementLength);
bctoolbox_DHMComputeSecret(zrtpContext->DHMContext, (int (*)(void *, uint8_t *, size_t))bctoolbox_rng_get, (void *)zrtpContext->RNGContext);
bctbx_DHMComputeSecret(zrtpContext->DHMContext, (int (*)(void *, uint8_t *, size_t))bctbx_rng_get, (void *)zrtpContext->RNGContext);
/* Derive the s0 key */
bzrtp_computeS0DHMMode(zrtpContext, zrtpChannelContext);
......@@ -861,7 +861,7 @@ int state_keyAgreement_responderSendingDHPart1(bzrtpEvent_t event) {
/* Compute the shared DH secret */
zrtpContext->DHMContext->peer = (uint8_t *)malloc(zrtpChannelContext->keyAgreementLength*sizeof(uint8_t));
memcpy (zrtpContext->DHMContext->peer, dhPart2Message->pv, zrtpChannelContext->keyAgreementLength);
bctoolbox_DHMComputeSecret(zrtpContext->DHMContext, (int (*)(void *, uint8_t *, size_t))bctoolbox_rng_get, (void *)zrtpContext->RNGContext);
bctbx_DHMComputeSecret(zrtpContext->DHMContext, (int (*)(void *, uint8_t *, size_t))bctbx_rng_get, (void *)zrtpContext->RNGContext);
/* Derive the s0 key */
bzrtp_computeS0DHMMode(zrtpContext, zrtpChannelContext);
......@@ -1666,16 +1666,16 @@ int bzrtp_responseToHelloMessage(bzrtpContext_t *zrtpContext, bzrtpChannelContex
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.rs1, zrtpContext->cachedSecret.rs1Length, (uint8_t *)"Initiator", 9, 8, zrtpContext->initiatorCachedSecretHash.rs1ID);
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.rs1, zrtpContext->cachedSecret.rs1Length, (uint8_t *)"Responder", 9, 8, zrtpContext->responderCachedSecretHash.rs1ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.rs1ID, 8);
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.rs1ID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.rs1ID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.rs1ID, 8);
}
if (zrtpContext->cachedSecret.rs2!=NULL) {
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.rs2, zrtpContext->cachedSecret.rs2Length, (uint8_t *)"Initiator", 9, 8, zrtpContext->initiatorCachedSecretHash.rs2ID);
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.rs2, zrtpContext->cachedSecret.rs2Length, (uint8_t *)"Responder", 9, 8, zrtpContext->responderCachedSecretHash.rs2ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.rs2ID, 8);
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.rs2ID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.rs2ID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.rs2ID, 8);
}
......@@ -1683,16 +1683,16 @@ int bzrtp_responseToHelloMessage(bzrtpContext_t *zrtpContext, bzrtpChannelContex
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.pbxsecret, zrtpContext->cachedSecret.pbxsecretLength, (uint8_t *)"Initiator", 9, 8, zrtpContext->initiatorCachedSecretHash.pbxsecretID);
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.pbxsecret, zrtpContext->cachedSecret.pbxsecretLength, (uint8_t *)"Responder", 9, 8, zrtpContext->responderCachedSecretHash.pbxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.pbxsecretID, 8);
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->initiatorCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpContext->responderCachedSecretHash.pbxsecretID, 8);
}
if (zrtpContext->cachedSecret.auxsecret!=NULL) {
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.auxsecret, zrtpContext->cachedSecret.auxsecretLength, zrtpChannelContext->selfH[3], 32, 8, zrtpChannelContext->initiatorAuxsecretID);
zrtpChannelContext->hmacFunction(zrtpContext->cachedSecret.auxsecret, zrtpContext->cachedSecret.auxsecretLength, zrtpChannelContext->peerH[3], 32, 8, zrtpChannelContext->responderAuxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpChannelContext->initiatorAuxsecretID, 8);
bctoolbox_rng_get(zrtpContext->RNGContext, zrtpChannelContext->responderAuxsecretID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpChannelContext->initiatorAuxsecretID, 8);
bctbx_rng_get(zrtpContext->RNGContext, zrtpChannelContext->responderAuxsecretID, 8);
}
}
......@@ -1910,7 +1910,7 @@ int bzrtp_computeS0DHMMode(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *z
zrtpContext->ZRTPSess);
/* clean the DHM context (secret and key shall be erased by this operation) */
bctoolbox_DestroyDHMContext(zrtpContext->DHMContext);
bctbx_DestroyDHMContext(zrtpContext->DHMContext);
zrtpContext->DHMContext = NULL;
/* now derive the other keys */
......
......@@ -58,7 +58,7 @@ int bzrtp_getSelfZID(bzrtpContext_t *context, uint8_t selfZID[12]) {
if (cb!=NULL) cb(cacheStringBuffer);
} else {
/* we are running cacheless, return a random number */
bctoolbox_rng_get(context->RNGContext, selfZID, 12);
bctbx_rng_get(context->RNGContext, selfZID, 12);
return 0;
}
......@@ -87,7 +87,7 @@ int bzrtp_getSelfZID(bzrtpContext_t *context, uint8_t selfZID[12]) {
xmlNodePtr rootNode;
/* generate a random ZID */
bctoolbox_rng_get(context->RNGContext, selfZID, 12);
bctbx_rng_get(context->RNGContext, selfZID, 12);
/* convert it to an Hexa String */
bzrtp_int8ToStr(newZidHex, selfZID, 12);
newZidHex[24] = '\0'; /* the string must be null terminated for libxml2 to add it correctly in the element */
......@@ -352,7 +352,7 @@ int bzrtp_getSelfZID(bzrtpContext_t *context, uint8_t selfZID[12]) {
return ZRTP_ZIDCACHE_INVALID_CONTEXT;
}
/* we are running cacheless, return a random number */
bctoolbox_rng_get(context->RNGContext, selfZID, 12);
bctbx_rng_get(context->RNGContext, selfZID, 12);
return 0;
}
int bzrtp_getPeerAssociatedSecretsHash(bzrtpContext_t *context, uint8_t peerZID[12]) {
......
......@@ -84,7 +84,7 @@ void test_zrtpKDF(void) {
patternKDFLabel[i], strlen((char *)patternKDFLabel[i]),
patternKDFContext[i], patternKDFContextLength[i],
patternKDFHmacLength[i],
(void (*)(uint8_t *, uint8_t, uint8_t *, uint32_t, uint8_t, uint8_t *))bctoolbox_hmacSha256,
(void (*)(uint8_t *, uint8_t, uint8_t *, uint32_t, uint8_t, uint8_t *))bctbx_hmacSha256,
output);
CU_ASSERT_TRUE(memcmp(output, patternKDFOutput[i], patternKDFHmacLength[i]) == 0);
......
......@@ -527,49 +527,49 @@ void test_parserComplete() {
if (contextAlice->cachedSecret.rs1!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.rs1, contextAlice->cachedSecret.rs1Length, (uint8_t *)"Initiator", 9, 8, contextAlice->initiatorCachedSecretHash.rs1ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.rs1ID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.rs1ID, 8);
}
if (contextAlice->cachedSecret.rs2!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.rs2, contextAlice->cachedSecret.rs2Length, (uint8_t *)"Initiator", 9, 8, contextAlice->initiatorCachedSecretHash.rs2ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.rs2ID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.rs2ID, 8);
}
if (contextAlice->cachedSecret.auxsecret!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.auxsecret, contextAlice->cachedSecret.auxsecretLength, contextAlice->channelContext[0]->selfH[3], 32, 8, contextAlice->channelContext[0]->initiatorAuxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->channelContext[0]->initiatorAuxsecretID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->channelContext[0]->initiatorAuxsecretID, 8);
}
if (contextAlice->cachedSecret.pbxsecret!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.pbxsecret, contextAlice->cachedSecret.pbxsecretLength, (uint8_t *)"Initiator", 9, 8, contextAlice->initiatorCachedSecretHash.pbxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->initiatorCachedSecretHash.pbxsecretID, 8);
}
if (contextAlice->cachedSecret.rs1!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.rs1, contextAlice->cachedSecret.rs1Length, (uint8_t *)"Responder", 9, 8, contextAlice->responderCachedSecretHash.rs1ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.rs1ID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.rs1ID, 8);
}
if (contextAlice->cachedSecret.rs2!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.rs2, contextAlice->cachedSecret.rs2Length, (uint8_t *)"Responder", 9, 8, contextAlice->responderCachedSecretHash.rs2ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.rs2ID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.rs2ID, 8);
}
if (contextAlice->cachedSecret.auxsecret!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.auxsecret, contextAlice->cachedSecret.auxsecretLength, contextAlice->channelContext[0]->peerH[3], 32, 8, contextAlice->channelContext[0]->responderAuxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->channelContext[0]->responderAuxsecretID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->channelContext[0]->responderAuxsecretID, 8);
}
if (contextAlice->cachedSecret.pbxsecret!=NULL) {
contextAlice->channelContext[0]->hmacFunction(contextAlice->cachedSecret.pbxsecret, contextAlice->cachedSecret.pbxsecretLength, (uint8_t *)"Responder", 9, 8, contextAlice->responderCachedSecretHash.pbxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(contextAlice->RNGContext, contextAlice->responderCachedSecretHash.pbxsecretID, 8);
}
......@@ -577,49 +577,49 @@ void test_parserComplete() {
if (contextBob->cachedSecret.rs1!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.rs1, contextBob->cachedSecret.rs1Length, (uint8_t *)"Initiator", 9, 8, contextBob->initiatorCachedSecretHash.rs1ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.rs1ID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.rs1ID, 8);
}
if (contextBob->cachedSecret.rs2!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.rs2, contextBob->cachedSecret.rs2Length, (uint8_t *)"Initiator", 9, 8, contextBob->initiatorCachedSecretHash.rs2ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.rs2ID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.rs2ID, 8);
}
if (contextBob->cachedSecret.auxsecret!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.auxsecret, contextBob->cachedSecret.auxsecretLength, contextBob->channelContext[0]->selfH[3], 32, 8, contextBob->channelContext[0]->initiatorAuxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->channelContext[0]->initiatorAuxsecretID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->channelContext[0]->initiatorAuxsecretID, 8);
}
if (contextBob->cachedSecret.pbxsecret!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.pbxsecret, contextBob->cachedSecret.pbxsecretLength, (uint8_t *)"Initiator", 9, 8, contextBob->initiatorCachedSecretHash.pbxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->initiatorCachedSecretHash.pbxsecretID, 8);
}
if (contextBob->cachedSecret.rs1!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.rs1, contextBob->cachedSecret.rs1Length, (uint8_t *)"Responder", 9, 8, contextBob->responderCachedSecretHash.rs1ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.rs1ID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.rs1ID, 8);
}
if (contextBob->cachedSecret.rs2!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.rs2, contextBob->cachedSecret.rs2Length, (uint8_t *)"Responder", 9, 8, contextBob->responderCachedSecretHash.rs2ID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.rs2ID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.rs2ID, 8);
}
if (contextBob->cachedSecret.auxsecret!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.auxsecret, contextBob->cachedSecret.auxsecretLength, contextBob->channelContext[0]->peerH[3], 32, 8, contextBob->channelContext[0]->responderAuxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->channelContext[0]->responderAuxsecretID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->channelContext[0]->responderAuxsecretID, 8);
}
if (contextBob->cachedSecret.pbxsecret!=NULL) {
contextBob->channelContext[0]->hmacFunction(contextBob->cachedSecret.pbxsecret, contextBob->cachedSecret.pbxsecretLength, (uint8_t *)"Responder", 9, 8, contextBob->responderCachedSecretHash.pbxsecretID);
} else { /* we have no secret, generate a random */
bctoolbox_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.pbxsecretID, 8);
bctbx_rng_get(contextBob->RNGContext, contextBob->responderCachedSecretHash.pbxsecretID, 8);
}
/* dump alice's packet on both sides */
......@@ -806,7 +806,7 @@ void test_parserComplete() {
/* Compute the shared DH secret */
contextAlice->DHMContext->peer = (uint8_t *)malloc(contextAlice->channelContext[0]->keyAgreementLength*sizeof(uint8_t));
memcpy (contextAlice->DHMContext->peer, alice_DHPart1FromBob_message->pv, contextAlice->channelContext[0]->keyAgreementLength);
bctoolbox_DHMComputeSecret(contextAlice->DHMContext, (int (*)(void *, uint8_t *, size_t))bctoolbox_rng_get, (void *)contextAlice->RNGContext);
bctbx_DHMComputeSecret(contextAlice->DHMContext, (int (*)(void *, uint8_t *, size_t))bctbx_rng_get, (void *)contextAlice->RNGContext);
/* So Alice send bob her DHPart2 message which is already prepared and stored (we just need to update the sequence number) */
bzrtp_packetUpdateSequenceNumber(contextAlice->channelContext[0]->selfPackets[DHPART_MESSAGE_STORE_ID], contextAlice->channelContext[0]->selfSequenceNumber);
......@@ -860,7 +860,7 @@ void test_parserComplete() {
/* Compute the shared DH secret */
contextBob->DHMContext->peer = (uint8_t *)malloc(contextBob->channelContext[0]->keyAgreementLength*sizeof(uint8_t));
memcpy (contextBob->DHMContext->peer, bob_DHPart2FromAlice_message->pv, contextBob->channelContext[0]->keyAgreementLength);
bctoolbox_DHMComputeSecret(contextBob->DHMContext, (int (*)(void *, uint8_t *, size_t))bctoolbox_rng_get, (void *)contextAlice->RNGContext);
bctbx_DHMComputeSecret(contextBob->DHMContext, (int (*)(void *, uint8_t *, size_t))bctbx_rng_get, (void *)contextAlice->RNGContext);
/* JUST FOR TEST: check that the generated secrets are the same */
......
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