diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-06-20 14:41:26 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-06-20 14:41:26 +0000 |
commit | 57d95c73256176bfd5cd3ef003c062697435f9c2 (patch) | |
tree | f48bdb80188b8af7962ff7143e1732fc5dfc8d01 /sys/include | |
parent | 6dd2c638b6fa9f891836cd2fceb3e4f996f6e199 (diff) |
libsec: move zero check to curve25519_dh_finish()
As checking for all zero has to be done in a timing-safe
way to avoid a side channel, it is best todo this here
instead of letting the caller deal with it.
This adds a return type of int to curve25519_dh_finish()
where returning 0 means we got a all zero shared key.
RFC7748 states:
The check for the all-zero value results from the fact
that the X25519 function produces that value if it
operates on an input corresponding to a point with small
order, where the order divides the cofactor of the curve.
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/ape/libsec.h | 2 | ||||
-rw-r--r-- | sys/include/libsec.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/include/ape/libsec.h b/sys/include/ape/libsec.h index 6f44db92d..d44ff0cde 100644 --- a/sys/include/ape/libsec.h +++ b/sys/include/ape/libsec.h @@ -583,7 +583,7 @@ void curve25519(uchar mypublic[32], uchar secret[32], uchar basepoint[32]); /* Curve25519 diffie hellman */ void curve25519_dh_new(uchar x[32], uchar y[32]); -void curve25519_dh_finish(uchar x[32], uchar y[32], uchar z[32]); +int curve25519_dh_finish(uchar x[32], uchar y[32], uchar z[32]); /* password-based key derivation function 2 (rfc2898) */ void pbkdf2_x(uchar *p, ulong plen, uchar *s, ulong slen, ulong rounds, uchar *d, ulong dlen, diff --git a/sys/include/libsec.h b/sys/include/libsec.h index b19d18a76..bebcc98fe 100644 --- a/sys/include/libsec.h +++ b/sys/include/libsec.h @@ -575,7 +575,7 @@ void curve25519(uchar mypublic[32], uchar secret[32], uchar basepoint[32]); /* Curve25519 diffie hellman */ void curve25519_dh_new(uchar x[32], uchar y[32]); -void curve25519_dh_finish(uchar x[32], uchar y[32], uchar z[32]); +int curve25519_dh_finish(uchar x[32], uchar y[32], uchar z[32]); /* password-based key derivation function 2 (rfc2898) */ void pbkdf2_x(uchar *p, ulong plen, uchar *s, ulong slen, ulong rounds, uchar *d, ulong dlen, |