mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Merge pull request #2243 from JacobBarthelmeh/Windows
custom ECC curves on Windows
This commit is contained in:
@ -13615,7 +13615,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||
ecc_set_type* curve;
|
||||
int len;
|
||||
char* point;
|
||||
char* point = NULL;
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -13625,8 +13625,13 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
ret = MEMORY_E;
|
||||
|
||||
if (ret == 0) {
|
||||
static char customName[] = "Custom";
|
||||
XMEMSET(curve, 0, sizeof(*curve));
|
||||
curve->name = "Custom";
|
||||
#ifndef USE_WINDOWS_API
|
||||
curve->name = customName;
|
||||
#else
|
||||
XMEMCPY((void*)curve->name, customName, sizeof(customName));
|
||||
#endif
|
||||
curve->id = ECC_CURVE_CUSTOM;
|
||||
|
||||
if (GetSequence(input, inOutIdx, &length, inSz) < 0)
|
||||
@ -13677,6 +13682,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
}
|
||||
}
|
||||
if (ret == 0) {
|
||||
#ifndef USE_WINDOWS_API
|
||||
curve->Gx = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
||||
DYNAMIC_TYPE_ECC_BUFFER);
|
||||
curve->Gy = (const char*)XMALLOC(curve->size * 2 + 2, key->heap,
|
||||
@ -13685,6 +13691,12 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
XFREE(point, key->heap, DYNAMIC_TYPE_ECC_BUFFER);
|
||||
ret = MEMORY_E;
|
||||
}
|
||||
#else
|
||||
if (curve->size * 2 + 2 > MAX_ECC_STRING) {
|
||||
WOLFSSL_MSG("curve size is too large to fit in buffer");
|
||||
ret = BUFFER_E;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (ret == 0) {
|
||||
XMEMCPY((char*)curve->Gx, point + 2, curve->size * 2);
|
||||
@ -13699,14 +13711,20 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
if (ret == 0) {
|
||||
curve->cofactor = GetInteger7Bit(input, inOutIdx, inSz);
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
curve->oid = NULL;
|
||||
#else
|
||||
XMEMSET((void*)curve->oid, 0, sizeof(curve->oid));
|
||||
#endif
|
||||
curve->oidSz = 0;
|
||||
curve->oidSum = 0;
|
||||
|
||||
if (wc_ecc_set_custom_curve(key, curve) < 0) {
|
||||
ret = ASN_PARSE_E;
|
||||
}
|
||||
#ifndef USE_WINDOWS_API
|
||||
key->deallocSet = 1;
|
||||
#endif
|
||||
curve = NULL;
|
||||
}
|
||||
if (curve != NULL)
|
||||
|
Reference in New Issue
Block a user