mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
ECC FIPS
Add the ECC API to the FIPS boundary. Included are ECDHE and ECDSA.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -38,7 +38,9 @@ tags
|
|||||||
cyassl-config
|
cyassl-config
|
||||||
wolfssl-config
|
wolfssl-config
|
||||||
cyassl.sublime*
|
cyassl.sublime*
|
||||||
|
fips.h
|
||||||
fips.c
|
fips.c
|
||||||
|
fipsv2.c
|
||||||
fips_test.c
|
fips_test.c
|
||||||
fips
|
fips
|
||||||
src/async.c
|
src/async.c
|
||||||
|
@@ -18,6 +18,8 @@ if test -e .git; then
|
|||||||
# touch fips files for non fips distribution
|
# touch fips files for non fips distribution
|
||||||
touch ./ctaocrypt/src/fips.c
|
touch ./ctaocrypt/src/fips.c
|
||||||
touch ./ctaocrypt/src/fips_test.c
|
touch ./ctaocrypt/src/fips_test.c
|
||||||
|
touch ./wolfcrypt/src/fipsv2.c
|
||||||
|
touch ./wolfssl/wolfcrypt/fips.h
|
||||||
|
|
||||||
# touch async crypt files
|
# touch async crypt files
|
||||||
touch ./wolfcrypt/src/async.c
|
touch ./wolfcrypt/src/async.c
|
||||||
|
@@ -1934,7 +1934,8 @@ then
|
|||||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS"
|
AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS"
|
||||||
# Add the FIPS flag.
|
# Add the FIPS flag.
|
||||||
AS_IF([test "x$FIPS_VERSION" = "xv2"],
|
AS_IF([test "x$FIPS_VERSION" = "xv2"],
|
||||||
[AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS_VERSION=2"])
|
[AM_CFLAGS="$AM_CFLAGS -DHAVE_FIPS_VERSION=2 -DWOLFSSL_KEY_GEN"
|
||||||
|
ENABLED_KEYGEN="yes"])
|
||||||
else
|
else
|
||||||
if test "x$ENABLED_FORTRESS" = "xyes"
|
if test "x$ENABLED_FORTRESS" = "xyes"
|
||||||
then
|
then
|
||||||
|
@@ -36,6 +36,10 @@ if BUILD_RSA
|
|||||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/rsa.c
|
src_libwolfssl_la_SOURCES += ctaocrypt/src/rsa.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if BUILD_ECC
|
||||||
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_AES
|
if BUILD_AES
|
||||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/aes.c
|
src_libwolfssl_la_SOURCES += ctaocrypt/src/aes.c
|
||||||
endif
|
endif
|
||||||
@@ -53,6 +57,7 @@ src_libwolfssl_la_SOURCES += ctaocrypt/src/sha512.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
|
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
|
||||||
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/fipsv2.c
|
||||||
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c
|
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c
|
||||||
|
|
||||||
# fips last file
|
# fips last file
|
||||||
@@ -218,9 +223,11 @@ if BUILD_SLOWMATH
|
|||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !BUILD_FIPS
|
||||||
if BUILD_ECC
|
if BUILD_ECC
|
||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_CURVE25519
|
if BUILD_CURVE25519
|
||||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve25519.c
|
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve25519.c
|
||||||
|
@@ -93,6 +93,16 @@ ECC Curve Sizes:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||||
|
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
|
||||||
|
#define FIPS_NO_WRAPPERS
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#pragma code_seg(".fipsA$e2")
|
||||||
|
#pragma const_seg(".fipsB$e2")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wolfssl/wolfcrypt/ecc.h>
|
#include <wolfssl/wolfcrypt/ecc.h>
|
||||||
#include <wolfssl/wolfcrypt/asn.h>
|
#include <wolfssl/wolfcrypt/asn.h>
|
||||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||||
@@ -3786,10 +3796,10 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
|||||||
Free an ECC key from memory
|
Free an ECC key from memory
|
||||||
key The key you wish to free
|
key The key you wish to free
|
||||||
*/
|
*/
|
||||||
void wc_ecc_free(ecc_key* key)
|
int wc_ecc_free(ecc_key* key)
|
||||||
{
|
{
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
|
||||||
@@ -3808,6 +3818,7 @@ void wc_ecc_free(ecc_key* key)
|
|||||||
|
|
||||||
mp_forcezero(&key->k);
|
mp_forcezero(&key->k);
|
||||||
#endif /* WOLFSSL_ATECC508A */
|
#endif /* WOLFSSL_ATECC508A */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ECC_SHAMIR
|
#ifdef ECC_SHAMIR
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
|
|
||||||
|
#if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||||
|
#include <wolfssl/wolfcrypt/fips.h>
|
||||||
|
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||||
|
|
||||||
#include <wolfssl/wolfcrypt/integer.h>
|
#include <wolfssl/wolfcrypt/integer.h>
|
||||||
#include <wolfssl/wolfcrypt/random.h>
|
#include <wolfssl/wolfcrypt/random.h>
|
||||||
|
|
||||||
@@ -172,6 +176,8 @@ typedef enum ecc_curve_id {
|
|||||||
#endif
|
#endif
|
||||||
} ecc_curve_id;
|
} ecc_curve_id;
|
||||||
|
|
||||||
|
#if !defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)
|
||||||
|
|
||||||
#ifdef HAVE_OID_ENCODING
|
#ifdef HAVE_OID_ENCODING
|
||||||
typedef word16 ecc_oid_t;
|
typedef word16 ecc_oid_t;
|
||||||
#else
|
#else
|
||||||
@@ -198,6 +204,7 @@ typedef struct ecc_set_type {
|
|||||||
int cofactor;
|
int cofactor;
|
||||||
} ecc_set_type;
|
} ecc_set_type;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ALT_ECC_SIZE
|
#ifdef ALT_ECC_SIZE
|
||||||
|
|
||||||
@@ -258,6 +265,7 @@ typedef struct alt_fp_int {
|
|||||||
#endif /* ALT_ECC_SIZE */
|
#endif /* ALT_ECC_SIZE */
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)
|
||||||
/* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
|
/* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
|
||||||
(x/z^2, y/z^3, 1) when interpreted as affine */
|
(x/z^2, y/z^3, 1) when interpreted as affine */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -315,6 +323,7 @@ struct ecc_key {
|
|||||||
typedef struct ecc_key ecc_key;
|
typedef struct ecc_key ecc_key;
|
||||||
#define WC_ECCKEY_TYPE_DEFINED
|
#define WC_ECCKEY_TYPE_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ECC predefined curve sets */
|
/* ECC predefined curve sets */
|
||||||
@@ -387,7 +396,7 @@ int wc_ecc_init(ecc_key* key);
|
|||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
|
int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
void wc_ecc_free(ecc_key* key);
|
int wc_ecc_free(ecc_key* key);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ecc_set_flags(ecc_key* key, word32 flags);
|
int wc_ecc_set_flags(ecc_key* key, word32 flags);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
|
@@ -20,6 +20,7 @@ nobase_include_HEADERS+= \
|
|||||||
wolfssl/wolfcrypt/fe_operations.h \
|
wolfssl/wolfcrypt/fe_operations.h \
|
||||||
wolfssl/wolfcrypt/ge_operations.h \
|
wolfssl/wolfcrypt/ge_operations.h \
|
||||||
wolfssl/wolfcrypt/error-crypt.h \
|
wolfssl/wolfcrypt/error-crypt.h \
|
||||||
|
wolfssl/wolfcrypt/fips.h \
|
||||||
wolfssl/wolfcrypt/fips_test.h \
|
wolfssl/wolfcrypt/fips_test.h \
|
||||||
wolfssl/wolfcrypt/hash.h \
|
wolfssl/wolfcrypt/hash.h \
|
||||||
wolfssl/wolfcrypt/hc128.h \
|
wolfssl/wolfcrypt/hc128.h \
|
||||||
|
Reference in New Issue
Block a user