Commit d5003fd9 authored by johan's avatar johan

PVS flag must be set only when both parts set it at last call

parent 40e9a1ac
......@@ -247,6 +247,7 @@ struct bzrtpContext_struct {
cachedSecretsHash_t initiatorCachedSecretHash; /**< The hash of cached secret from initiator side, computed as described in rfc section 4.3.1 */
cachedSecretsHash_t responderCachedSecretHash; /**< The hash of cached secret from responder side, computed as described in rfc section 4.3.1 */
uint8_t cacheMismatchFlag; /**< Flag set in case of cache mismatch(detected in DHM mode when DH part packet arrives) */
uint8_t peerPVS; /**< used to store value of PVS flag sent by peer in the confirm packet on first channel only, then used to compute the PVS value sent to the application */
/* keys */
uint8_t *ZRTPSess; /**< ZRTP session key as described in rfc section 4.5.2 */
......
......@@ -97,6 +97,7 @@ bzrtpContext_t *bzrtp_createBzrtpContext(void) {
context->cachedSecret.auxsecret = NULL;
context->cachedSecret.auxsecretLength = 0;
context->cacheMismatchFlag = 0;
context->peerPVS = 0;
/* initialise key buffers */
context->ZRTPSess = NULL;
......
......@@ -986,6 +986,10 @@ int state_keyAgreement_initiatorSendingDHPart2(bzrtpEvent_t event) {
/* update context with the information found in the packet */
confirm1Packet = (bzrtpConfirmMessage_t *)zrtpPacket->messageData;
memcpy(zrtpChannelContext->peerH[0], confirm1Packet->H0, 32);
/* on the first channel, set peerPVS in context */
if (zrtpChannelContext->keyAgreementAlgo != ZRTP_KEYAGREEMENT_Mult) {
zrtpContext->peerPVS=confirm1Packet->V;
}
/* store the packet to check possible repetitions */
zrtpChannelContext->peerPackets[CONFIRM_MESSAGE_STORE_ID] = zrtpPacket;
......@@ -1195,6 +1199,10 @@ int state_confirmation_responderSendingConfirm1(bzrtpEvent_t event) {
/* update context with the information found in the packet */
confirm2Packet = (bzrtpConfirmMessage_t *)zrtpPacket->messageData;
memcpy(zrtpChannelContext->peerH[0], confirm2Packet->H0, 32);
/* on the first channel, set peerPVS in context */
if (zrtpChannelContext->keyAgreementAlgo != ZRTP_KEYAGREEMENT_Mult) {
zrtpContext->peerPVS = confirm2Packet->V;
}
/* store the packet to check possible repetitions : note the storage points to confirm1, delete it as we don't need it anymore */
bzrtp_freeZrtpPacket(zrtpChannelContext->peerPackets[CONFIRM_MESSAGE_STORE_ID]);
......@@ -1462,7 +1470,7 @@ int state_secure(bzrtpEvent_t event) {
/* call the environment to signal we're ready to operate */
if (zrtpContext->zrtpCallbacks.bzrtp_startSrtpSession!= NULL) {
zrtpContext->zrtpCallbacks.bzrtp_startSrtpSession(zrtpChannelContext->clientData, &(zrtpChannelContext->srtpSecrets), zrtpContext->cachedSecret.previouslyVerifiedSas);
zrtpContext->zrtpCallbacks.bzrtp_startSrtpSession(zrtpChannelContext->clientData, &(zrtpChannelContext->srtpSecrets), zrtpContext->cachedSecret.previouslyVerifiedSas && zrtpContext->peerPVS);
}
return 0;
}
......
This diff is collapsed.
......@@ -23,4 +23,5 @@ void test_cacheless_exchange(void);
void test_loosy_network(void);
void test_cache_enabled_exchange(void);
void test_cache_mismatch_exchange(void);
void test_cache_sas_not_confirmed(void);
......@@ -86,7 +86,8 @@ test_t key_exchange_tests[] = {
TEST_NO_TAG("Cacheless multi channel", test_cacheless_exchange),
TEST_NO_TAG("Cached Simple", test_cache_enabled_exchange),
TEST_NO_TAG("Cached mismatch", test_cache_mismatch_exchange),
TEST_NO_TAG("Loosy network", test_loosy_network)
TEST_NO_TAG("Loosy network", test_loosy_network),
TEST_NO_TAG("Cached PVS", test_cache_sas_not_confirmed)
};
test_suite_t key_exchange_test_suite = {
......
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