From 079f309fd5079d505584a38e837b8b505be38e27 Mon Sep 17 00:00:00 2001 From: Tiago Oliveira Date: Sun, 22 Oct 2023 14:16:20 +0200 Subject: [PATCH] armv7m: shake* --- src/crypto_xof/shake128/armv7m/ref/Makefile | 3 +++ .../shake128/armv7m/ref/include/api.h | 17 +++++++++++++++++ .../shake128/armv7m/ref/shake128.jinc | 13 +++++++++++++ src/crypto_xof/shake128/armv7m/ref/xof.jazz | 11 +++++++++++ src/crypto_xof/shake256/armv7m/ref/Makefile | 3 +++ .../shake256/armv7m/ref/include/api.h | 17 +++++++++++++++++ .../shake256/armv7m/ref/shake256.jinc | 13 +++++++++++++ src/crypto_xof/shake256/armv7m/ref/xof.jazz | 10 ++++++++++ 8 files changed, 87 insertions(+) create mode 100644 src/crypto_xof/shake128/armv7m/ref/Makefile create mode 100644 src/crypto_xof/shake128/armv7m/ref/include/api.h create mode 100644 src/crypto_xof/shake128/armv7m/ref/shake128.jinc create mode 100644 src/crypto_xof/shake128/armv7m/ref/xof.jazz create mode 100644 src/crypto_xof/shake256/armv7m/ref/Makefile create mode 100644 src/crypto_xof/shake256/armv7m/ref/include/api.h create mode 100644 src/crypto_xof/shake256/armv7m/ref/shake256.jinc create mode 100644 src/crypto_xof/shake256/armv7m/ref/xof.jazz diff --git a/src/crypto_xof/shake128/armv7m/ref/Makefile b/src/crypto_xof/shake128/armv7m/ref/Makefile new file mode 100644 index 00000000..72547a45 --- /dev/null +++ b/src/crypto_xof/shake128/armv7m/ref/Makefile @@ -0,0 +1,3 @@ +override JFLAGS += -arch arm-m4 +SRCS := xof.jazz +include ../../../../Makefile.common diff --git a/src/crypto_xof/shake128/armv7m/ref/include/api.h b/src/crypto_xof/shake128/armv7m/ref/include/api.h new file mode 100644 index 00000000..a826fc50 --- /dev/null +++ b/src/crypto_xof/shake128/armv7m/ref/include/api.h @@ -0,0 +1,17 @@ +#ifndef JADE_XOF_shake128_armv7m_ref_API_H +#define JADE_XOF_shake128_armv7m_ref_API_H + +#define JADE_XOF_shake128_armv7m_ref_ALGNAME "SHAKE128" +#define JADE_XOF_shake128_armv7m_ref_ARCH "armv7m" +#define JADE_XOF_shake128_armv7m_ref_IMPL "ref" + +#include + +int jade_xof_shake128_armv7m_ref( + uint8_t *output, + uint32_t output_length, + const uint8_t *input, + uint32_t input_length +); + +#endif diff --git a/src/crypto_xof/shake128/armv7m/ref/shake128.jinc b/src/crypto_xof/shake128/armv7m/ref/shake128.jinc new file mode 100644 index 00000000..80cab943 --- /dev/null +++ b/src/crypto_xof/shake128/armv7m/ref/shake128.jinc @@ -0,0 +1,13 @@ +from Jade require "common/keccak/keccak1600/armv7m/ref/keccak1600.jinc" + +inline fn __shake128_ref(reg u32 out outlen in inlen) +{ + reg u32 rate trail_byte; + + trail_byte = 0x1F; + rate = (1344/8); + + __keccak1600_ref(out, outlen, in, inlen, trail_byte, rate); +} + + diff --git a/src/crypto_xof/shake128/armv7m/ref/xof.jazz b/src/crypto_xof/shake128/armv7m/ref/xof.jazz new file mode 100644 index 00000000..3191b09b --- /dev/null +++ b/src/crypto_xof/shake128/armv7m/ref/xof.jazz @@ -0,0 +1,11 @@ +require "shake128.jinc" + +export fn jade_xof_shake128_armv7m_ref(reg u32 output output_length input input_length) -> reg u32 +{ + reg u32 r; + __shake128_ref(output, output_length, input, input_length); + r = 0; + return r; +} + + diff --git a/src/crypto_xof/shake256/armv7m/ref/Makefile b/src/crypto_xof/shake256/armv7m/ref/Makefile new file mode 100644 index 00000000..72547a45 --- /dev/null +++ b/src/crypto_xof/shake256/armv7m/ref/Makefile @@ -0,0 +1,3 @@ +override JFLAGS += -arch arm-m4 +SRCS := xof.jazz +include ../../../../Makefile.common diff --git a/src/crypto_xof/shake256/armv7m/ref/include/api.h b/src/crypto_xof/shake256/armv7m/ref/include/api.h new file mode 100644 index 00000000..44bb2fc4 --- /dev/null +++ b/src/crypto_xof/shake256/armv7m/ref/include/api.h @@ -0,0 +1,17 @@ +#ifndef JADE_XOF_shake256_armv7m_ref_API_H +#define JADE_XOF_shake256_armv7m_ref_API_H + +#define JADE_XOF_shake256_armv7m_ref_ALGNAME "SHAKE256" +#define JADE_XOF_shake256_armv7m_ref_ARCH "armv7m" +#define JADE_XOF_shake256_armv7m_ref_IMPL "ref" + +#include + +int jade_xof_shake256_armv7m_ref( + uint8_t *output, + uint32_t output_length, + const uint8_t *input, + uint32_t input_length +); + +#endif diff --git a/src/crypto_xof/shake256/armv7m/ref/shake256.jinc b/src/crypto_xof/shake256/armv7m/ref/shake256.jinc new file mode 100644 index 00000000..889c9782 --- /dev/null +++ b/src/crypto_xof/shake256/armv7m/ref/shake256.jinc @@ -0,0 +1,13 @@ +from Jade require "common/keccak/keccak1600/armv7m/ref/keccak1600.jinc" + +inline fn __shake256_ref(reg u32 out outlen in inlen) +{ + reg u32 rate trail_byte; + + trail_byte = 0x1F; + rate = (1088/8); + + __keccak1600_ref(out, outlen, in, inlen, trail_byte, rate); +} + + diff --git a/src/crypto_xof/shake256/armv7m/ref/xof.jazz b/src/crypto_xof/shake256/armv7m/ref/xof.jazz new file mode 100644 index 00000000..d5b91912 --- /dev/null +++ b/src/crypto_xof/shake256/armv7m/ref/xof.jazz @@ -0,0 +1,10 @@ +require "shake256.jinc" + +export fn jade_xof_shake256_armv7m_ref(reg u32 output output_length input input_length) -> reg u32 +{ + reg u32 r; + __shake256_ref(output, output_length, input, input_length); + r = 0; + return r; +} +