forked from wolfSSL/wolfssl
ECC, DH, GCM, GMAC, CCM and AES updated services
This commit is contained in:
10
tests/api.c
10
tests/api.c
@ -24918,6 +24918,7 @@ static int test_wc_ecc_export_x963_ex(void)
|
|||||||
XMEMSET(&key, 0, sizeof(ecc_key));
|
XMEMSET(&key, 0, sizeof(ecc_key));
|
||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
XMEMSET(out, 0, outlen);
|
XMEMSET(out, 0, outlen);
|
||||||
|
PRIVATE_KEY_UNLOCK();
|
||||||
|
|
||||||
ExpectIntEQ(wc_ecc_init(&key), 0);
|
ExpectIntEQ(wc_ecc_init(&key), 0);
|
||||||
ExpectIntEQ(wc_InitRng(&rng), 0);
|
ExpectIntEQ(wc_InitRng(&rng), 0);
|
||||||
@ -24958,6 +24959,7 @@ static int test_wc_ecc_export_x963_ex(void)
|
|||||||
ExpectIntEQ(wc_ecc_export_x963_ex(&key, out, &outlen, NOCOMP),
|
ExpectIntEQ(wc_ecc_export_x963_ex(&key, out, &outlen, NOCOMP),
|
||||||
ECC_BAD_ARG_E);
|
ECC_BAD_ARG_E);
|
||||||
#endif
|
#endif
|
||||||
|
PRIVATE_KEY_LOCK();
|
||||||
|
|
||||||
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
||||||
wc_ecc_free(&key);
|
wc_ecc_free(&key);
|
||||||
@ -25049,6 +25051,7 @@ static int test_wc_ecc_import_private_key(void)
|
|||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
XMEMSET(privKey, 0, privKeySz);
|
XMEMSET(privKey, 0, privKeySz);
|
||||||
XMEMSET(x963Key, 0, x963KeySz);
|
XMEMSET(x963Key, 0, x963KeySz);
|
||||||
|
PRIVATE_KEY_UNLOCK();
|
||||||
|
|
||||||
ExpectIntEQ(wc_ecc_init(&key), 0);
|
ExpectIntEQ(wc_ecc_init(&key), 0);
|
||||||
ExpectIntEQ(wc_ecc_init(&keyImp), 0);
|
ExpectIntEQ(wc_ecc_init(&keyImp), 0);
|
||||||
@ -25071,6 +25074,7 @@ static int test_wc_ecc_import_private_key(void)
|
|||||||
x963KeySz, NULL), BAD_FUNC_ARG);
|
x963KeySz, NULL), BAD_FUNC_ARG);
|
||||||
ExpectIntEQ(wc_ecc_import_private_key(NULL, privKeySz, x963Key, x963KeySz,
|
ExpectIntEQ(wc_ecc_import_private_key(NULL, privKeySz, x963Key, x963KeySz,
|
||||||
&keyImp), BAD_FUNC_ARG);
|
&keyImp), BAD_FUNC_ARG);
|
||||||
|
PRIVATE_KEY_LOCK();
|
||||||
|
|
||||||
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
||||||
wc_ecc_free(&keyImp);
|
wc_ecc_free(&keyImp);
|
||||||
@ -25101,6 +25105,7 @@ static int test_wc_ecc_export_private_only(void)
|
|||||||
XMEMSET(&key, 0, sizeof(ecc_key));
|
XMEMSET(&key, 0, sizeof(ecc_key));
|
||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
XMEMSET(out, 0, outlen);
|
XMEMSET(out, 0, outlen);
|
||||||
|
PRIVATE_KEY_UNLOCK();
|
||||||
|
|
||||||
ExpectIntEQ(wc_ecc_init(&key), 0);
|
ExpectIntEQ(wc_ecc_init(&key), 0);
|
||||||
ExpectIntEQ(wc_InitRng(&rng), 0);
|
ExpectIntEQ(wc_InitRng(&rng), 0);
|
||||||
@ -25115,6 +25120,7 @@ static int test_wc_ecc_export_private_only(void)
|
|||||||
ExpectIntEQ(wc_ecc_export_private_only(NULL, out, &outlen), BAD_FUNC_ARG);
|
ExpectIntEQ(wc_ecc_export_private_only(NULL, out, &outlen), BAD_FUNC_ARG);
|
||||||
ExpectIntEQ(wc_ecc_export_private_only(&key, NULL, &outlen), BAD_FUNC_ARG);
|
ExpectIntEQ(wc_ecc_export_private_only(&key, NULL, &outlen), BAD_FUNC_ARG);
|
||||||
ExpectIntEQ(wc_ecc_export_private_only(&key, out, NULL), BAD_FUNC_ARG);
|
ExpectIntEQ(wc_ecc_export_private_only(&key, out, NULL), BAD_FUNC_ARG);
|
||||||
|
PRIVATE_KEY_LOCK();
|
||||||
|
|
||||||
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
||||||
wc_ecc_free(&key);
|
wc_ecc_free(&key);
|
||||||
@ -25712,6 +25718,7 @@ static int test_wc_ecc_shared_secret_ssh(void)
|
|||||||
XMEMSET(&key2, 0, sizeof(ecc_key));
|
XMEMSET(&key2, 0, sizeof(ecc_key));
|
||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
XMEMSET(secret, 0, secretLen);
|
XMEMSET(secret, 0, secretLen);
|
||||||
|
PRIVATE_KEY_UNLOCK();
|
||||||
|
|
||||||
/* Make keys */
|
/* Make keys */
|
||||||
ExpectIntEQ(wc_ecc_init(&key), 0);
|
ExpectIntEQ(wc_ecc_init(&key), 0);
|
||||||
@ -25751,6 +25758,7 @@ static int test_wc_ecc_shared_secret_ssh(void)
|
|||||||
key.type = ECC_PUBLICKEY;
|
key.type = ECC_PUBLICKEY;
|
||||||
ExpectIntEQ(wc_ecc_shared_secret_ssh(&key, &key2.pubkey, secret,
|
ExpectIntEQ(wc_ecc_shared_secret_ssh(&key, &key2.pubkey, secret,
|
||||||
&secretLen), ECC_BAD_ARG_E);
|
&secretLen), ECC_BAD_ARG_E);
|
||||||
|
PRIVATE_KEY_LOCK();
|
||||||
|
|
||||||
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
DoExpectIntEQ(wc_FreeRng(&rng), 0);
|
||||||
wc_ecc_free(&key);
|
wc_ecc_free(&key);
|
||||||
@ -26678,6 +26686,7 @@ static int test_wc_EccPrivateKeyToDer(void)
|
|||||||
|
|
||||||
XMEMSET(&eccKey, 0, sizeof(ecc_key));
|
XMEMSET(&eccKey, 0, sizeof(ecc_key));
|
||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
|
PRIVATE_KEY_UNLOCK();
|
||||||
|
|
||||||
ExpectIntEQ(wc_InitRng(&rng), 0);
|
ExpectIntEQ(wc_InitRng(&rng), 0);
|
||||||
ExpectIntEQ(wc_ecc_init(&eccKey), 0);
|
ExpectIntEQ(wc_ecc_init(&eccKey), 0);
|
||||||
@ -26718,6 +26727,7 @@ static int test_wc_EccPrivateKeyToDer(void)
|
|||||||
EVP_PKEY_free(pkey); /* EC_KEY should be free'd by free'ing pkey */
|
EVP_PKEY_free(pkey); /* EC_KEY should be free'd by free'ing pkey */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
PRIVATE_KEY_LOCK();
|
||||||
#endif
|
#endif
|
||||||
return EXPECT_RESULT();
|
return EXPECT_RESULT();
|
||||||
} /* End test_wc_EccPrivateKeyToDer*/
|
} /* End test_wc_EccPrivateKeyToDer*/
|
||||||
|
@ -401,6 +401,9 @@ struct Aes {
|
|||||||
|
|
||||||
#ifndef WC_AES_TYPE_DEFINED
|
#ifndef WC_AES_TYPE_DEFINED
|
||||||
typedef struct Aes Aes;
|
typedef struct Aes Aes;
|
||||||
|
#ifdef HAVE_AESGCM
|
||||||
|
typedef struct Gmac Gmac;
|
||||||
|
#endif
|
||||||
#define WC_AES_TYPE_DEFINED
|
#define WC_AES_TYPE_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -457,9 +460,9 @@ struct Aes {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AESGCM
|
#ifdef HAVE_AESGCM
|
||||||
typedef struct Gmac {
|
struct Gmac {
|
||||||
Aes aes;
|
Aes aes;
|
||||||
} Gmac;
|
};
|
||||||
#endif /* HAVE_AESGCM */
|
#endif /* HAVE_AESGCM */
|
||||||
#endif /* HAVE_FIPS */
|
#endif /* HAVE_FIPS */
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ typedef byte ecc_oid_t;
|
|||||||
|
|
||||||
/* ECC set type defined a GF(p) curve */
|
/* ECC set type defined a GF(p) curve */
|
||||||
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
typedef struct ecc_set_type {
|
struct ecc_set_type {
|
||||||
int size; /* The size of the curve in octets */
|
int size; /* The size of the curve in octets */
|
||||||
int id; /* id of this curve */
|
int id; /* id of this curve */
|
||||||
const char* name; /* name of this curve */
|
const char* name; /* name of this curve */
|
||||||
@ -311,13 +311,13 @@ typedef struct ecc_set_type {
|
|||||||
word32 oidSz;
|
word32 oidSz;
|
||||||
word32 oidSum; /* sum of encoded OID bytes */
|
word32 oidSum; /* sum of encoded OID bytes */
|
||||||
int cofactor;
|
int cofactor;
|
||||||
} ecc_set_type;
|
};
|
||||||
#else
|
#else
|
||||||
#define MAX_ECC_NAME 16
|
#define MAX_ECC_NAME 16
|
||||||
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 2)
|
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 2)
|
||||||
/* The values are stored as text strings. */
|
/* The values are stored as text strings. */
|
||||||
|
|
||||||
typedef struct ecc_set_type {
|
struct ecc_set_type {
|
||||||
int size; /* The size of the curve in octets */
|
int size; /* The size of the curve in octets */
|
||||||
int id; /* id of this curve */
|
int id; /* id of this curve */
|
||||||
char name[MAX_ECC_NAME]; /* name of this curve */
|
char name[MAX_ECC_NAME]; /* name of this curve */
|
||||||
@ -331,7 +331,7 @@ typedef struct ecc_set_type {
|
|||||||
word32 oidSz;
|
word32 oidSz;
|
||||||
word32 oidSum; /* sum of encoded OID bytes */
|
word32 oidSum; /* sum of encoded OID bytes */
|
||||||
int cofactor;
|
int cofactor;
|
||||||
} ecc_set_type;
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -441,10 +441,19 @@ typedef struct alt_fp_int {
|
|||||||
#define WC_ECCKEY_TYPE_DEFINED
|
#define WC_ECCKEY_TYPE_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WC_ECCPOINT_TYPE_DEFINED
|
||||||
|
typedef struct ecc_point ecc_point;
|
||||||
|
#define WC_ECCPOINT_TYPE_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WC_ECCSET_TYPE_DEFINED
|
||||||
|
typedef struct ecc_set_type ecc_set_type;
|
||||||
|
#define WC_ECCSET_TYPE_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A point on an ECC curve, stored in Jacobian format such that (x,y,z) =>
|
/* A point on an ECC curve, stored in Jacobian 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 {
|
struct ecc_point {
|
||||||
#ifndef ALT_ECC_SIZE
|
#ifndef ALT_ECC_SIZE
|
||||||
mp_int x[1]; /* The x coordinate */
|
mp_int x[1]; /* The x coordinate */
|
||||||
mp_int y[1]; /* The y coordinate */
|
mp_int y[1]; /* The y coordinate */
|
||||||
@ -458,7 +467,7 @@ typedef struct {
|
|||||||
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK)
|
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK)
|
||||||
ecc_key* key;
|
ecc_key* key;
|
||||||
#endif
|
#endif
|
||||||
} ecc_point;
|
};
|
||||||
|
|
||||||
/* ECC Flags */
|
/* ECC Flags */
|
||||||
enum {
|
enum {
|
||||||
|
Reference in New Issue
Block a user