forked from wolfSSL/wolfssl
2
src/pk.c
2
src/pk.c
@@ -12659,7 +12659,7 @@ point_conversion_form_t wolfSSL_EC_KEY_get_conv_form(const WOLFSSL_EC_KEY* key)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (key != NULL) {
|
if (key != NULL) {
|
||||||
ret = (int)(unsigned char)key->form;
|
ret = key->form;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
22
src/ssl.c
22
src/ssl.c
@@ -22959,7 +22959,7 @@ int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
|
|||||||
unsigned char *local_der = NULL;
|
unsigned char *local_der = NULL;
|
||||||
word32 local_derSz = 0;
|
word32 local_derSz = 0;
|
||||||
unsigned char *pub_der = NULL;
|
unsigned char *pub_der = NULL;
|
||||||
ecc_key eccKey;
|
ecc_key *eccKey = NULL;
|
||||||
word32 inOutIdx = 0;
|
word32 inOutIdx = 0;
|
||||||
#endif
|
#endif
|
||||||
word32 pub_derSz = 0;
|
word32 pub_derSz = 0;
|
||||||
@@ -22996,15 +22996,23 @@ int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_ecc_init(&eccKey);
|
eccKey = (ecc_key *)XMALLOC(sizeof(*eccKey), NULL, DYNAMIC_TYPE_ECC);
|
||||||
|
if (eccKey == NULL) {
|
||||||
|
WOLFSSL_MSG("Failed to allocate key buffer.");
|
||||||
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_EccPublicKeyDecode(local_der, &inOutIdx, &eccKey, local_derSz);
|
ret = wc_ecc_init(eccKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
pub_derSz = wc_EccPublicKeyDerSize(&eccKey, 0);
|
ret = wc_EccPublicKeyDecode(local_der, &inOutIdx, eccKey, local_derSz);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
pub_derSz = wc_EccPublicKeyDerSize(eccKey, 0);
|
||||||
if (pub_derSz <= 0) {
|
if (pub_derSz <= 0) {
|
||||||
ret = WOLFSSL_FAILURE;
|
ret = WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -23020,7 +23028,7 @@ int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
pub_derSz = wc_EccPublicKeyToDer(&eccKey, pub_der, pub_derSz, 0);
|
pub_derSz = wc_EccPublicKeyToDer(eccKey, pub_der, pub_derSz, 0);
|
||||||
if (pub_derSz <= 0) {
|
if (pub_derSz <= 0) {
|
||||||
ret = WOLFSSL_FATAL_ERROR;
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
@@ -23049,7 +23057,9 @@ int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
|
|||||||
XFREE(pub_der, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(pub_der, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
XFREE(local_der, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
XFREE(local_der, NULL, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
|
|
||||||
wc_ecc_free(&eccKey);
|
wc_ecc_free(eccKey);
|
||||||
|
XFREE(eccKey, NULL, DYNAMIC_TYPE_ECC);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
ret = WOLFSSL_FATAL_ERROR;
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
#endif /* HAVE_ECC */
|
#endif /* HAVE_ECC */
|
||||||
|
@@ -581,8 +581,7 @@ static void scryptSalsa(word32* out, word32* in)
|
|||||||
word32 x[16];
|
word32 x[16];
|
||||||
|
|
||||||
#ifdef LITTLE_ENDIAN_ORDER
|
#ifdef LITTLE_ENDIAN_ORDER
|
||||||
for (i = 0; i < 16; ++i)
|
XMEMCPY(x, in, sizeof(x));
|
||||||
x[i] = in[i];
|
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
x[i] = ByteReverseWord32(in[i]);
|
x[i] = ByteReverseWord32(in[i]);
|
||||||
@@ -623,15 +622,14 @@ static void scryptSalsa(word32* out, word32* in)
|
|||||||
*/
|
*/
|
||||||
static void scryptBlockMix(byte* b, byte* y, int r)
|
static void scryptBlockMix(byte* b, byte* y, int r)
|
||||||
{
|
{
|
||||||
byte x[64];
|
|
||||||
#ifdef WORD64_AVAILABLE
|
#ifdef WORD64_AVAILABLE
|
||||||
|
word64 x[8];
|
||||||
word64* b64 = (word64*)b;
|
word64* b64 = (word64*)b;
|
||||||
word64* y64 = (word64*)y;
|
word64* y64 = (word64*)y;
|
||||||
word64* x64 = (word64*)x;
|
|
||||||
#else
|
#else
|
||||||
|
word32 x[16];
|
||||||
word32* b32 = (word32*)b;
|
word32* b32 = (word32*)b;
|
||||||
word32* y32 = (word32*)y;
|
word32* y32 = (word32*)y;
|
||||||
word32* x32 = (word32*)x;
|
|
||||||
#endif
|
#endif
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@@ -643,10 +641,11 @@ static void scryptBlockMix(byte* b, byte* y, int r)
|
|||||||
{
|
{
|
||||||
#ifdef WORD64_AVAILABLE
|
#ifdef WORD64_AVAILABLE
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
x64[j] ^= b64[i * 8 + j];
|
x[j] ^= b64[i * 8 + j];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
for (j = 0; j < 16; j++)
|
for (j = 0; j < 16; j++)
|
||||||
x32[j] ^= b32[i * 16 + j];
|
x[j] ^= b32[i * 16 + j];
|
||||||
#endif
|
#endif
|
||||||
scryptSalsa((word32*)x, (word32*)x);
|
scryptSalsa((word32*)x, (word32*)x);
|
||||||
XMEMCPY(y + i * 64, x, sizeof(x));
|
XMEMCPY(y + i * 64, x, sizeof(x));
|
||||||
|
@@ -116,7 +116,7 @@ struct WOLFSSL_EC_KEY {
|
|||||||
|
|
||||||
void* internal; /* our ECC Key */
|
void* internal; /* our ECC Key */
|
||||||
void* heap;
|
void* heap;
|
||||||
char form; /* Either POINT_CONVERSION_UNCOMPRESSED or
|
unsigned char form; /* Either POINT_CONVERSION_UNCOMPRESSED or
|
||||||
* POINT_CONVERSION_COMPRESSED */
|
* POINT_CONVERSION_COMPRESSED */
|
||||||
word16 pkcs8HeaderSz;
|
word16 pkcs8HeaderSz;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user