-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kyber: Implementation in wolfSSL #7318
Conversation
5fc8fd6
to
a2695be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./configure --enable-kyber --enable-smallstack --enable-intelasm && make
...
wolfcrypt/src/wc_kyber_asm.S:12065:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12066:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12126:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12127:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12187:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12188:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12248:21: error: invalid operand for instruction
CC examples/client/client-client.o
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12249:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12309:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12310:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12370:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12371:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12431:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12432:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12495:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12496:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12686:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12687:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12751:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12752:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
wolfcrypt/src/wc_kyber_asm.S:12817:21: error: invalid operand for instruction
movzbl %bl, %r10b
^~~~~
wolfcrypt/src/wc_kyber_asm.S:12818:21: error: invalid operand for instruction
movzbl %bl, %cl
^~~
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.3.0
Thread model: posix```
wolfcrypt/src/wc_kyber_poly.c
Outdated
|
||
/* Initialize Kyber implementation. | ||
*/ | ||
void kyber_init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void kyber_init()
^
void
1 error generated.```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
wolfcrypt/src/wc_kyber.c
Outdated
/** | ||
* Make a Kyber key object using a random number generator. | ||
* | ||
* @param [in, out] key Kyber key ovject. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ovject
-> object
. 4 places in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
wolfcrypt/src/wc_kyber_poly.c
Outdated
} | ||
|
||
|
||
/* Encapsuluate message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encapsuluate
-> Encapsulate
. Two places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
wolfcrypt/src/wc_kyber_poly.c
Outdated
r += 4; | ||
} | ||
#else | ||
/* Calculate sizteen integer coefficients at a time. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizteen -> sixteen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
wolfcrypt/src/wc_kyber_poly.c
Outdated
} | ||
|
||
/* Get the noise/error by calculating random bytes and sampling to a binomial | ||
* deistributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deistributions
-> distributions
Assembly code fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builds, but fails.
./configure --enable-kyber --enable-smallstack --enable-intelasm && make
./wolfcrypt/test/testwolfcrypt
...
KYBER test failed!
error L=35378
[fiducial line numbers: 8247 25532 38178 50526]
Many build errors with: ./configure --enable-kyber=small --enable-smallstack --enable-intelasm && make
. Lots also without the intelasm.
./wolfssl/wolfcrypt/wc_kyber.h:124:18: error: use of undeclared identifier 'KYBER512_K'; did you mean 'KYBER512'?
sword16 priv[KYBER_MAX_K * KYBER_N];
^~~~~~~~~~~
KYBER512
./wolfssl/wolfcrypt/kyber.h:148:37: note: expanded from macro 'KYBER_MAX_K'
#define KYBER_MAX_K KYBER512_K
^
./wolfssl/wolfcrypt/kyber.h:156:5: note: 'KYBER512' declared here
KYBER512 = 0,
^
In file included from wolfcrypt/benchmark/benchmark.c:171:
./wolfssl/wolfcrypt/wc_kyber.h:126:17: error: use of undeclared identifier 'KYBER512_K'; did you mean 'KYBER512'?
sword16 pub[KYBER_MAX_K * KYBER_N];
^~~~~~~~~~~
KYBER512
./wolfssl/wolfcrypt/kyber.h:148:37: note: expanded from macro 'KYBER_MAX_K'
#define KYBER_MAX_K KYBER512_K
^
./wolfssl/wolfcrypt/kyber.h:156:5: note: 'KYBER512' declared here
KYBER512 = 0,
^
In file included from wolfcrypt/src/wc_kyber_poly.c:31:
./wolfssl/wolfcrypt/wc_kyber.h:124:18: error: use of undeclared identifier 'KYBER512_K'; did you mean 'KYBER512'?
sword16 priv[KYBER_MAX_K * KYBER_N];
^~~~~~~~~~~
KYBER512
./wolfssl/wolfcrypt/kyber.h:148:37: note: expanded from macro 'KYBER_MAX_K'
#define KYBER_MAX_K KYBER512_K
^
./wolfssl/wolfcrypt/kyber.h:156:5: note: 'KYBER512' declared here
KYBER512 = 0,
^
In file included from wolfcrypt/src/wc_kyber_poly.c:31:
./wolfssl/wolfcrypt/wc_kyber.h:126:17: error: use of undeclared identifier 'KYBER512_K'; did you mean 'KYBER512'?
sword16 pub[KYBER_MAX_K * KYBER_N];
^~~~~~~~~~~
KYBER512
./wolfssl/wolfcrypt/kyber.h:148:37: note: expanded from macro 'KYBER_MAX_K'
#define KYBER_MAX_K KYBER512_K
^
./wolfssl/wolfcrypt/kyber.h:156:5: note: 'KYBER512' declared here
KYBER512 = 0,
^
wolfcrypt/src/wc_kyber_poly.c:1280:35: error: unused parameter 'prf' [-Werror,-Wunused-parameter]
int kyber_gen_matrix(KYBER_PRF_T* prf, sword16* a, int kp, byte* seed,
^
wolfcrypt/src/wc_kyber_poly.c:1280:49: error: unused parameter 'a' [-Werror,-Wunused-parameter]
int kyber_gen_matrix(KYBER_PRF_T* prf, sword16* a, int kp, byte* seed,
^
wolfcrypt/src/wc_kyber_poly.c:1280:56: error: unused parameter 'kp' [-Werror,-Wunused-parameter]
int kyber_gen_matrix(KYBER_PRF_T* prf, sword16* a, int kp, byte* seed,
^
wolfcrypt/src/wc_kyber_poly.c:1280:66: error: unused parameter 'seed' [-Werror,-Wunused-parameter]
int kyber_gen_matrix(KYBER_PRF_T* prf, sword16* a, int kp, byte* seed,
^
wolfcrypt/src/wc_kyber_poly.c:1281:9: error: unused parameter 'transposed' [-Werror,-Wunused-parameter]
int transposed)
^
wolfcrypt/src/wc_kyber_poly.c:1843:34: error: unused parameter 'prf' [-Werror,-Wunused-parameter]
int kyber_get_noise(KYBER_PRF_T* prf, int kp, sword16* vec1,
^
wolfcrypt/src/wc_kyber_poly.c:1843:43: error: unused parameter 'kp' [-Werror,-Wunused-parameter]
int kyber_get_noise(KYBER_PRF_T* prf, int kp, sword16* vec1,
^
wolfcrypt/src/wc_kyber_poly.c:1843:56: error: unused parameter 'vec1' [-Werror,-Wunused-parameter]
int kyber_get_noise(KYBER_PRF_T* prf, int kp, sword16* vec1,
^
wolfcrypt/src/wc_kyber_poly.c:1844:14: error: unused parameter 'vec2' [-Werror,-Wunused-parameter]
sword16* vec2, sword16* poly, byte* seed)
^
wolfcrypt/src/wc_kyber_poly.c:1844:29: error: unused parameter 'poly' [-Werror,-Wunused-parameter]
sword16* vec2, sword16* poly, byte* seed)
^
wolfcrypt/src/wc_kyber_poly.c:1844:41: error: unused parameter 'seed' [-Werror,-Wunused-parameter]
sword16* vec2, sword16* poly, byte* seed)
^
13 errors generated.
make[2]: *** [wolfcrypt/src/src_libwolfssl_la-wc_kyber_poly.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
wolfcrypt/benchmark/benchmark.c:9195:13: error: use of undeclared identifier 'KYBER512_CIPHER_TEXT_SIZE'
byte ct[KYBER_MAX_CIPHER_TEXT_SIZE];
^
./wolfssl/wolfcrypt/kyber.h:151:37: note: expanded from macro 'KYBER_MAX_CIPHER_TEXT_SIZE'
#define KYBER_MAX_CIPHER_TEXT_SIZE KYBER512_CIPHER_TEXT_SIZE
^
3 errors generated.```
wolfcrypt/src/wc_kyber_poly.c
Outdated
|
||
#ifdef WOLFSSL_KYBER1024 | ||
/* Get the noise/error by calculating random bytes and sampling to a binomial | ||
* deistributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deistributions
-> distributions
. Four places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Put Kyber implementation into wolfSSL.
Can't do --enable-kyber=small. |
Assembly code works now. |
Description
Put Kyber implementation into wolfSSL.
Testing
Regression tested kyber.
--enable-kyber no defaults to wolfSSL when liboqs is not specified.
Checklist