Skip to content

Commit

Permalink
Move clamping fix back into the curve22519 crypto routine.
Browse files Browse the repository at this point in the history
This reverts b5f7915 and is broader. Based on a suggestion
from Jason Donenfeld.

The calls to the clamping routine now match the OpenBSD curve22519 code.
  • Loading branch information
grehan-freebsd committed Jan 27, 2021
1 parent 4a7a2c1 commit b6caeef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions sys/dev/if_wg/module/curve25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ void curve25519_generic(u8 out[CURVE25519_KEY_SIZE],
u8 e[32];

memcpy(e, scalar, 32);
curve25519_clamp_secret(e);

/* The following implementation was transcribed to Coq and proven to
* correspond to unary scalar multiplication in affine coordinates given
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/if_wg/module/wg_noise.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ noise_local_set_private(struct noise_local *l, uint8_t private[NOISE_KEY_SIZE])

memcpy(l->l_private, private, NOISE_KEY_SIZE);
curve25519_clamp_secret(l->l_private);
l->l_has_identity = curve25519_generate_public(l->l_public, l->l_private);
l->l_has_identity = curve25519_generate_public(l->l_public, private);

return l->l_has_identity ? 0 : ENXIO;
}
Expand Down

0 comments on commit b6caeef

Please sign in to comment.