forked from wolfSSL/wolfssl
Added WOLFSSL_ECC_CURVE_STATIC
build option to allow using fixed arrays for ECC parameters. This is enabled by default on Windows. Fixed several compiler warnings. Fixed build macro for key->deallocSet
.
This commit is contained in:
@@ -14356,7 +14356,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
static char customName[] = "Custom";
|
static char customName[] = "Custom";
|
||||||
XMEMSET(curve, 0, sizeof(*curve));
|
XMEMSET(curve, 0, sizeof(*curve));
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->name = customName;
|
curve->name = customName;
|
||||||
#else
|
#else
|
||||||
XMEMCPY((void*)curve->name, customName, sizeof(customName));
|
XMEMCPY((void*)curve->name, customName, sizeof(customName));
|
||||||
@@ -14377,17 +14377,17 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
SkipObjectId(input, inOutIdx, inSz);
|
SkipObjectId(input, inOutIdx, inSz);
|
||||||
ret = ASNToHexString(input, inOutIdx, &p, inSz,
|
ret = ASNToHexString(input, inOutIdx, &p, inSz,
|
||||||
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->prime = p;
|
curve->prime = p;
|
||||||
#else
|
#else
|
||||||
if (ret == 0 && p != NULL) {
|
if (ret == 0 && p != NULL) {
|
||||||
length = XSTRLEN(p) + 1;
|
length = (int)XSTRLEN(p) + 1;
|
||||||
if (length > MAX_ECC_STRING) {
|
if (length > MAX_ECC_STRING) {
|
||||||
WOLFSSL_MSG("Prime too large for buffer");
|
WOLFSSL_MSG("Prime too large for buffer");
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XSTRNCPY(curve->prime, p, length);
|
XSTRNCPY((char*)curve->prime, p, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFREE(p, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
XFREE(p, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
@@ -14403,17 +14403,17 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
char* af = NULL;
|
char* af = NULL;
|
||||||
ret = ASNToHexString(input, inOutIdx, &af, inSz,
|
ret = ASNToHexString(input, inOutIdx, &af, inSz,
|
||||||
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->Af = af;
|
curve->Af = af;
|
||||||
#else
|
#else
|
||||||
if (ret == 0 && af != NULL) {
|
if (ret == 0 && af != NULL) {
|
||||||
length = XSTRLEN(af) + 1;
|
length = (int)XSTRLEN(af) + 1;
|
||||||
if (length > MAX_ECC_STRING) {
|
if (length > MAX_ECC_STRING) {
|
||||||
WOLFSSL_MSG("Af too large for buffer");
|
WOLFSSL_MSG("Af too large for buffer");
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XSTRNCPY(curve->Af, af, length);
|
XSTRNCPY((char*)curve->Af, af, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFREE(af, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
XFREE(af, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
@@ -14424,17 +14424,17 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
char* bf = NULL;
|
char* bf = NULL;
|
||||||
ret = ASNToHexString(input, inOutIdx, &bf, inSz,
|
ret = ASNToHexString(input, inOutIdx, &bf, inSz,
|
||||||
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->Bf = bf;
|
curve->Bf = bf;
|
||||||
#else
|
#else
|
||||||
if (ret == 0 && bf != NULL) {
|
if (ret == 0 && bf != NULL) {
|
||||||
length = XSTRLEN(bf) + 1;
|
length = (int)XSTRLEN(bf) + 1;
|
||||||
if (length > MAX_ECC_STRING) {
|
if (length > MAX_ECC_STRING) {
|
||||||
WOLFSSL_MSG("Bf too large for buffer");
|
WOLFSSL_MSG("Bf too large for buffer");
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XSTRNCPY(curve->Bf, bf, length);
|
XSTRNCPY((char*)curve->Bf, bf, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFREE(bf, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
XFREE(bf, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
@@ -14462,7 +14462,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->Gx = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
curve->Gx = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
||||||
DYNAMIC_TYPE_ECC_BUFFER);
|
DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
curve->Gy = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
curve->Gy = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
||||||
@@ -14490,17 +14490,17 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
ret = ASNToHexString(input, inOutIdx, &o, inSz,
|
ret = ASNToHexString(input, inOutIdx, &o, inSz,
|
||||||
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->order = o;
|
curve->order = o;
|
||||||
#else
|
#else
|
||||||
if (ret == 0 && o != NULL) {
|
if (ret == 0 && o != NULL) {
|
||||||
length = XSTRLEN(o) + 1;
|
length = (int)XSTRLEN(o) + 1;
|
||||||
if (length > MAX_ECC_STRING) {
|
if (length > MAX_ECC_STRING) {
|
||||||
WOLFSSL_MSG("Order too large for buffer");
|
WOLFSSL_MSG("Order too large for buffer");
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XSTRNCPY(curve->order, o, length);
|
XSTRNCPY((char*)curve->order, o, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFREE(o, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
XFREE(o, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
@@ -14509,7 +14509,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
curve->cofactor = GetInteger7Bit(input, inOutIdx, inSz);
|
curve->cofactor = GetInteger7Bit(input, inOutIdx, inSz);
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
curve->oid = NULL;
|
curve->oid = NULL;
|
||||||
#else
|
#else
|
||||||
XMEMSET((void*)curve->oid, 0, sizeof(curve->oid));
|
XMEMSET((void*)curve->oid, 0, sizeof(curve->oid));
|
||||||
@@ -14520,7 +14520,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
if (wc_ecc_set_custom_curve(key, curve) < 0) {
|
if (wc_ecc_set_custom_curve(key, curve) < 0) {
|
||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
}
|
}
|
||||||
#ifndef USE_WINDOWS_API
|
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||||
key->deallocSet = 1;
|
key->deallocSet = 1;
|
||||||
#endif
|
#endif
|
||||||
curve = NULL;
|
curve = NULL;
|
||||||
|
@@ -53,6 +53,9 @@ Possible ECC enable options:
|
|||||||
* FP_ECC: ECC Fixed Point Cache default: off
|
* FP_ECC: ECC Fixed Point Cache default: off
|
||||||
* USE_ECC_B_PARAM: Enable ECC curve B param default: off
|
* USE_ECC_B_PARAM: Enable ECC curve B param default: off
|
||||||
(on for HAVE_COMP_KEY)
|
(on for HAVE_COMP_KEY)
|
||||||
|
* WOLFSSL_ECC_CURVE_STATIC: default off (on for windows)
|
||||||
|
For the ECC curve paramaters `ecc_set_type` use fixed
|
||||||
|
array for hex string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -212,7 +215,7 @@ enum {
|
|||||||
#define CODED_SECP112R1 {0x2B,0x81,0x04,0x00,0x06}
|
#define CODED_SECP112R1 {0x2B,0x81,0x04,0x00,0x06}
|
||||||
#define CODED_SECP112R1_SZ 5
|
#define CODED_SECP112R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp112r1[] = CODED_SECP112R1;
|
static const ecc_oid_t ecc_oid_secp112r1[] = CODED_SECP112R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp112r1 CODED_SECP112R1
|
#define ecc_oid_secp112r1 CODED_SECP112R1
|
||||||
@@ -227,7 +230,7 @@ enum {
|
|||||||
#define CODED_SECP112R2 {0x2B,0x81,0x04,0x00,0x07}
|
#define CODED_SECP112R2 {0x2B,0x81,0x04,0x00,0x07}
|
||||||
#define CODED_SECP112R2_SZ 5
|
#define CODED_SECP112R2_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp112r2[] = CODED_SECP112R2;
|
static const ecc_oid_t ecc_oid_secp112r2[] = CODED_SECP112R2;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp112r2 CODED_SECP112R2
|
#define ecc_oid_secp112r2 CODED_SECP112R2
|
||||||
@@ -244,7 +247,7 @@ enum {
|
|||||||
#define CODED_SECP128R1 {0x2B,0x81,0x04,0x00,0x1C}
|
#define CODED_SECP128R1 {0x2B,0x81,0x04,0x00,0x1C}
|
||||||
#define CODED_SECP128R1_SZ 5
|
#define CODED_SECP128R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp128r1[] = CODED_SECP128R1;
|
static const ecc_oid_t ecc_oid_secp128r1[] = CODED_SECP128R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp128r1 CODED_SECP128R1
|
#define ecc_oid_secp128r1 CODED_SECP128R1
|
||||||
@@ -259,7 +262,7 @@ enum {
|
|||||||
#define CODED_SECP128R2 {0x2B,0x81,0x04,0x00,0x1D}
|
#define CODED_SECP128R2 {0x2B,0x81,0x04,0x00,0x1D}
|
||||||
#define CODED_SECP128R2_SZ 5
|
#define CODED_SECP128R2_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp128r2[] = CODED_SECP128R2;
|
static const ecc_oid_t ecc_oid_secp128r2[] = CODED_SECP128R2;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp128r2 CODED_SECP128R2
|
#define ecc_oid_secp128r2 CODED_SECP128R2
|
||||||
@@ -276,7 +279,7 @@ enum {
|
|||||||
#define CODED_SECP160R1 {0x2B,0x81,0x04,0x00,0x08}
|
#define CODED_SECP160R1 {0x2B,0x81,0x04,0x00,0x08}
|
||||||
#define CODED_SECP160R1_SZ 5
|
#define CODED_SECP160R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp160r1[] = CODED_SECP160R1;
|
static const ecc_oid_t ecc_oid_secp160r1[] = CODED_SECP160R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp160r1 CODED_SECP160R1
|
#define ecc_oid_secp160r1 CODED_SECP160R1
|
||||||
@@ -291,7 +294,7 @@ enum {
|
|||||||
#define CODED_SECP160R2 {0x2B,0x81,0x04,0x00,0x1E}
|
#define CODED_SECP160R2 {0x2B,0x81,0x04,0x00,0x1E}
|
||||||
#define CODED_SECP160R2_SZ 5
|
#define CODED_SECP160R2_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp160r2[] = CODED_SECP160R2;
|
static const ecc_oid_t ecc_oid_secp160r2[] = CODED_SECP160R2;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp160r2 CODED_SECP160R2
|
#define ecc_oid_secp160r2 CODED_SECP160R2
|
||||||
@@ -306,7 +309,7 @@ enum {
|
|||||||
#define CODED_SECP160K1 {0x2B,0x81,0x04,0x00,0x09}
|
#define CODED_SECP160K1 {0x2B,0x81,0x04,0x00,0x09}
|
||||||
#define CODED_SECP160K1_SZ 5
|
#define CODED_SECP160K1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp160k1[] = CODED_SECP160K1;
|
static const ecc_oid_t ecc_oid_secp160k1[] = CODED_SECP160K1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp160k1 CODED_SECP160K1
|
#define ecc_oid_secp160k1 CODED_SECP160K1
|
||||||
@@ -321,7 +324,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP160R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x01}
|
#define CODED_BRAINPOOLP160R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x01}
|
||||||
#define CODED_BRAINPOOLP160R1_SZ 9
|
#define CODED_BRAINPOOLP160R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp160r1[] = CODED_BRAINPOOLP160R1;
|
static const ecc_oid_t ecc_oid_brainpoolp160r1[] = CODED_BRAINPOOLP160R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp160r1 CODED_BRAINPOOLP160R1
|
#define ecc_oid_brainpoolp160r1 CODED_BRAINPOOLP160R1
|
||||||
@@ -338,7 +341,7 @@ enum {
|
|||||||
#define CODED_SECP192R1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01}
|
#define CODED_SECP192R1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01}
|
||||||
#define CODED_SECP192R1_SZ 8
|
#define CODED_SECP192R1_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp192r1[] = CODED_SECP192R1;
|
static const ecc_oid_t ecc_oid_secp192r1[] = CODED_SECP192R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp192r1 CODED_SECP192R1
|
#define ecc_oid_secp192r1 CODED_SECP192R1
|
||||||
@@ -353,7 +356,7 @@ enum {
|
|||||||
#define CODED_PRIME192V2 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x02}
|
#define CODED_PRIME192V2 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x02}
|
||||||
#define CODED_PRIME192V2_SZ 8
|
#define CODED_PRIME192V2_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_prime192v2[] = CODED_PRIME192V2;
|
static const ecc_oid_t ecc_oid_prime192v2[] = CODED_PRIME192V2;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_prime192v2 CODED_PRIME192V2
|
#define ecc_oid_prime192v2 CODED_PRIME192V2
|
||||||
@@ -368,7 +371,7 @@ enum {
|
|||||||
#define CODED_PRIME192V3 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x03}
|
#define CODED_PRIME192V3 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x03}
|
||||||
#define CODED_PRIME192V3_SZ 8
|
#define CODED_PRIME192V3_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_prime192v3[] = CODED_PRIME192V3;
|
static const ecc_oid_t ecc_oid_prime192v3[] = CODED_PRIME192V3;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_prime192v3 CODED_PRIME192V3
|
#define ecc_oid_prime192v3 CODED_PRIME192V3
|
||||||
@@ -383,7 +386,7 @@ enum {
|
|||||||
#define CODED_SECP192K1 {0x2B,0x81,0x04,0x00,0x1F}
|
#define CODED_SECP192K1 {0x2B,0x81,0x04,0x00,0x1F}
|
||||||
#define CODED_SECP192K1_SZ 5
|
#define CODED_SECP192K1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp192k1[] = CODED_SECP192K1;
|
static const ecc_oid_t ecc_oid_secp192k1[] = CODED_SECP192K1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp192k1 CODED_SECP192K1
|
#define ecc_oid_secp192k1 CODED_SECP192K1
|
||||||
@@ -398,7 +401,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP192R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x03}
|
#define CODED_BRAINPOOLP192R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x03}
|
||||||
#define CODED_BRAINPOOLP192R1_SZ 9
|
#define CODED_BRAINPOOLP192R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp192r1[] = CODED_BRAINPOOLP192R1;
|
static const ecc_oid_t ecc_oid_brainpoolp192r1[] = CODED_BRAINPOOLP192R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp192r1 CODED_BRAINPOOLP192R1
|
#define ecc_oid_brainpoolp192r1 CODED_BRAINPOOLP192R1
|
||||||
@@ -415,7 +418,7 @@ enum {
|
|||||||
#define CODED_SECP224R1 {0x2B,0x81,0x04,0x00,0x21}
|
#define CODED_SECP224R1 {0x2B,0x81,0x04,0x00,0x21}
|
||||||
#define CODED_SECP224R1_SZ 5
|
#define CODED_SECP224R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp224r1[] = CODED_SECP224R1;
|
static const ecc_oid_t ecc_oid_secp224r1[] = CODED_SECP224R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp224r1 CODED_SECP224R1
|
#define ecc_oid_secp224r1 CODED_SECP224R1
|
||||||
@@ -430,7 +433,7 @@ enum {
|
|||||||
#define CODED_SECP224K1 {0x2B,0x81,0x04,0x00,0x20}
|
#define CODED_SECP224K1 {0x2B,0x81,0x04,0x00,0x20}
|
||||||
#define CODED_SECP224K1_SZ 5
|
#define CODED_SECP224K1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp224k1[] = CODED_SECP224K1;
|
static const ecc_oid_t ecc_oid_secp224k1[] = CODED_SECP224K1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp224k1 CODED_SECP224K1
|
#define ecc_oid_secp224k1 CODED_SECP224K1
|
||||||
@@ -445,7 +448,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP224R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x05}
|
#define CODED_BRAINPOOLP224R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x05}
|
||||||
#define CODED_BRAINPOOLP224R1_SZ 9
|
#define CODED_BRAINPOOLP224R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp224r1[] = CODED_BRAINPOOLP224R1;
|
static const ecc_oid_t ecc_oid_brainpoolp224r1[] = CODED_BRAINPOOLP224R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp224r1 CODED_BRAINPOOLP224R1
|
#define ecc_oid_brainpoolp224r1 CODED_BRAINPOOLP224R1
|
||||||
@@ -462,7 +465,7 @@ enum {
|
|||||||
#define CODED_PRIME239V1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x04}
|
#define CODED_PRIME239V1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x04}
|
||||||
#define CODED_PRIME239V1_SZ 8
|
#define CODED_PRIME239V1_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_prime239v1[] = CODED_PRIME239V1;
|
static const ecc_oid_t ecc_oid_prime239v1[] = CODED_PRIME239V1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_prime239v1 CODED_PRIME239V1
|
#define ecc_oid_prime239v1 CODED_PRIME239V1
|
||||||
@@ -477,7 +480,7 @@ enum {
|
|||||||
#define CODED_PRIME239V2 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x05}
|
#define CODED_PRIME239V2 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x05}
|
||||||
#define CODED_PRIME239V2_SZ 8
|
#define CODED_PRIME239V2_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_prime239v2[] = CODED_PRIME239V2;
|
static const ecc_oid_t ecc_oid_prime239v2[] = CODED_PRIME239V2;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_prime239v2 CODED_PRIME239V2
|
#define ecc_oid_prime239v2 CODED_PRIME239V2
|
||||||
@@ -492,7 +495,7 @@ enum {
|
|||||||
#define CODED_PRIME239V3 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x06}
|
#define CODED_PRIME239V3 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x06}
|
||||||
#define CODED_PRIME239V3_SZ 8
|
#define CODED_PRIME239V3_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_prime239v3[] = CODED_PRIME239V3;
|
static const ecc_oid_t ecc_oid_prime239v3[] = CODED_PRIME239V3;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_prime239v3 CODED_PRIME239V3
|
#define ecc_oid_prime239v3 CODED_PRIME239V3
|
||||||
@@ -509,7 +512,7 @@ enum {
|
|||||||
#define CODED_SECP256R1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07}
|
#define CODED_SECP256R1 {0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07}
|
||||||
#define CODED_SECP256R1_SZ 8
|
#define CODED_SECP256R1_SZ 8
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp256r1[] = CODED_SECP256R1;
|
static const ecc_oid_t ecc_oid_secp256r1[] = CODED_SECP256R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp256r1 CODED_SECP256R1
|
#define ecc_oid_secp256r1 CODED_SECP256R1
|
||||||
@@ -524,7 +527,7 @@ enum {
|
|||||||
#define CODED_SECP256K1 {0x2B,0x81,0x04,0x00,0x0A}
|
#define CODED_SECP256K1 {0x2B,0x81,0x04,0x00,0x0A}
|
||||||
#define CODED_SECP256K1_SZ 5
|
#define CODED_SECP256K1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp256k1[] = CODED_SECP256K1;
|
static const ecc_oid_t ecc_oid_secp256k1[] = CODED_SECP256K1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp256k1 CODED_SECP256K1
|
#define ecc_oid_secp256k1 CODED_SECP256K1
|
||||||
@@ -539,7 +542,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP256R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07}
|
#define CODED_BRAINPOOLP256R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07}
|
||||||
#define CODED_BRAINPOOLP256R1_SZ 9
|
#define CODED_BRAINPOOLP256R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp256r1[] = CODED_BRAINPOOLP256R1;
|
static const ecc_oid_t ecc_oid_brainpoolp256r1[] = CODED_BRAINPOOLP256R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp256r1 CODED_BRAINPOOLP256R1
|
#define ecc_oid_brainpoolp256r1 CODED_BRAINPOOLP256R1
|
||||||
@@ -556,7 +559,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP320R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x09}
|
#define CODED_BRAINPOOLP320R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x09}
|
||||||
#define CODED_BRAINPOOLP320R1_SZ 9
|
#define CODED_BRAINPOOLP320R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp320r1[] = CODED_BRAINPOOLP320R1;
|
static const ecc_oid_t ecc_oid_brainpoolp320r1[] = CODED_BRAINPOOLP320R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp320r1 CODED_BRAINPOOLP320R1
|
#define ecc_oid_brainpoolp320r1 CODED_BRAINPOOLP320R1
|
||||||
@@ -573,7 +576,7 @@ enum {
|
|||||||
#define CODED_SECP384R1 {0x2B,0x81,0x04,0x00,0x22}
|
#define CODED_SECP384R1 {0x2B,0x81,0x04,0x00,0x22}
|
||||||
#define CODED_SECP384R1_SZ 5
|
#define CODED_SECP384R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp384r1[] = CODED_SECP384R1;
|
static const ecc_oid_t ecc_oid_secp384r1[] = CODED_SECP384R1;
|
||||||
#define CODED_SECP384R1_OID ecc_oid_secp384r1
|
#define CODED_SECP384R1_OID ecc_oid_secp384r1
|
||||||
#else
|
#else
|
||||||
@@ -589,7 +592,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP384R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0B}
|
#define CODED_BRAINPOOLP384R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0B}
|
||||||
#define CODED_BRAINPOOLP384R1_SZ 9
|
#define CODED_BRAINPOOLP384R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp384r1[] = CODED_BRAINPOOLP384R1;
|
static const ecc_oid_t ecc_oid_brainpoolp384r1[] = CODED_BRAINPOOLP384R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp384r1 CODED_BRAINPOOLP384R1
|
#define ecc_oid_brainpoolp384r1 CODED_BRAINPOOLP384R1
|
||||||
@@ -606,7 +609,7 @@ enum {
|
|||||||
#define CODED_BRAINPOOLP512R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0D}
|
#define CODED_BRAINPOOLP512R1 {0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x0D}
|
||||||
#define CODED_BRAINPOOLP512R1_SZ 9
|
#define CODED_BRAINPOOLP512R1_SZ 9
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_brainpoolp512r1[] = CODED_BRAINPOOLP512R1;
|
static const ecc_oid_t ecc_oid_brainpoolp512r1[] = CODED_BRAINPOOLP512R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_brainpoolp512r1 CODED_BRAINPOOLP512R1
|
#define ecc_oid_brainpoolp512r1 CODED_BRAINPOOLP512R1
|
||||||
@@ -623,7 +626,7 @@ enum {
|
|||||||
#define CODED_SECP521R1 {0x2B,0x81,0x04,0x00,0x23}
|
#define CODED_SECP521R1 {0x2B,0x81,0x04,0x00,0x23}
|
||||||
#define CODED_SECP521R1_SZ 5
|
#define CODED_SECP521R1_SZ 5
|
||||||
#endif
|
#endif
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
static const ecc_oid_t ecc_oid_secp521r1[] = CODED_SECP521R1;
|
static const ecc_oid_t ecc_oid_secp521r1[] = CODED_SECP521R1;
|
||||||
#else
|
#else
|
||||||
#define ecc_oid_secp521r1 CODED_SECP521R1
|
#define ecc_oid_secp521r1 CODED_SECP521R1
|
||||||
@@ -1118,7 +1121,7 @@ const ecc_set_type ecc_sets[] = {
|
|||||||
{
|
{
|
||||||
1, /* non-zero */
|
1, /* non-zero */
|
||||||
ECC_CURVE_CUSTOM,
|
ECC_CURVE_CUSTOM,
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
#else
|
#else
|
||||||
{0},{0},{0},{0},{0},{0},{0},{0},
|
{0},{0},{0},{0},{0},{0},{0},{0},
|
||||||
@@ -1129,7 +1132,7 @@ const ecc_set_type ecc_sets[] = {
|
|||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
ECC_CURVE_INVALID,
|
ECC_CURVE_INVALID,
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
#else
|
#else
|
||||||
{0},{0},{0},{0},{0},{0},{0},{0},
|
{0},{0},{0},{0},{0},{0},{0},{0},
|
||||||
@@ -3144,7 +3147,10 @@ int wc_ecc_get_curve_idx_from_name(const char* curveName)
|
|||||||
len = (word32)XSTRLEN(curveName);
|
len = (word32)XSTRLEN(curveName);
|
||||||
|
|
||||||
for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {
|
for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {
|
||||||
if (ecc_sets[curve_idx].name &&
|
if (
|
||||||
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
|
ecc_sets[curve_idx].name &&
|
||||||
|
#endif
|
||||||
XSTRNCASECMP(ecc_sets[curve_idx].name, curveName, len) == 0) {
|
XSTRNCASECMP(ecc_sets[curve_idx].name, curveName, len) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3331,9 +3337,14 @@ int wc_ecc_get_curve_id_from_dp_params(const ecc_set_type* dp)
|
|||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (dp == NULL || dp->prime == NULL || dp->Af == NULL ||
|
if (dp == NULL
|
||||||
dp->Bf == NULL || dp->order == NULL || dp->Gx == NULL || dp->Gy == NULL)
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
|
|| dp->prime == NULL || dp->Af == NULL ||
|
||||||
|
dp->Bf == NULL || dp->order == NULL || dp->Gx == NULL || dp->Gy == NULL
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
for (idx = 0; ecc_sets[idx].size != 0; idx++) {
|
for (idx = 0; ecc_sets[idx].size != 0; idx++) {
|
||||||
if (dp->size == ecc_sets[idx].size) {
|
if (dp->size == ecc_sets[idx].size) {
|
||||||
@@ -3376,7 +3387,11 @@ int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len)
|
|||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {
|
for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {
|
||||||
if (ecc_sets[curve_idx].oid && ecc_sets[curve_idx].oidSz == len &&
|
if (
|
||||||
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
|
ecc_sets[curve_idx].oid &&
|
||||||
|
#endif
|
||||||
|
ecc_sets[curve_idx].oidSz == len &&
|
||||||
XMEMCMP(ecc_sets[curve_idx].oid, oid, len) == 0) {
|
XMEMCMP(ecc_sets[curve_idx].oid, oid, len) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5127,7 +5142,7 @@ int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key)
|
|||||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||||
void wc_ecc_free_curve(const ecc_set_type* curve, void* heap)
|
void wc_ecc_free_curve(const ecc_set_type* curve, void* heap)
|
||||||
{
|
{
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
if (curve->prime != NULL)
|
if (curve->prime != NULL)
|
||||||
XFREE((void*)curve->prime, heap, DYNAMIC_TYPE_ECC_BUFFER);
|
XFREE((void*)curve->prime, heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||||
if (curve->Af != NULL)
|
if (curve->Af != NULL)
|
||||||
|
@@ -18241,10 +18241,20 @@ static int ecc_test_custom_curves(WC_RNG* rng)
|
|||||||
ecc_key key;
|
ecc_key key;
|
||||||
|
|
||||||
/* test use of custom curve - using BRAINPOOLP256R1 for test */
|
/* test use of custom curve - using BRAINPOOLP256R1 for test */
|
||||||
const word32 ecc_oid_brainpoolp256r1_sum = 104;
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
const ecc_oid_t ecc_oid_brainpoolp256r1[] = {
|
const ecc_oid_t ecc_oid_brainpoolp256r1[] = {
|
||||||
0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07
|
0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07
|
||||||
};
|
};
|
||||||
|
const word32 ecc_oid_brainpoolp256r1_sz =
|
||||||
|
sizeof(ecc_oid_brainpoolp256r1) / sizeof(ecc_oid_t);
|
||||||
|
#else
|
||||||
|
#define ecc_oid_brainpoolp256r1 { \
|
||||||
|
0x2B,0x24,0x03,0x03,0x02,0x08,0x01,0x01,0x07 \
|
||||||
|
}
|
||||||
|
#define ecc_oid_brainpoolp256r1_sz 9
|
||||||
|
#endif
|
||||||
|
const word32 ecc_oid_brainpoolp256r1_sum = 104;
|
||||||
|
|
||||||
const ecc_set_type ecc_dp_brainpool256r1 = {
|
const ecc_set_type ecc_dp_brainpool256r1 = {
|
||||||
32, /* size/bytes */
|
32, /* size/bytes */
|
||||||
ECC_CURVE_CUSTOM, /* ID */
|
ECC_CURVE_CUSTOM, /* ID */
|
||||||
@@ -18256,7 +18266,7 @@ static int ecc_test_custom_curves(WC_RNG* rng)
|
|||||||
"8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262", /* Gx */
|
"8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262", /* Gx */
|
||||||
"547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997", /* Gy */
|
"547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997", /* Gy */
|
||||||
ecc_oid_brainpoolp256r1, /* oid/oidSz */
|
ecc_oid_brainpoolp256r1, /* oid/oidSz */
|
||||||
sizeof(ecc_oid_brainpoolp256r1) / sizeof(ecc_oid_t),
|
ecc_oid_brainpoolp256r1_sz,
|
||||||
ecc_oid_brainpoolp256r1_sum, /* oid sum */
|
ecc_oid_brainpoolp256r1_sum, /* oid sum */
|
||||||
1, /* cofactor */
|
1, /* cofactor */
|
||||||
};
|
};
|
||||||
|
@@ -214,8 +214,17 @@ typedef byte ecc_oid_t;
|
|||||||
if any element > 127 then MSB 0x80 indicates additional byte */
|
if any element > 127 then MSB 0x80 indicates additional byte */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(WOLFSSL_ECC_CURVE_STATIC) && defined(USE_WINDOWS_API)
|
||||||
|
/* MSC does something different with the pointers to the arrays than GCC,
|
||||||
|
* and it causes the FIPS checksum to fail. In the case of windows builds,
|
||||||
|
* store everything as arrays instead of pointers to strings. */
|
||||||
|
|
||||||
|
#define WOLFSSL_ECC_CURVE_STATIC
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ECC set type defined a GF(p) curve */
|
/* ECC set type defined a GF(p) curve */
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef WOLFSSL_ECC_CURVE_STATIC
|
||||||
typedef struct ecc_set_type {
|
typedef 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 */
|
||||||
@@ -232,10 +241,6 @@ typedef struct ecc_set_type {
|
|||||||
int cofactor;
|
int cofactor;
|
||||||
} ecc_set_type;
|
} ecc_set_type;
|
||||||
#else
|
#else
|
||||||
/* MSC does something different with the pointers to the arrays than GCC,
|
|
||||||
* and it causes the FIPS checksum to fail. In the case of windows builds,
|
|
||||||
* store everything as arrays instead of pointers to strings. */
|
|
||||||
|
|
||||||
#define MAX_ECC_NAME 16
|
#define MAX_ECC_NAME 16
|
||||||
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 1)
|
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 1)
|
||||||
/* The values are stored as text strings. */
|
/* The values are stored as text strings. */
|
||||||
|
Reference in New Issue
Block a user