|
Dmitry Belyavskiy |
15a324 |
diff --git a/kexmlkem768x25519.c b/kexmlkem768x25519.c
|
|
Dmitry Belyavskiy |
15a324 |
index 679446e9..2b5d3960 100644
|
|
Dmitry Belyavskiy |
15a324 |
--- a/kexmlkem768x25519.c
|
|
Dmitry Belyavskiy |
15a324 |
+++ b/kexmlkem768x25519.c
|
|
Dmitry Belyavskiy |
15a324 |
@@ -1,4 +1,4 @@
|
|
Dmitry Belyavskiy |
15a324 |
-/* $OpenBSD: kexmlkem768x25519.c,v 1.1 2024/09/02 12:13:56 djm Exp $ */
|
|
Dmitry Belyavskiy |
15a324 |
+/* $OpenBSD: kexmlkem768x25519.c,v 1.2 2024/10/27 02:06:59 djm Exp $ */
|
|
Dmitry Belyavskiy |
15a324 |
/*
|
|
Dmitry Belyavskiy |
15a324 |
* Copyright (c) 2023 Markus Friedl. All rights reserved.
|
|
Dmitry Belyavskiy |
15a324 |
*
|
|
Dmitry Belyavskiy |
15a324 |
@@ -34,6 +34,9 @@
|
|
Dmitry Belyavskiy |
15a324 |
#include <stdbool.h>
|
|
Dmitry Belyavskiy |
15a324 |
#include <string.h>
|
|
Dmitry Belyavskiy |
15a324 |
#include <signal.h>
|
|
Dmitry Belyavskiy |
15a324 |
+#ifdef HAVE_ENDIAN_H
|
|
Dmitry Belyavskiy |
15a324 |
+# include <endian.h>
|
|
Dmitry Belyavskiy |
15a324 |
+#endif
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
#include "sshkey.h"
|
|
Dmitry Belyavskiy |
15a324 |
#include "kex.h"
|
|
Dmitry Belyavskiy |
15a324 |
diff --git a/libcrux_mlkem768_sha3.h b/libcrux_mlkem768_sha3.h
|
|
Dmitry Belyavskiy |
15a324 |
index a82d60e8..b8ac1436 100644
|
|
Dmitry Belyavskiy |
15a324 |
--- a/libcrux_mlkem768_sha3.h
|
|
Dmitry Belyavskiy |
15a324 |
+++ b/libcrux_mlkem768_sha3.h
|
|
Dmitry Belyavskiy |
15a324 |
@@ -1,4 +1,5 @@
|
|
Dmitry Belyavskiy |
15a324 |
-/* $OpenBSD: libcrux_mlkem768_sha3.h,v 1.1 2024/09/02 12:13:56 djm Exp $ */
|
|
Dmitry Belyavskiy |
15a324 |
+/* $OpenBSD: libcrux_mlkem768_sha3.h,v 1.2 2024/10/27 02:06:01 djm Exp $ */
|
|
Dmitry Belyavskiy |
15a324 |
+
|
|
Dmitry Belyavskiy |
15a324 |
/* Extracted from libcrux revision 84c5d87b3092c59294345aa269ceefe0eb97cc35 */
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
/*
|
|
Dmitry Belyavskiy |
15a324 |
@@ -160,18 +161,19 @@ static inline void Eurydice_slice_to_array3(uint8_t *dst_tag, char *dst_ok,
|
|
Dmitry Belyavskiy |
15a324 |
// CORE STUFF (conversions, endianness, ...)
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
static inline void core_num__u64_9__to_le_bytes(uint64_t v, uint8_t buf[8]) {
|
|
Dmitry Belyavskiy |
15a324 |
+ v = htole64(v);
|
|
Dmitry Belyavskiy |
15a324 |
memcpy(buf, &v, sizeof(v));
|
|
Dmitry Belyavskiy |
15a324 |
}
|
|
Dmitry Belyavskiy |
15a324 |
static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t buf[8]) {
|
|
Dmitry Belyavskiy |
15a324 |
uint64_t v;
|
|
Dmitry Belyavskiy |
15a324 |
memcpy(&v, buf, sizeof(v));
|
|
Dmitry Belyavskiy |
15a324 |
- return v;
|
|
Dmitry Belyavskiy |
15a324 |
+ return le64toh(v);
|
|
Dmitry Belyavskiy |
15a324 |
}
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
static inline uint32_t core_num__u32_8__from_le_bytes(uint8_t buf[4]) {
|
|
Dmitry Belyavskiy |
15a324 |
uint32_t v;
|
|
Dmitry Belyavskiy |
15a324 |
memcpy(&v, buf, sizeof(v));
|
|
Dmitry Belyavskiy |
15a324 |
- return v;
|
|
Dmitry Belyavskiy |
15a324 |
+ return le32toh(v);
|
|
Dmitry Belyavskiy |
15a324 |
}
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
static inline uint32_t core_num__u8_6__count_ones(uint8_t x0) {
|
|
Dmitry Belyavskiy |
15a324 |
diff --git a/mlkem768.sh b/mlkem768.sh
|
|
Dmitry Belyavskiy |
15a324 |
index 2fdc2831..3d12b2ed 100644
|
|
Dmitry Belyavskiy |
15a324 |
--- a/mlkem768.sh
|
|
Dmitry Belyavskiy |
15a324 |
+++ b/mlkem768.sh
|
|
Dmitry Belyavskiy |
15a324 |
@@ -1,9 +1,10 @@
|
|
Dmitry Belyavskiy |
15a324 |
#!/bin/sh
|
|
Dmitry Belyavskiy |
15a324 |
-# $OpenBSD: mlkem768.sh,v 1.2 2024/09/04 05:11:33 djm Exp $
|
|
Dmitry Belyavskiy |
15a324 |
+# $OpenBSD: mlkem768.sh,v 1.3 2024/10/27 02:06:01 djm Exp $
|
|
Dmitry Belyavskiy |
15a324 |
# Placed in the Public Domain.
|
|
Dmitry Belyavskiy |
15a324 |
#
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
-WANT_LIBCRUX_REVISION="origin/main"
|
|
Dmitry Belyavskiy |
15a324 |
+#WANT_LIBCRUX_REVISION="origin/main"
|
|
Dmitry Belyavskiy |
15a324 |
+WANT_LIBCRUX_REVISION="84c5d87b3092c59294345aa269ceefe0eb97cc35"
|
|
Dmitry Belyavskiy |
15a324 |
|
|
Dmitry Belyavskiy |
15a324 |
FILES="
|
|
Dmitry Belyavskiy |
15a324 |
libcrux/libcrux-ml-kem/cg/eurydice_glue.h
|
|
Dmitry Belyavskiy |
15a324 |
@@ -47,6 +48,7 @@ echo '#define KRML_NOINLINE __attribute__((noinline, unused))'
|
|
Dmitry Belyavskiy |
15a324 |
echo '#define KRML_HOST_EPRINTF(...)'
|
|
Dmitry Belyavskiy |
15a324 |
echo '#define KRML_HOST_EXIT(x) fatal_f("internal error")'
|
|
Dmitry Belyavskiy |
15a324 |
echo
|
|
Dmitry Belyavskiy |
15a324 |
+
|
|
Dmitry Belyavskiy |
15a324 |
for i in $FILES; do
|
|
Dmitry Belyavskiy |
15a324 |
echo "/* from $i */"
|
|
Dmitry Belyavskiy |
15a324 |
# Changes to all files:
|
|
Dmitry Belyavskiy |
15a324 |
@@ -56,11 +58,16 @@ for i in $FILES; do
|
|
Dmitry Belyavskiy |
15a324 |
-e 's/[ ]*$//' \
|
|
Dmitry Belyavskiy |
15a324 |
$i | \
|
|
Dmitry Belyavskiy |
15a324 |
case "$i" in
|
|
Dmitry Belyavskiy |
15a324 |
- # XXX per-file handling goes here.
|
|
Dmitry Belyavskiy |
15a324 |
+ */libcrux-ml-kem/cg/eurydice_glue.h)
|
|
Dmitry Belyavskiy |
15a324 |
+ # Replace endian functions with versions that work.
|
|
Dmitry Belyavskiy |
15a324 |
+ perl -0777 -pe 's/(static inline void core_num__u64_9__to_le_bytes.*\n)([^}]*\n)/\1 v = htole64(v);\n\2/' |
|
|
Dmitry Belyavskiy |
15a324 |
+ perl -0777 -pe 's/(static inline uint64_t core_num__u64_9__from_le_bytes.*?)return v;/\1return le64toh(v);/s' |
|
|
Dmitry Belyavskiy |
15a324 |
+ perl -0777 -pe 's/(static inline uint32_t core_num__u32_8__from_le_bytes.*?)return v;/\1return le32toh(v);/s'
|
|
Dmitry Belyavskiy |
15a324 |
+ ;;
|
|
Dmitry Belyavskiy |
15a324 |
# Default: pass through.
|
|
Dmitry Belyavskiy |
15a324 |
*)
|
|
Dmitry Belyavskiy |
15a324 |
- cat
|
|
Dmitry Belyavskiy |
15a324 |
- ;;
|
|
Dmitry Belyavskiy |
15a324 |
+ cat
|
|
Dmitry Belyavskiy |
15a324 |
+ ;;
|
|
Dmitry Belyavskiy |
15a324 |
esac
|
|
Dmitry Belyavskiy |
15a324 |
echo
|
|
Dmitry Belyavskiy |
15a324 |
done
|