From 2802cf8c0e945dd5c6446b492e57b6c42e6e5b12 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:13:44 +0800 Subject: [PATCH] update mlkem m7fstack --- .../m7fstack/basemul_acc_kyber_opt_m7.s | 1 + .../m7fstack/basemul_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-1024/m7fstack/matacc.h | 2 +- crypto_kem/ml-kem-1024/m7fstack/matacc.i | 1 - .../m7fstack/matacc_acc_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-1024/m7fstack/matacc_asm.S | 1 - .../m7fstack/matacc_kyber_opt_m7.s | 1 + .../ml-kem-1024/m7fstack/slothy_layer.h | 2 +- .../m7fstack/basemul_acc_kyber_opt_m7.s | 1 + .../m7fstack/basemul_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-512/m7fstack/fastbasemul.S | 1 - crypto_kem/ml-kem-512/m7fstack/matacc.h | 2 +- crypto_kem/ml-kem-512/m7fstack/matacc.i | 1 - .../m7fstack/matacc_acc_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-512/m7fstack/matacc_asm.S | 1 - .../ml-kem-512/m7fstack/matacc_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-512/m7fstack/slothy_layer.h | 2 +- .../m7fstack/basemul_acc_kyber_opt_m7.s | 1 + .../m7fstack/basemul_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-768/m7fstack/fastbasemul.S | 1 - crypto_kem/ml-kem-768/m7fstack/matacc.h | 27 ++++++++++++++++++- crypto_kem/ml-kem-768/m7fstack/matacc.i | 1 - .../m7fstack/matacc_acc_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-768/m7fstack/matacc_asm.S | 1 - .../ml-kem-768/m7fstack/matacc_kyber_opt_m7.s | 1 + crypto_kem/ml-kem-768/m7fstack/slothy_layer.h | 21 ++++++++++++++- 26 files changed, 62 insertions(+), 14 deletions(-) create mode 120000 crypto_kem/ml-kem-1024/m7fstack/basemul_acc_kyber_opt_m7.s create mode 120000 crypto_kem/ml-kem-1024/m7fstack/basemul_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-1024/m7fstack/matacc.i create mode 120000 crypto_kem/ml-kem-1024/m7fstack/matacc_acc_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-1024/m7fstack/matacc_asm.S create mode 120000 crypto_kem/ml-kem-1024/m7fstack/matacc_kyber_opt_m7.s create mode 120000 crypto_kem/ml-kem-512/m7fstack/basemul_acc_kyber_opt_m7.s create mode 120000 crypto_kem/ml-kem-512/m7fstack/basemul_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-512/m7fstack/fastbasemul.S delete mode 120000 crypto_kem/ml-kem-512/m7fstack/matacc.i create mode 120000 crypto_kem/ml-kem-512/m7fstack/matacc_acc_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-512/m7fstack/matacc_asm.S create mode 120000 crypto_kem/ml-kem-512/m7fstack/matacc_kyber_opt_m7.s create mode 120000 crypto_kem/ml-kem-768/m7fstack/basemul_acc_kyber_opt_m7.s create mode 120000 crypto_kem/ml-kem-768/m7fstack/basemul_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-768/m7fstack/fastbasemul.S mode change 120000 => 100644 crypto_kem/ml-kem-768/m7fstack/matacc.h delete mode 120000 crypto_kem/ml-kem-768/m7fstack/matacc.i create mode 120000 crypto_kem/ml-kem-768/m7fstack/matacc_acc_kyber_opt_m7.s delete mode 120000 crypto_kem/ml-kem-768/m7fstack/matacc_asm.S create mode 120000 crypto_kem/ml-kem-768/m7fstack/matacc_kyber_opt_m7.s mode change 120000 => 100644 crypto_kem/ml-kem-768/m7fstack/slothy_layer.h diff --git a/crypto_kem/ml-kem-1024/m7fstack/basemul_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-1024/m7fstack/basemul_acc_kyber_opt_m7.s new file mode 120000 index 0000000..f9dc911 --- /dev/null +++ b/crypto_kem/ml-kem-1024/m7fstack/basemul_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/basemul_kyber_opt_m7.s b/crypto_kem/ml-kem-1024/m7fstack/basemul_kyber_opt_m7.s new file mode 120000 index 0000000..daa6d11 --- /dev/null +++ b/crypto_kem/ml-kem-1024/m7fstack/basemul_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/matacc.h b/crypto_kem/ml-kem-1024/m7fstack/matacc.h index ad643ca..541a400 120000 --- a/crypto_kem/ml-kem-1024/m7fstack/matacc.h +++ b/crypto_kem/ml-kem-1024/m7fstack/matacc.h @@ -1 +1 @@ -../m4fstack/matacc.h \ No newline at end of file +../../ml-kem-768/m7fstack/matacc.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/matacc.i b/crypto_kem/ml-kem-1024/m7fstack/matacc.i deleted file mode 120000 index 5c0d8e5..0000000 --- a/crypto_kem/ml-kem-1024/m7fstack/matacc.i +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc.i \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/matacc_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-1024/m7fstack/matacc_acc_kyber_opt_m7.s new file mode 120000 index 0000000..2318505 --- /dev/null +++ b/crypto_kem/ml-kem-1024/m7fstack/matacc_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/matacc_asm.S b/crypto_kem/ml-kem-1024/m7fstack/matacc_asm.S deleted file mode 120000 index 5f8b5c2..0000000 --- a/crypto_kem/ml-kem-1024/m7fstack/matacc_asm.S +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc_asm.S \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/matacc_kyber_opt_m7.s b/crypto_kem/ml-kem-1024/m7fstack/matacc_kyber_opt_m7.s new file mode 120000 index 0000000..26de8c5 --- /dev/null +++ b/crypto_kem/ml-kem-1024/m7fstack/matacc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-1024/m7fstack/slothy_layer.h b/crypto_kem/ml-kem-1024/m7fstack/slothy_layer.h index 2afd910..7d16a61 120000 --- a/crypto_kem/ml-kem-1024/m7fstack/slothy_layer.h +++ b/crypto_kem/ml-kem-1024/m7fstack/slothy_layer.h @@ -1 +1 @@ -../m7fspeed/slothy_layer.h \ No newline at end of file +../../ml-kem-768/m7fstack/slothy_layer.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/basemul_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-512/m7fstack/basemul_acc_kyber_opt_m7.s new file mode 120000 index 0000000..f9dc911 --- /dev/null +++ b/crypto_kem/ml-kem-512/m7fstack/basemul_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/basemul_kyber_opt_m7.s b/crypto_kem/ml-kem-512/m7fstack/basemul_kyber_opt_m7.s new file mode 120000 index 0000000..daa6d11 --- /dev/null +++ b/crypto_kem/ml-kem-512/m7fstack/basemul_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/fastbasemul.S b/crypto_kem/ml-kem-512/m7fstack/fastbasemul.S deleted file mode 120000 index 205b31b..0000000 --- a/crypto_kem/ml-kem-512/m7fstack/fastbasemul.S +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/fastbasemul.S \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/matacc.h b/crypto_kem/ml-kem-512/m7fstack/matacc.h index ad643ca..541a400 120000 --- a/crypto_kem/ml-kem-512/m7fstack/matacc.h +++ b/crypto_kem/ml-kem-512/m7fstack/matacc.h @@ -1 +1 @@ -../m4fstack/matacc.h \ No newline at end of file +../../ml-kem-768/m7fstack/matacc.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/matacc.i b/crypto_kem/ml-kem-512/m7fstack/matacc.i deleted file mode 120000 index 5c0d8e5..0000000 --- a/crypto_kem/ml-kem-512/m7fstack/matacc.i +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc.i \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/matacc_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-512/m7fstack/matacc_acc_kyber_opt_m7.s new file mode 120000 index 0000000..2318505 --- /dev/null +++ b/crypto_kem/ml-kem-512/m7fstack/matacc_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/matacc_asm.S b/crypto_kem/ml-kem-512/m7fstack/matacc_asm.S deleted file mode 120000 index 5f8b5c2..0000000 --- a/crypto_kem/ml-kem-512/m7fstack/matacc_asm.S +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc_asm.S \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/matacc_kyber_opt_m7.s b/crypto_kem/ml-kem-512/m7fstack/matacc_kyber_opt_m7.s new file mode 120000 index 0000000..26de8c5 --- /dev/null +++ b/crypto_kem/ml-kem-512/m7fstack/matacc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-512/m7fstack/slothy_layer.h b/crypto_kem/ml-kem-512/m7fstack/slothy_layer.h index 2afd910..7d16a61 120000 --- a/crypto_kem/ml-kem-512/m7fstack/slothy_layer.h +++ b/crypto_kem/ml-kem-512/m7fstack/slothy_layer.h @@ -1 +1 @@ -../m7fspeed/slothy_layer.h \ No newline at end of file +../../ml-kem-768/m7fstack/slothy_layer.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/basemul_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-768/m7fstack/basemul_acc_kyber_opt_m7.s new file mode 120000 index 0000000..f9dc911 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/basemul_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/basemul_kyber_opt_m7.s b/crypto_kem/ml-kem-768/m7fstack/basemul_kyber_opt_m7.s new file mode 120000 index 0000000..daa6d11 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/basemul_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/basemul_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/fastbasemul.S b/crypto_kem/ml-kem-768/m7fstack/fastbasemul.S deleted file mode 120000 index 205b31b..0000000 --- a/crypto_kem/ml-kem-768/m7fstack/fastbasemul.S +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/fastbasemul.S \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc.h b/crypto_kem/ml-kem-768/m7fstack/matacc.h deleted file mode 120000 index ad643ca..0000000 --- a/crypto_kem/ml-kem-768/m7fstack/matacc.h +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc.h b/crypto_kem/ml-kem-768/m7fstack/matacc.h new file mode 100644 index 0000000..57425d6 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/matacc.h @@ -0,0 +1,26 @@ +#ifndef MATACC_H +#define MATACC_H +#include "poly.h" +#include "polyvec.h" +#include "symmetric.h" + +extern void __matacc_asm(int16_t *r, const int16_t *b, int16_t c[4], unsigned char buf[XOF_BLOCKBYTES+2], const int32_t zetas[64], xof_state *state); +static inline void _matacc_asm(int16_t *r, const int16_t *b, int16_t c[4], unsigned char buf[XOF_BLOCKBYTES + 2], const int32_t _zetas[64], xof_state *state) +{ + // floating point registers clobbered by assembly function + asm volatile("" : : : "s16", "s17", "s18", "s19", "s20", "s21", "s26"); + __matacc_asm(r, b, c, buf, _zetas, state); +} +#define matacc_asm _matacc_asm + +extern void __matacc_asm_acc(int16_t *r, const int16_t *b, int16_t c[4], unsigned char buf[XOF_BLOCKBYTES+2], const int32_t zetas[64], xof_state *state); +static inline void _matacc_asm_acc(int16_t *r, const int16_t *b, int16_t c[4], unsigned char buf[XOF_BLOCKBYTES + 2], const int32_t _zetas[64], xof_state *state) +{ + // floating point registers clobbered by assembly function + asm volatile("" : : : "s16", "s17", "s18", "s19", "s20", "s21", "s26"); + __matacc_asm_acc(r, b, c, buf, _zetas, state); +} +#define matacc_asm_acc _matacc_asm_acc + +void matacc(poly* r, const polyvec *b, unsigned char i, const unsigned char *seed, int transposed); +#endif diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc.i b/crypto_kem/ml-kem-768/m7fstack/matacc.i deleted file mode 120000 index 5c0d8e5..0000000 --- a/crypto_kem/ml-kem-768/m7fstack/matacc.i +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc.i \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc_acc_kyber_opt_m7.s b/crypto_kem/ml-kem-768/m7fstack/matacc_acc_kyber_opt_m7.s new file mode 120000 index 0000000..2318505 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/matacc_acc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_acc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc_asm.S b/crypto_kem/ml-kem-768/m7fstack/matacc_asm.S deleted file mode 120000 index 5f8b5c2..0000000 --- a/crypto_kem/ml-kem-768/m7fstack/matacc_asm.S +++ /dev/null @@ -1 +0,0 @@ -../m4fstack/matacc_asm.S \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/matacc_kyber_opt_m7.s b/crypto_kem/ml-kem-768/m7fstack/matacc_kyber_opt_m7.s new file mode 120000 index 0000000..26de8c5 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/matacc_kyber_opt_m7.s @@ -0,0 +1 @@ +../../../slothy/examples/opt/armv7m/matacc_kyber_opt_m7.s \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h b/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h deleted file mode 120000 index 2afd910..0000000 --- a/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h +++ /dev/null @@ -1 +0,0 @@ -../m7fspeed/slothy_layer.h \ No newline at end of file diff --git a/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h b/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h new file mode 100644 index 0000000..b9a2ec1 --- /dev/null +++ b/crypto_kem/ml-kem-768/m7fstack/slothy_layer.h @@ -0,0 +1,20 @@ +#ifndef SLOTHY_H +#define SLOTHY_H + +#include + +#define N(x, y) x##y +#define SLOTHY_NAMESPACE(s) N(s, _opt_m7) + +#define ntt_fast SLOTHY_NAMESPACE(ntt_fast) +#define invntt_fast SLOTHY_NAMESPACE(invntt_fast) +#define asm_barrett_reduce SLOTHY_NAMESPACE(asm_barrett_reduce) +#define basemul_asm SLOTHY_NAMESPACE(basemul_asm) +#define basemul_asm_acc SLOTHY_NAMESPACE(basemul_asm_acc) +#define asm_fromplant SLOTHY_NAMESPACE(asm_fromplant) +#define pointwise_add SLOTHY_NAMESPACE(pointwise_add) +#define pointwise_sub SLOTHY_NAMESPACE(pointwise_sub) +#define __matacc_asm SLOTHY_NAMESPACE(matacc_asm) +#define __matacc_asm_acc SLOTHY_NAMESPACE(matacc_asm_acc) + +#endif