Commit 543b9d63 authored by Ian Goldberg's avatar Ian Goldberg

Don't copy auth states on receipt of a COMMIT message

Similarly to the previous commit, if we receive a COMMIT message, we
should just use it to start a new SIGMA protocol, rather than comparing
it against the old COMMIT message we may have still lying around.  This
completely removes the need for the otrl_auth_copy_on_commit function.
parent a7dc24c2
......@@ -1426,41 +1426,6 @@ err:
return err;
}
/*
* Copy relevant information from the master OtrlAuthInfo to an
* instance OtrlAuthInfo in response to a D-H Commit with a new
* instance. The fields copied will depend on the state of the
* master auth.
*/
void otrl_auth_copy_on_commit(OtrlAuthInfo *m_auth, OtrlAuthInfo *auth)
{
switch(m_auth->authstate) {
case OTRL_AUTHSTATE_NONE:
case OTRL_AUTHSTATE_AWAITING_REVEALSIG:
auth->authstate = OTRL_AUTHSTATE_NONE;
break;
case OTRL_AUTHSTATE_AWAITING_DHKEY:
/* We sent a D-H Commit Message, and we also received one.
* Copy our D_H Commit and auth state */
otrl_dh_keypair_free(&(auth->our_dh));
auth->initiated = m_auth->initiated;
otrl_dh_keypair_copy(&(auth->our_dh), &(m_auth->our_dh));
auth->our_keyid = m_auth->our_keyid;
memmove(auth->r, m_auth->r, 16);
if (auth->encgx) free(auth->encgx);
auth->encgx = malloc(m_auth->encgx_len);
memmove(auth->encgx, m_auth->encgx, m_auth->encgx_len);
memmove(auth->hashgx, m_auth->hashgx, 32);
auth->authstate = OTRL_AUTHSTATE_AWAITING_DHKEY;
break;
default:
/* This bad state will be detected and handled later */
break;
}
}
/*
* Copy relevant information from the master OtrlAuthInfo to an
* instance OtrlAuthInfo in response to a D-H Key with a new
......
......@@ -159,14 +159,6 @@ gcry_error_t otrl_auth_handle_v1_key_exchange(OtrlAuthInfo *auth,
gcry_error_t (*auth_succeeded)(const OtrlAuthInfo *auth, void *asdata),
void *asdata);
/*
* Copy relevant information from the master OtrlAuthInfo to an
* instance OtrlAuthInfo in response to a D-H Commit with a new
* instance. The fields copied will depend on the state of the
* master auth.
*/
void otrl_auth_copy_on_commit(OtrlAuthInfo *m_auth, OtrlAuthInfo *auth);
/*
* Copy relevant information from the master OtrlAuthInfo to an
* instance OtrlAuthInfo in response to a D-H Key with a new
......
......@@ -1051,11 +1051,9 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
context->msgstate = m_context->msgstate;
}
if (msgtype == OTRL_MSGTYPE_DH_COMMIT) {
otrl_auth_copy_on_commit(&(m_context->auth), &(context->auth));
} else if (msgtype == OTRL_MSGTYPE_DH_KEY) {
if (msgtype == OTRL_MSGTYPE_DH_KEY) {
otrl_auth_copy_on_key(&(m_context->auth), &(context->auth));
} else {
} else if (msgtype != OTRL_MSGTYPE_DH_COMMIT) {
return 1; /* Ignore unexpected message */
}
......@@ -1073,14 +1071,6 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
context->auth.protocol_version = 3;
context->protocol_version = 3;
otrl_auth_copy_on_key(&(m_context->auth), &(context->auth));
} else if (msgtype == OTRL_MSGTYPE_DH_COMMIT &&
m_context->auth.authstate == OTRL_AUTHSTATE_AWAITING_DHKEY
&& !(context->auth.authstate ==
OTRL_AUTHSTATE_AWAITING_DHKEY)) {
context->msgstate = m_context->msgstate;
context->auth.protocol_version = 3;
context->protocol_version = 3;
otrl_auth_copy_on_commit(&(m_context->auth), &(context->auth));
}
}
}
......
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