Skip to content

Commit

Permalink
Add asm for rejection sampling
Browse files Browse the repository at this point in the history
Signed-off-by: Duc Tri Nguyen <[email protected]>

move to mlkem/asm/clean

Signed-off-by: Duc Tri Nguyen <[email protected]>

rewrite checksum to pure Python

Signed-off-by: Duc Tri Nguyen <[email protected]>

add comment, preserve register and spacing

Signed-off-by: Duc Tri Nguyen <[email protected]>
  • Loading branch information
cothan committed Jun 7, 2024
1 parent c1d65ef commit f4ead9a
Show file tree
Hide file tree
Showing 9 changed files with 766 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ test/gen_KAT1024
test/gen_NISTKAT512
test/gen_NISTKAT768
test/gen_NISTKAT1024
*.dSYM
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
CC ?= gcc
INCLUDE_FIPS202 = -I fips202
INCLUDE_MLKEM = -I mlkem
INCLUDE_ASM_CLEAN = -I mlkem/asm/clean
INCLUDE_ASM_OPT = -I mlkem/asm/opt
INCLUDE_RANDOM = -I randombytes
INCLUDE_NISTRANDOM = -I test/nistrng
CFLAGS += -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wredundant-decls \
-Wshadow -Wpointer-arith -O3 -fomit-frame-pointer -pedantic \
${INCLUDE_MLKEM} ${INCLUDE_FIPS202}
${INCLUDE_MLKEM} ${INCLUDE_FIPS202} ${INCLUDE_ASM_CLEAN}
CFLAGS_RANDOMBYTES = ${CFLAGS} ${INCLUDE_RANDOM}
CFLAGS_NISTRANDOMBYTES = ${CFLAGS} ${INCLUDE_NISTRANDOM}
NISTFLAGS += -Wno-unused-result -O3 -fomit-frame-pointer
RM = /bin/rm

SOURCES = mlkem/kem.c mlkem/indcpa.c mlkem/polyvec.c mlkem/poly.c mlkem/ntt.c mlkem/cbd.c mlkem/reduce.c mlkem/verify.c
ASM_CLEAN = mlkem/asm/clean/rej_uniform_asm.s

SOURCES = $(ASM_CLEAN) mlkem/kem.c mlkem/indcpa.c mlkem/polyvec.c mlkem/poly.c mlkem/ntt.c mlkem/cbd.c mlkem/reduce.c mlkem/verify.c mlkem/rej_uniform.c
SOURCESKECCAK = $(SOURCES) fips202/keccakf1600.c fips202/fips202.c mlkem/symmetric-shake.c
SOURCESKECCAKRANDOM = $(SOURCESKECCAK) randombytes/randombytes.c
SOURCESNISTKATS = $(SOURCESKECCAK) test/nistrng/aes.c test/nistrng/rng.c

HEADERS = mlkem/params.h mlkem/kem.h mlkem/indcpa.h mlkem/polyvec.h mlkem/poly.h mlkem/ntt.h mlkem/cbd.h mlkem/reduce.c mlkem/verify.h mlkem/symmetric.h
HEADERS = mlkem/params.h mlkem/kem.h mlkem/indcpa.h mlkem/polyvec.h mlkem/poly.h mlkem/ntt.h mlkem/cbd.h mlkem/reduce.c mlkem/verify.h mlkem/symmetric.h mlkem/rej_uniform.h
HEADERSKECCAK = $(HEADERS) fips202/keccakf1600.h fips202/fips202.h
HEADERSKECCAKRANDOM = $(HEADERSKECCAK) randombytes/randombytes.h
HEADERNISTKATS = $(HEADERSKECCAK) test/nistrng/aes.h test/nistrng/randombytes.h
Expand Down
13 changes: 13 additions & 0 deletions mlkem/asm/clean/rej_uniform_asm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
#ifndef REJ_UNIFORM_ASM
#define REJ_UNIFORM_ASM

unsigned int rej_uniform_asm(int16_t *r,
const uint8_t *buf,
unsigned int *buf_consumed,
unsigned int buflen,
unsigned int len,
const uint8_t idx[256][16],
const uint16_t bits[8]);

#endif
Loading

0 comments on commit f4ead9a

Please sign in to comment.