Skip to content

Commit cf2c577

Browse files
committed
Update PQM4 kyber setup script.
Until now there was a bug in the PQM4 library that did not allow us to turn on optimizations. That bug has been resolved. So, now we use the current head as of today.
1 parent b06e00e commit cf2c577

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

pq/stm32/setup_kyber.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ diff -u pqm4_kyber512.old/kem.c pqm4_kyber512/kem.c
1010
diff -u pqm4_kyber512.old/randombytes.c pqm4_kyber512/randombytes.c
1111
--- pqm4_kyber512.old/randombytes.c 2022-03-28 16:36:40.037940919 -0400
1212
+++ pqm4_kyber512/randombytes.c 2022-03-11 14:38:18.192717915 -0500
13-
@@ -320,6 +320,10 @@
14-
/* Use windows API */
15-
return randombytes_win32_randombytes(buf, n);
13+
@@ -357,6 +357,10 @@
14+
/* Use WASI */
15+
return randombytes_wasi_randombytes(buf, n);
1616
#else
17-
-#error "randombytes(...) is not supported on this platform"
17+
-# error "randombytes(...) is not supported on this platform"
1818
+ #warning randombytes() is not supported on this platform!
1919
+ for (size_t i = 0; i < n; i++) {
2020
+ buf[i] = (uint8_t)i;
21-
+ }
21+
+ }
2222
+ return 0;
2323
#endif
2424
}

pq/stm32/setup_kyber.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ tmp_dir=$PWD
1414

1515
git clone https://github.com/mupq/pqm4.git $tmp_dir/pqm4
1616
cd $tmp_dir/pqm4
17-
git checkout 3bfbbfd30401bd1dce3c497feb2a152713f2e735
17+
git checkout 1eeb74e4106a80e26a9452e4793acd6f191fe413
1818

1919
git clone https://github.com/mupq/mupq.git $tmp_dir/mupq
2020
cd $tmp_dir/mupq
21-
git checkout 0235e325b60dcbd41bc82cdee55b5e3940e70b3e
21+
git checkout 3b48fa5aff6f5921df5b3444450281daca6d21d1
2222

2323
git clone https://github.com/pqclean/pqclean.git $tmp_dir/pqclean
2424
cd $tmp_dir/pqclean
25-
git checkout 964469d5506f3068c5afb504e3406f3291f6c336
25+
git checkout 2cc6e744e63c9aa7703ba3ae3304215e83bba167
2626

2727
# Populate include directory
2828
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/params.h $inc_dir
@@ -52,12 +52,12 @@ cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/macros.i $code_dir
5252
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/matacc.c $code_dir
5353
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/matacc.h $code_dir
5454
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/matacc.i $code_dir
55-
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/matacc.S $code_dir
55+
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/matacc_asm.S $code_dir
5656
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/ntt.c $code_dir
5757
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/ntt.h $code_dir
5858
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/poly.c $code_dir
5959
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/poly.h $code_dir
60-
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/poly.S $code_dir
60+
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/poly_asm.S $code_dir
6161
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/polyvec.c $code_dir
6262
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/polyvec.h $code_dir
6363
cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/reduce.S $code_dir
@@ -68,16 +68,14 @@ cp $tmp_dir/pqm4/crypto_kem/kyber512/m4fspeed/verify.h $code_dir
6868

6969
# Rename some files
7070
mv $inc_dir/api.h $inc_dir/api_kyber.h
71-
mv $code_dir/matacc.S $code_dir/matacc_renamed.S
72-
mv $code_dir/poly.S $code_dir/poly_renamed.S
7371

7472
# Patch in some small fixups.
7573
cd $cur_dir
7674
patch -p0 < setup_kyber.patch
7775

7876
# give the user some instructions
79-
echo "Created $code_dir . Plese add it to your project's Core directory."
80-
echo "Created $inc_dir . Plese add the files it contains to you project's Core/Inc directory."
77+
echo "Created $code_dir . Please add it to your project's Core directory."
78+
echo "Created $inc_dir . Please add the files it contains to you project's Core/Inc directory."
8179

8280
# Cleanup
8381
rm -rf $tmp_dir

0 commit comments

Comments
 (0)