Kyber: fixes
Don't define WOLFSSL_HAVE_KYBER unless configured. Only compile code in ext_kyber.c when WOLFSSL_HAVE_KYBER defined. Include config.h and settings in ext_kyber.c. This allowed HAVE_VISIBILITY to be defined. Cleanup kyber.h.
This commit is contained in:
parent
bcf4dbe697
commit
62c415fd50
@ -19,6 +19,11 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/ext_kyber.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
@ -26,6 +31,8 @@
|
||||
#error "KYBER-90s is not supported when building PQM4"
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_HAVE_KYBER
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
@ -674,3 +681,4 @@ int wc_KyberKey_EncodePublicKey(KyberKey* key, unsigned char* out, word32 len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_KYBER */
|
||||
|
@ -21,8 +21,7 @@
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/kyber.h
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_KYBER_H
|
||||
#define WOLF_CRYPT_KYBER_H
|
||||
@ -152,17 +151,15 @@
|
||||
#define KYBER_MAX_CIPHER_TEXT_SIZE KYBER512_CIPHER_TEXT_SIZE
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
/* Types of Kyber keys. */
|
||||
KYBER512 = 0,
|
||||
KYBER768 = 1,
|
||||
KYBER1024 = 2,
|
||||
|
||||
KYBER_LEVEL1 = KYBER512,
|
||||
KYBER_LEVEL3 = KYBER768,
|
||||
KYBER_LEVEL5 = KYBER1024,
|
||||
KYBER_LEVEL1 = KYBER512,
|
||||
KYBER_LEVEL3 = KYBER768,
|
||||
KYBER_LEVEL5 = KYBER1024,
|
||||
|
||||
/* Symmetric data size. */
|
||||
KYBER_SYM_SZ = 32,
|
||||
@ -174,53 +171,47 @@ enum {
|
||||
KYBER_ENC_RAND_SZ = KYBER_SYM_SZ,
|
||||
|
||||
/* Encoded polynomial size. */
|
||||
KYBER_POLY_SIZE = 384,
|
||||
KYBER_POLY_SIZE = 384,
|
||||
};
|
||||
|
||||
|
||||
/* Different structures for different implementations. */
|
||||
typedef struct KyberKey KyberKey;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_Init(int type, KyberKey* key, void* heap, int devId);
|
||||
WOLFSSL_API
|
||||
void wc_KyberKey_Free(KyberKey* key);
|
||||
WOLFSSL_API int wc_KyberKey_Init(int type, KyberKey* key, void* heap,
|
||||
int devId);
|
||||
WOLFSSL_API void wc_KyberKey_Free(KyberKey* key);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_MakeKey(KyberKey* key, WC_RNG* rng);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_MakeKeyWithRandom(KyberKey* key, const unsigned char* rand,
|
||||
int len);
|
||||
WOLFSSL_API int wc_KyberKey_MakeKey(KyberKey* key, WC_RNG* rng);
|
||||
WOLFSSL_API int wc_KyberKey_MakeKeyWithRandom(KyberKey* key,
|
||||
const unsigned char* rand, int len);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_CipherTextSize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_SharedSecretSize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API int wc_KyberKey_CipherTextSize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API int wc_KyberKey_SharedSecretSize(KyberKey* key, word32* len);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_Encapsulate(KyberKey* key, unsigned char* ct,
|
||||
WOLFSSL_API int wc_KyberKey_Encapsulate(KyberKey* key, unsigned char* ct,
|
||||
unsigned char* ss, WC_RNG* rng);
|
||||
int wc_KyberKey_EncapsulateWithRandom(KyberKey* key, unsigned char* ct,
|
||||
unsigned char* ss, const unsigned char* rand, int len);
|
||||
WOLFSSL_API int wc_KyberKey_EncapsulateWithRandom(KyberKey* key,
|
||||
unsigned char* ct, unsigned char* ss, const unsigned char* rand, int len);
|
||||
WOLFSSL_API int wc_KyberKey_Decapsulate(KyberKey* key, unsigned char* ss,
|
||||
const unsigned char* ct, word32 len);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_DecodePrivateKey(KyberKey* key, unsigned char* in, word32 len);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_DecodePublicKey(KyberKey* key, unsigned char* in, word32 len);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_PrivateKeySize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_PublicKeySize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_EncodePrivateKey(KyberKey* key, unsigned char* out, word32 len);
|
||||
WOLFSSL_API
|
||||
int wc_KyberKey_EncodePublicKey(KyberKey* key, unsigned char* out, word32 len);
|
||||
WOLFSSL_API int wc_KyberKey_DecodePrivateKey(KyberKey* key, unsigned char* in,
|
||||
word32 len);
|
||||
WOLFSSL_API int wc_KyberKey_DecodePublicKey(KyberKey* key, unsigned char* in,
|
||||
word32 len);
|
||||
|
||||
WOLFSSL_API int wc_KyberKey_PrivateKeySize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API int wc_KyberKey_PublicKeySize(KyberKey* key, word32* len);
|
||||
WOLFSSL_API int wc_KyberKey_EncodePrivateKey(KyberKey* key, unsigned char* out,
|
||||
word32 len);
|
||||
WOLFSSL_API int wc_KyberKey_EncodePublicKey(KyberKey* key, unsigned char* out,
|
||||
word32 len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -2734,7 +2734,6 @@ extern void uITRON4_free(void *p) ;
|
||||
#define HAVE_DILITHIUM
|
||||
#define HAVE_SPHINCS
|
||||
#define HAVE_KYBER
|
||||
#define WOLFSSL_HAVE_KYBER
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PQM4
|
||||
|
Loading…
x
Reference in New Issue
Block a user