Permalink
Browse files

Breaking change to the kx_kk_3() API

Last DH should be `se`, not `es`.

Fixes #32
  • Loading branch information...
jedisct1 committed Jan 24, 2019
1 parent 2b2632f commit 471b749d336b2e20e20adae9a8f0bb722e2cedab
Showing with 5 additions and 5 deletions.
  1. +1 −1 hydrogen.h
  2. +3 −3 impl/kx.h
  3. +1 −1 tests/tests.c
@@ -219,7 +219,7 @@ int hydro_kx_kk_2(hydro_kx_session_keypair *kp, uint8_t packet2[hydro_kx_KK_PACK

int hydro_kx_kk_3(hydro_kx_state *state, hydro_kx_session_keypair *kp,
const uint8_t packet2[hydro_kx_KK_PACKET2BYTES],
const uint8_t peer_static_pk[hydro_kx_PUBLICKEYBYTES]);
const hydro_kx_keypair *static_kp);

/* NOISE_XX */

@@ -306,7 +306,7 @@ hydro_kx_kk_2(hydro_kx_session_keypair *kp, uint8_t packet2[hydro_kx_KK_PACKET2B
if (hydro_kx_scalarmult(&state, dh_res, state.eph_kp.sk, peer_eph_pk) != 0) {
return -1;
}
if (hydro_kx_scalarmult(&state, dh_res, static_kp->sk, peer_eph_pk) != 0) {
if (hydro_kx_scalarmult(&state, dh_res, state.eph_kp.sk, peer_static_pk) != 0) {
return -1;
}
hydro_kx_final(&state, kp->rx, kp->tx);
@@ -317,15 +317,15 @@ hydro_kx_kk_2(hydro_kx_session_keypair *kp, uint8_t packet2[hydro_kx_KK_PACKET2B
int
hydro_kx_kk_3(hydro_kx_state *state, hydro_kx_session_keypair *kp,
const uint8_t packet2[hydro_kx_KK_PACKET2BYTES],
const uint8_t peer_static_pk[hydro_kx_PUBLICKEYBYTES])
const hydro_kx_keypair *static_kp)
{
uint8_t dh_res[hydro_x25519_BYTES];
const uint8_t *peer_eph_pk = packet2;

if (hydro_kx_scalarmult(state, dh_res, state->eph_kp.sk, peer_eph_pk) != 0) {
return -1;
}
if (hydro_kx_scalarmult(state, dh_res, state->eph_kp.sk, peer_static_pk) != 0) {
if (hydro_kx_scalarmult(state, dh_res, static_kp->sk, peer_eph_pk) != 0) {
return -1;
}
hydro_kx_final(state, kp->tx, kp->rx);
@@ -314,7 +314,7 @@ test_kx_kk(void)

hydro_kx_kk_1(&st_client, packet1, server_static_kp.pk, &client_static_kp);
hydro_kx_kk_2(&kp_server, packet2, packet1, client_static_kp.pk, &server_static_kp);
hydro_kx_kk_3(&st_client, &kp_client, packet2, server_static_kp.pk);
hydro_kx_kk_3(&st_client, &kp_client, packet2, &client_static_kp);

assert(hydro_equal(kp_client.tx, kp_server.rx, hydro_kx_SESSIONKEYBYTES));
assert(hydro_equal(kp_client.rx, kp_server.tx, hydro_kx_SESSIONKEYBYTES));

0 comments on commit 471b749

Please sign in to comment.