forked from wolfSSL/wolfssl
linuxkm: add asm support for Kyber.
This commit is contained in:
@ -115,7 +115,8 @@ $(obj)/wolfcrypt/benchmark/benchmark.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS
|
|||||||
asflags-y := $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPUSIMD_DISABLE)
|
asflags-y := $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPUSIMD_DISABLE)
|
||||||
|
|
||||||
# vectorized implementations that are kernel-safe are listed here.
|
# vectorized implementations that are kernel-safe are listed here.
|
||||||
# these are known kernel-compatible, but they still irritate objtool.
|
# these are known kernel-compatible, but need the vector instructions enabled in the assembler,
|
||||||
|
# and most of them still irritate objtool.
|
||||||
$(obj)/wolfcrypt/src/aes_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
$(obj)/wolfcrypt/src/aes_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
||||||
$(obj)/wolfcrypt/src/aes_asm.o: OBJECT_FILES_NON_STANDARD := y
|
$(obj)/wolfcrypt/src/aes_asm.o: OBJECT_FILES_NON_STANDARD := y
|
||||||
$(obj)/wolfcrypt/src/aes_gcm_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
$(obj)/wolfcrypt/src/aes_gcm_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
||||||
@ -134,6 +135,7 @@ $(obj)/wolfcrypt/src/chacha_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_
|
|||||||
$(obj)/wolfcrypt/src/chacha_asm.o: OBJECT_FILES_NON_STANDARD := y
|
$(obj)/wolfcrypt/src/chacha_asm.o: OBJECT_FILES_NON_STANDARD := y
|
||||||
$(obj)/wolfcrypt/src/poly1305_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
$(obj)/wolfcrypt/src/poly1305_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
||||||
$(obj)/wolfcrypt/src/poly1305_asm.o: OBJECT_FILES_NON_STANDARD := y
|
$(obj)/wolfcrypt/src/poly1305_asm.o: OBJECT_FILES_NON_STANDARD := y
|
||||||
|
$(obj)/wolfcrypt/src/wc_kyber_asm.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_DISABLE_SIMD_ENABLE)
|
||||||
|
|
||||||
ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
|
ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
|
||||||
|
|
||||||
|
@ -171,6 +171,9 @@
|
|||||||
#include <wolfssl/wolfcrypt/wc_lms.h>
|
#include <wolfssl/wolfcrypt/wc_lms.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DILITHIUM
|
||||||
|
#include <wolfssl/wolfcrypt/dilithium.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
#ifndef WOLFCRYPT_ONLY
|
#ifndef WOLFCRYPT_ONLY
|
||||||
|
@ -377,11 +377,7 @@ static int kyberkey_encapsulate(KyberKey* key, const byte* msg, byte* coins,
|
|||||||
sword16* epp = NULL;
|
sword16* epp = NULL;
|
||||||
unsigned int kp = 0;
|
unsigned int kp = 0;
|
||||||
unsigned int compVecSz = 0;
|
unsigned int compVecSz = 0;
|
||||||
#ifndef USE_INTEL_SPEEDUP
|
|
||||||
sword16* at = NULL;
|
sword16* at = NULL;
|
||||||
#else
|
|
||||||
sword16 at[((KYBER_MAX_K + 3) * KYBER_MAX_K + 3) * KYBER_N];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Establish parameters based on key type. */
|
/* Establish parameters based on key type. */
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
@ -409,16 +405,20 @@ static int kyberkey_encapsulate(KyberKey* key, const byte* msg, byte* coins,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_INTEL_SPEEDUP
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* Allocate dynamic memory for all matrices, vectors and polynomials. */
|
/* Allocate dynamic memory for all matrices, vectors and polynomials. */
|
||||||
|
#ifndef USE_INTEL_SPEEDUP
|
||||||
at = (sword16*)XMALLOC(((kp + 3) * kp + 3) * KYBER_N * sizeof(sword16),
|
at = (sword16*)XMALLOC(((kp + 3) * kp + 3) * KYBER_N * sizeof(sword16),
|
||||||
key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#else
|
||||||
|
at = (sword16*)XMALLOC(
|
||||||
|
((KYBER_MAX_K + 3) * KYBER_MAX_K + 3) * KYBER_N * sizeof(sword16),
|
||||||
|
key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
if (at == NULL) {
|
if (at == NULL) {
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* Assign allocated dynamic memory to pointers.
|
/* Assign allocated dynamic memory to pointers.
|
||||||
@ -472,10 +472,8 @@ static int kyberkey_encapsulate(KyberKey* key, const byte* msg, byte* coins,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_INTEL_SPEEDUP
|
|
||||||
/* Dispose of dynamic memory allocated in function. */
|
/* Dispose of dynamic memory allocated in function. */
|
||||||
XFREE(at, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(at, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user