aboutsummaryrefslogtreecommitdiff
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-01-30 13:14:21 +0000
committerMichael Brown <mcb30@ipxe.org>2024-01-30 13:21:01 +0000
commit27398f136030efb8845c45fbe154e544feefd7e5 (patch)
tree11a7010a065c90bb0e0cd8040a158cf9cb41e09c /src/include/ipxe
parentde8a0821c7bc737e724fa3dfb6d89dc36f591d7a (diff)
downloadipxe-27398f136030efb8845c45fbe154e544feefd7e5.zip
ipxe-27398f136030efb8845c45fbe154e544feefd7e5.tar.gz
ipxe-27398f136030efb8845c45fbe154e544feefd7e5.tar.bz2
[crypto] Check for all-zeros result from X25519 key exchange
RFC7748 states that it is entirely optional for X25519 Diffie-Hellman implementations to check whether or not the result is the all-zero value (indicating that an attacker sent a malicious public key with a small order). RFC8422 states that implementations in TLS must abort the handshake if the all-zero value is obtained. Return an error if the all-zero value is obtained, so that the TLS code will not require knowledge specific to the X25519 curve. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/x25519.h6
2 files changed, 4 insertions, 3 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 320835a..060a42a 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -407,6 +407,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_efi_rng ( ERRFILE_OTHER | 0x005c0000 )
#define ERRFILE_efi_shim ( ERRFILE_OTHER | 0x005d0000 )
#define ERRFILE_efi_settings ( ERRFILE_OTHER | 0x005e0000 )
+#define ERRFILE_x25519 ( ERRFILE_OTHER | 0x005f0000 )
/** @} */
diff --git a/src/include/ipxe/x25519.h b/src/include/ipxe/x25519.h
index 7a86c11..6524abb 100644
--- a/src/include/ipxe/x25519.h
+++ b/src/include/ipxe/x25519.h
@@ -84,8 +84,8 @@ extern void x25519_multiply ( const union x25519_oct258 *multiplicand,
extern void x25519_invert ( const union x25519_oct258 *invertend,
union x25519_quad257 *result );
extern void x25519_reduce ( union x25519_quad257 *value );
-extern void x25519_key ( const struct x25519_value *base,
- const struct x25519_value *scalar,
- struct x25519_value *result );
+extern int x25519_key ( const struct x25519_value *base,
+ const struct x25519_value *scalar,
+ struct x25519_value *result );
#endif /* _IPXE_X25519_H */