forked from wolfSSL/wolfssl
align return code, coding style (tab-> space, line with 80 char), curve_idx validity
This commit is contained in:
@ -529,7 +529,8 @@ WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len,
|
|||||||
|
|
||||||
|
|
||||||
/* winodws header clash for WinCE using GetVersion */
|
/* winodws header clash for WinCE using GetVersion */
|
||||||
WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx, int* version)
|
WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx,
|
||||||
|
int* version)
|
||||||
{
|
{
|
||||||
word32 idx = *inOutIdx;
|
word32 idx = *inOutIdx;
|
||||||
|
|
||||||
@ -939,12 +940,12 @@ static int DecryptKey(const char* password, int passwordSz, byte* salt,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (version == PKCS5v2)
|
if (version == PKCS5v2)
|
||||||
ret = wc_PBKDF2(key, (byte*)password, passwordSz, salt, saltSz, iterations,
|
ret = wc_PBKDF2(key, (byte*)password, passwordSz,
|
||||||
derivedLen, typeH);
|
salt, saltSz, iterations, derivedLen, typeH);
|
||||||
#ifndef NO_SHA
|
#ifndef NO_SHA
|
||||||
else if (version == PKCS5)
|
else if (version == PKCS5)
|
||||||
ret = wc_PBKDF1(key, (byte*)password, passwordSz, salt, saltSz, iterations,
|
ret = wc_PBKDF1(key, (byte*)password, passwordSz,
|
||||||
derivedLen, typeH);
|
salt, saltSz, iterations, derivedLen, typeH);
|
||||||
#endif
|
#endif
|
||||||
else if (version == PKCS12) {
|
else if (version == PKCS12) {
|
||||||
int i, idx = 0;
|
int i, idx = 0;
|
||||||
@ -6272,14 +6273,16 @@ int wc_SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wc_MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* key, RNG* rng)
|
int wc_MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz,
|
||||||
|
RsaKey* key, RNG* rng)
|
||||||
{
|
{
|
||||||
int ret = wc_MakeCert(cert, buffer, buffSz, key, NULL, rng);
|
int ret = wc_MakeCert(cert, buffer, buffSz, key, NULL, rng);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return wc_SignCert(cert->bodySz, cert->sigType, buffer, buffSz, key, NULL,rng);
|
return wc_SignCert(cert->bodySz, cert->sigType,
|
||||||
|
buffer, buffSz, key, NULL, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1442,25 +1442,30 @@ void ecc_del_point(ecc_point* p)
|
|||||||
*/
|
*/
|
||||||
int ecc_copy_point(ecc_point* p, ecc_point *r)
|
int ecc_copy_point(ecc_point* p, ecc_point *r)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* prevents null arguments */
|
/* prevents null arguments */
|
||||||
if (p == NULL || r == NULL)
|
if (p == NULL || r == NULL)
|
||||||
return 0;
|
return ECC_BAD_ARG_E;
|
||||||
|
|
||||||
if (mp_copy(p->x, r->x) != MP_OKAY)
|
ret = mp_copy(p->x, r->x);
|
||||||
return 0;
|
if (ret != MP_OKAY)
|
||||||
if (mp_copy(p->y, r->y) != MP_OKAY)
|
return ret;
|
||||||
return 0;
|
ret = mp_copy(p->y, r->y);
|
||||||
if (mp_copy(p->z, r->z) != MP_OKAY)
|
if (ret != MP_OKAY)
|
||||||
return 0;
|
return ret;
|
||||||
|
ret = mp_copy(p->z, r->z);
|
||||||
|
if (ret != MP_OKAY)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return 1;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare the value of a point with an other one
|
/** Compare the value of a point with an other one
|
||||||
a The point to compare
|
a The point to compare
|
||||||
b The othe point to compare
|
b The othe point to compare
|
||||||
|
|
||||||
return 0 if equal, 1 if not, -1 in case of error
|
return MP_EQ if equal, MP_LT/MP_GT if not, < 0 in case of error
|
||||||
*/
|
*/
|
||||||
int ecc_cmp_point(ecc_point* a, ecc_point *b)
|
int ecc_cmp_point(ecc_point* a, ecc_point *b)
|
||||||
{
|
{
|
||||||
@ -1468,28 +1473,19 @@ int ecc_cmp_point(ecc_point* a, ecc_point *b)
|
|||||||
|
|
||||||
/* prevents null arguments */
|
/* prevents null arguments */
|
||||||
if (a == NULL || b == NULL)
|
if (a == NULL || b == NULL)
|
||||||
return -1;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
ret = mp_cmp(a->x, b->x);
|
ret = mp_cmp(a->x, b->x);
|
||||||
if (ret != MP_EQ) {
|
if (ret != MP_EQ)
|
||||||
if (ret != MP_LT && ret != MP_GT)
|
return ret;
|
||||||
return -1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ret = mp_cmp(a->y, b->y);
|
ret = mp_cmp(a->y, b->y);
|
||||||
if (ret != MP_EQ) {
|
if (ret != MP_EQ)
|
||||||
if (ret != MP_LT && ret != MP_GT)
|
return ret;
|
||||||
return -1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ret = mp_cmp(a->z, b->z);
|
ret = mp_cmp(a->z, b->z);
|
||||||
if (ret != MP_EQ) {
|
if (ret != MP_EQ)
|
||||||
if (ret != MP_LT && ret != MP_GT)
|
return ret;
|
||||||
return -1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return MP_EQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether an ECC idx is valid or not
|
/** Returns whether an ECC idx is valid or not
|
||||||
@ -1588,7 +1584,8 @@ int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
|
|||||||
outlen [in/out] The max size and resulting size of the shared secret
|
outlen [in/out] The max size and resulting size of the shared secret
|
||||||
return MP_OKAY if successful
|
return MP_OKAY if successful
|
||||||
*/
|
*/
|
||||||
int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point, byte* out, word32 *outlen)
|
int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point,
|
||||||
|
byte* out, word32 *outlen)
|
||||||
{
|
{
|
||||||
word32 x = 0;
|
word32 x = 0;
|
||||||
ecc_point* result;
|
ecc_point* result;
|
||||||
@ -1630,7 +1627,8 @@ int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point, byte* out,
|
|||||||
|
|
||||||
if (err == MP_OKAY) {
|
if (err == MP_OKAY) {
|
||||||
XMEMSET(out, 0, x);
|
XMEMSET(out, 0, x);
|
||||||
err = mp_to_unsigned_bin(result->x,out + (x - mp_unsigned_bin_size(result->x)));
|
err = mp_to_unsigned_bin(result->x,out +
|
||||||
|
(x - mp_unsigned_bin_size(result->x)));
|
||||||
*outlen = x;
|
*outlen = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1823,7 +1821,7 @@ int wc_ecc_init(ecc_key* key)
|
|||||||
alt_fp_init(key->pubkey.z);
|
alt_fp_init(key->pubkey.z);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return MP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1843,7 +1841,8 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
|||||||
mp_int s;
|
mp_int s;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (in == NULL || out == NULL || outlen == NULL || key == NULL || rng == NULL)
|
if (in == NULL || out == NULL || outlen == NULL ||
|
||||||
|
key == NULL || rng == NULL)
|
||||||
return ECC_BAD_ARG_E;
|
return ECC_BAD_ARG_E;
|
||||||
|
|
||||||
if ((err = mp_init_multi(&r, &s, NULL, NULL, NULL, NULL)) != MP_OKAY) {
|
if ((err = mp_init_multi(&r, &s, NULL, NULL, NULL, NULL)) != MP_OKAY) {
|
||||||
@ -1916,7 +1915,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, RNG* rng,
|
|||||||
if (err == MP_OKAY) {
|
if (err == MP_OKAY) {
|
||||||
int loop_check = 0;
|
int loop_check = 0;
|
||||||
ecc_key pubkey;
|
ecc_key pubkey;
|
||||||
wc_ecc_init(&pubkey);
|
if (wc_ecc_init(&pubkey) == MP_OKAY) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (++loop_check > 64) {
|
if (++loop_check > 64) {
|
||||||
err = RNG_FAILURE_E;
|
err = RNG_FAILURE_E;
|
||||||
@ -1958,6 +1957,7 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, RNG* rng,
|
|||||||
}
|
}
|
||||||
wc_ecc_free(&pubkey);
|
wc_ecc_free(&pubkey);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mp_clear(&p);
|
mp_clear(&p);
|
||||||
mp_clear(&e);
|
mp_clear(&e);
|
||||||
@ -2335,7 +2335,8 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
|
|
||||||
/* check for zero */
|
/* check for zero */
|
||||||
if (err == MP_OKAY) {
|
if (err == MP_OKAY) {
|
||||||
if (mp_iszero(r) || mp_iszero(s) || mp_cmp(r, &p) != MP_LT || mp_cmp(s, &p) != MP_LT)
|
if (mp_iszero(r) || mp_iszero(s) || mp_cmp(r, &p) != MP_LT ||
|
||||||
|
mp_cmp(s, &p) != MP_LT)
|
||||||
err = MP_ZERO_E;
|
err = MP_ZERO_E;
|
||||||
}
|
}
|
||||||
/* read hash */
|
/* read hash */
|
||||||
@ -2434,12 +2435,14 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* import point from der */
|
/* import point from der */
|
||||||
int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx, ecc_point* point)
|
int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
|
||||||
|
ecc_point* point)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int compressed = 0;
|
int compressed = 0;
|
||||||
|
|
||||||
if (in == NULL || point == NULL || (ecc_is_valid_idx(curve_idx) == 0))
|
if (in == NULL || point == NULL || (curve_idx < 0) ||
|
||||||
|
(ecc_is_valid_idx(curve_idx) == 0))
|
||||||
return ECC_BAD_ARG_E;
|
return ECC_BAD_ARG_E;
|
||||||
|
|
||||||
/* must be odd */
|
/* must be odd */
|
||||||
@ -2539,7 +2542,8 @@ int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx, ecc_poi
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (err == MP_OKAY && compressed == 0)
|
if (err == MP_OKAY && compressed == 0)
|
||||||
err = mp_read_unsigned_bin(point->y, (byte*)in+1+((inLen-1)>>1), (inLen-1)>>1);
|
err = mp_read_unsigned_bin(point->y,
|
||||||
|
(byte*)in+1+((inLen-1)>>1), (inLen-1)>>1);
|
||||||
if (err == MP_OKAY)
|
if (err == MP_OKAY)
|
||||||
mp_set(point->z, 1);
|
mp_set(point->z, 1);
|
||||||
|
|
||||||
@ -2553,7 +2557,8 @@ int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx, ecc_poi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* export point to der */
|
/* export point to der */
|
||||||
int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out, word32* outLen)
|
int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out,
|
||||||
|
word32* outLen)
|
||||||
{
|
{
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
byte* buf;
|
byte* buf;
|
||||||
@ -2563,7 +2568,7 @@ int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out, wo
|
|||||||
word32 numlen;
|
word32 numlen;
|
||||||
int ret = MP_OKAY;
|
int ret = MP_OKAY;
|
||||||
|
|
||||||
if (curve_idx < 0)
|
if ((curve_idx < 0) || (ecc_is_valid_idx(curve_idx) == 0))
|
||||||
return ECC_BAD_ARG_E;
|
return ECC_BAD_ARG_E;
|
||||||
|
|
||||||
/* return length needed only */
|
/* return length needed only */
|
||||||
@ -2595,16 +2600,16 @@ int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out, wo
|
|||||||
do {
|
do {
|
||||||
/* pad and store x */
|
/* pad and store x */
|
||||||
XMEMSET(buf, 0, ECC_BUFSIZE);
|
XMEMSET(buf, 0, ECC_BUFSIZE);
|
||||||
ret = mp_to_unsigned_bin(point->x,
|
ret = mp_to_unsigned_bin(point->x, buf +
|
||||||
buf + (numlen - mp_unsigned_bin_size(point->x)));
|
(numlen - mp_unsigned_bin_size(point->x)));
|
||||||
if (ret != MP_OKAY)
|
if (ret != MP_OKAY)
|
||||||
break;
|
break;
|
||||||
XMEMCPY(out+1, buf, numlen);
|
XMEMCPY(out+1, buf, numlen);
|
||||||
|
|
||||||
/* pad and store y */
|
/* pad and store y */
|
||||||
XMEMSET(buf, 0, ECC_BUFSIZE);
|
XMEMSET(buf, 0, ECC_BUFSIZE);
|
||||||
ret = mp_to_unsigned_bin(point->y,
|
ret = mp_to_unsigned_bin(point->y, buf +
|
||||||
buf + (numlen - mp_unsigned_bin_size(point->y)));
|
(numlen - mp_unsigned_bin_size(point->y)));
|
||||||
if (ret != MP_OKAY)
|
if (ret != MP_OKAY)
|
||||||
break;
|
break;
|
||||||
XMEMCPY(out+1+numlen, buf, numlen);
|
XMEMCPY(out+1+numlen, buf, numlen);
|
||||||
@ -2690,7 +2695,8 @@ int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen)
|
|||||||
|
|
||||||
/* export public ECC key in ANSI X9.63 format, extended with
|
/* export public ECC key in ANSI X9.63 format, extended with
|
||||||
* compression option */
|
* compression option */
|
||||||
int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int compressed)
|
int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
|
||||||
|
int compressed)
|
||||||
{
|
{
|
||||||
if (compressed == 0)
|
if (compressed == 0)
|
||||||
return wc_ecc_export_x963(key, out, outLen);
|
return wc_ecc_export_x963(key, out, outLen);
|
||||||
@ -3235,8 +3241,8 @@ int wc_ecc_size(ecc_key* key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* worst case estimate, check actual return from wc_ecc_sign_hash for actual value
|
/* worst case estimate, check actual return from wc_ecc_sign_hash for actual
|
||||||
of signature size in octets */
|
value of signature size in octets */
|
||||||
int wc_ecc_sig_size(ecc_key* key)
|
int wc_ecc_sig_size(ecc_key* key)
|
||||||
{
|
{
|
||||||
int sz = wc_ecc_size(key);
|
int sz = wc_ecc_size(key);
|
||||||
|
@ -1888,7 +1888,8 @@ int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0; x < (winsize - 1); x++) {
|
for (x = 0; x < (winsize - 1); x++) {
|
||||||
if ((err = mp_sqr (&M[(mp_digit)(1 << (winsize - 1))], &M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
|
if ((err = mp_sqr (&M[(mp_digit)(1 << (winsize - 1))],
|
||||||
|
&M[(mp_digit)(1 << (winsize - 1))])) != MP_OKAY) {
|
||||||
goto LBL_RES;
|
goto LBL_RES;
|
||||||
}
|
}
|
||||||
if ((err = redux (&M[(mp_digit)(1 << (winsize - 1))], P, mp)) != MP_OKAY) {
|
if ((err = redux (&M[(mp_digit)(1 << (winsize - 1))], P, mp)) != MP_OKAY) {
|
||||||
@ -3192,7 +3193,8 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
|
|||||||
bits = mp_count_bits (b) % DIGIT_BIT;
|
bits = mp_count_bits (b) % DIGIT_BIT;
|
||||||
|
|
||||||
if (b->used > 1) {
|
if (b->used > 1) {
|
||||||
if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
|
if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1))
|
||||||
|
!= MP_OKAY) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3624,7 +3626,8 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
|||||||
/* can we use the fast multiplier? */
|
/* can we use the fast multiplier? */
|
||||||
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
||||||
if (((a->used + b->used + 1) < MP_WARRAY)
|
if (((a->used + b->used + 1) < MP_WARRAY)
|
||||||
&& MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
|
&& MIN (a->used, b->used) <
|
||||||
|
(1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
|
||||||
return fast_s_mp_mul_high_digs (a, b, c, digs);
|
return fast_s_mp_mul_high_digs (a, b, c, digs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -3818,7 +3821,8 @@ int mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(WOLFSSL_SNIFFER) || defined(WOLFSSL_HAVE_WOLFSCEP) || defined(WOLFSSL_KEY_GEN)
|
#if defined(HAVE_ECC) || !defined(NO_PWDBASED) || defined(WOLFSSL_SNIFFER) || \
|
||||||
|
defined(WOLFSSL_HAVE_WOLFSCEP) || defined(WOLFSSL_KEY_GEN)
|
||||||
|
|
||||||
/* single digit addition */
|
/* single digit addition */
|
||||||
int mp_add_d (mp_int* a, mp_digit b, mp_int* c)
|
int mp_add_d (mp_int* a, mp_digit b, mp_int* c)
|
||||||
@ -4472,7 +4476,8 @@ LBL_U:mp_clear (&v);
|
|||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
|
|
||||||
/* chars used in radix conversions */
|
/* chars used in radix conversions */
|
||||||
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
|
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\
|
||||||
|
abcdefghijklmnopqrstuvwxyz+/";
|
||||||
|
|
||||||
/* read a string [ASCII] in a given radix */
|
/* read a string [ASCII] in a given radix */
|
||||||
int mp_read_radix (mp_int * a, const char *str, int radix)
|
int mp_read_radix (mp_int * a, const char *str, int radix)
|
||||||
|
@ -966,8 +966,8 @@ int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d)
|
|||||||
#ifdef TFM_TIMING_RESISTANT
|
#ifdef TFM_TIMING_RESISTANT
|
||||||
|
|
||||||
/* timing resistant montgomery ladder based exptmod
|
/* timing resistant montgomery ladder based exptmod
|
||||||
|
Based on work by Marc Joye, Sung-Ming Yen, "The Montgomery Powering Ladder",
|
||||||
Based on work by Marc Joye, Sung-Ming Yen, "The Montgomery Powering Ladder", Cryptographic Hardware and Embedded Systems, CHES 2002
|
Cryptographic Hardware and Embedded Systems, CHES 2002
|
||||||
*/
|
*/
|
||||||
static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
||||||
{
|
{
|
||||||
@ -1085,7 +1085,8 @@ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
|||||||
}
|
}
|
||||||
fp_mulmod (&M[1], &res, P, &M[1]);
|
fp_mulmod (&M[1], &res, P, &M[1]);
|
||||||
|
|
||||||
/* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
|
/* compute the value at M[1<<(winsize-1)] by
|
||||||
|
* squaring M[1] (winsize-1) times */
|
||||||
fp_copy (&M[1], &M[1 << (winsize - 1)]);
|
fp_copy (&M[1], &M[1 << (winsize - 1)]);
|
||||||
for (x = 0; x < (winsize - 1); x++) {
|
for (x = 0; x < (winsize - 1); x++) {
|
||||||
fp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)]);
|
fp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)]);
|
||||||
@ -1737,7 +1738,8 @@ void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c)
|
|||||||
|
|
||||||
/* If we know the endianness of this architecture, and we're using
|
/* If we know the endianness of this architecture, and we're using
|
||||||
32-bit fp_digits, we can optimize this */
|
32-bit fp_digits, we can optimize this */
|
||||||
#if (defined(LITTLE_ENDIAN_ORDER) || defined(BIG_ENDIAN_ORDER)) && defined(FP_32BIT)
|
#if (defined(LITTLE_ENDIAN_ORDER) || defined(BIG_ENDIAN_ORDER)) && \
|
||||||
|
defined(FP_32BIT)
|
||||||
/* But not for both simultaneously */
|
/* But not for both simultaneously */
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && defined(BIG_ENDIAN_ORDER)
|
#if defined(LITTLE_ENDIAN_ORDER) && defined(BIG_ENDIAN_ORDER)
|
||||||
#error Both LITTLE_ENDIAN_ORDER and BIG_ENDIAN_ORDER defined.
|
#error Both LITTLE_ENDIAN_ORDER and BIG_ENDIAN_ORDER defined.
|
||||||
@ -2003,7 +2005,8 @@ void mp_clear (mp_int * a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* handle up to 6 inits */
|
/* handle up to 6 inits */
|
||||||
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, mp_int* f)
|
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d,
|
||||||
|
mp_int* e, mp_int* f)
|
||||||
{
|
{
|
||||||
if (a)
|
if (a)
|
||||||
fp_init(a);
|
fp_init(a);
|
||||||
@ -2597,7 +2600,8 @@ int mp_add_d(fp_int *a, fp_digit b, fp_int *c)
|
|||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
|
|
||||||
/* chars used in radix conversions */
|
/* chars used in radix conversions */
|
||||||
static const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
|
static const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\
|
||||||
|
abcdefghijklmnopqrstuvwxyz+/";
|
||||||
|
|
||||||
static int fp_read_radix(fp_int *a, const char *str, int radix)
|
static int fp_read_radix(fp_int *a, const char *str, int radix)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,8 @@ WOLFSSL_API int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM*, int n);
|
|||||||
WOLFSSL_API int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM**, const char* str);
|
WOLFSSL_API int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM**, const char* str);
|
||||||
|
|
||||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM*);
|
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM*);
|
||||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*);
|
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM*,
|
||||||
|
const WOLFSSL_BIGNUM*);
|
||||||
|
|
||||||
WOLFSSL_API int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM**, const char* str);
|
WOLFSSL_API int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM**, const char* str);
|
||||||
WOLFSSL_API char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM*);
|
WOLFSSL_API char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM*);
|
||||||
@ -69,12 +70,13 @@ WOLFSSL_API int wolfSSL_BN_add_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
|||||||
WOLFSSL_API int wolfSSL_BN_set_bit(WOLFSSL_BIGNUM*, int);
|
WOLFSSL_API int wolfSSL_BN_set_bit(WOLFSSL_BIGNUM*, int);
|
||||||
WOLFSSL_API int wolfSSL_BN_set_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
WOLFSSL_API int wolfSSL_BN_set_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
||||||
|
|
||||||
|
WOLFSSL_API int wolfSSL_BN_add(WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*,
|
||||||
/* 2/6 */
|
WOLFSSL_BIGNUM*);
|
||||||
WOLFSSL_API int wolfSSL_BN_add(WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*);
|
|
||||||
WOLFSSL_API char *wolfSSL_BN_bn2hex(const WOLFSSL_BIGNUM*);
|
WOLFSSL_API char *wolfSSL_BN_bn2hex(const WOLFSSL_BIGNUM*);
|
||||||
WOLFSSL_API int wolfSSL_BN_is_prime_ex(const WOLFSSL_BIGNUM*, int, WOLFSSL_BN_CTX*, WOLFSSL_BN_GENCB*);
|
WOLFSSL_API int wolfSSL_BN_is_prime_ex(const WOLFSSL_BIGNUM*, int,
|
||||||
WOLFSSL_API WOLFSSL_BN_ULONG wolfSSL_BN_mod_word(const WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
WOLFSSL_BN_CTX*, WOLFSSL_BN_GENCB*);
|
||||||
|
WOLFSSL_API WOLFSSL_BN_ULONG wolfSSL_BN_mod_word(const WOLFSSL_BIGNUM*,
|
||||||
|
WOLFSSL_BN_ULONG);
|
||||||
WOLFSSL_API int wolfSSL_BN_print_fp(FILE*, const WOLFSSL_BIGNUM*);
|
WOLFSSL_API int wolfSSL_BN_print_fp(FILE*, const WOLFSSL_BIGNUM*);
|
||||||
WOLFSSL_API int wolfSSL_BN_rshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
|
WOLFSSL_API int wolfSSL_BN_rshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
|
||||||
WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_BN_CTX_get(WOLFSSL_BN_CTX *ctx);
|
WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_BN_CTX_get(WOLFSSL_BN_CTX *ctx);
|
||||||
|
@ -4,18 +4,13 @@
|
|||||||
#ifndef WOLFSSL_DH_H_
|
#ifndef WOLFSSL_DH_H_
|
||||||
#define WOLFSSL_DH_H_
|
#define WOLFSSL_DH_H_
|
||||||
|
|
||||||
|
|
||||||
#include <wolfssl/openssl/ssl.h>
|
#include <wolfssl/openssl/ssl.h>
|
||||||
#include <wolfssl/openssl/bn.h>
|
#include <wolfssl/openssl/bn.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct WOLFSSL_DH {
|
typedef struct WOLFSSL_DH {
|
||||||
WOLFSSL_BIGNUM* p;
|
WOLFSSL_BIGNUM* p;
|
||||||
WOLFSSL_BIGNUM* g;
|
WOLFSSL_BIGNUM* g;
|
||||||
|
@ -4,17 +4,13 @@
|
|||||||
#ifndef WOLFSSL_DSA_H_
|
#ifndef WOLFSSL_DSA_H_
|
||||||
#define WOLFSSL_DSA_H_
|
#define WOLFSSL_DSA_H_
|
||||||
|
|
||||||
|
|
||||||
#include <wolfssl/openssl/ssl.h>
|
#include <wolfssl/openssl/ssl.h>
|
||||||
#include <wolfssl/openssl/bn.h>
|
#include <wolfssl/openssl/bn.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct WOLFSSL_DSA {
|
struct WOLFSSL_DSA {
|
||||||
WOLFSSL_BIGNUM* p;
|
WOLFSSL_BIGNUM* p;
|
||||||
WOLFSSL_BIGNUM* q;
|
WOLFSSL_BIGNUM* q;
|
||||||
@ -36,9 +32,12 @@ WOLFSSL_API int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA*, int bits,
|
|||||||
unsigned long* hRet, void* cb);
|
unsigned long* hRet, void* cb);
|
||||||
|
|
||||||
WOLFSSL_API int wolfSSL_DSA_LoadDer(WOLFSSL_DSA*, const unsigned char*, int sz);
|
WOLFSSL_API int wolfSSL_DSA_LoadDer(WOLFSSL_DSA*, const unsigned char*, int sz);
|
||||||
WOLFSSL_API int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
|
|
||||||
WOLFSSL_DSA* dsa);
|
WOLFSSL_API int wolfSSL_DSA_do_sign(const unsigned char* d,
|
||||||
WOLFSSL_API int wolfSSL_DSA_do_verify(const unsigned char* d, unsigned char* sig,
|
unsigned char* sigRet, WOLFSSL_DSA* dsa);
|
||||||
|
|
||||||
|
WOLFSSL_API int wolfSSL_DSA_do_verify(const unsigned char* d,
|
||||||
|
unsigned char* sig,
|
||||||
WOLFSSL_DSA* dsa, int *dsacheck);
|
WOLFSSL_DSA* dsa, int *dsacheck);
|
||||||
|
|
||||||
#define DSA_new wolfSSL_DSA_new
|
#define DSA_new wolfSSL_DSA_new
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <wolfssl/openssl/ssl.h>
|
#include <wolfssl/openssl/ssl.h>
|
||||||
#include <wolfssl/openssl/bn.h>
|
#include <wolfssl/openssl/bn.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -37,8 +36,8 @@ struct WOLFSSL_EC_POINT {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct WOLFSSL_EC_GROUP {
|
struct WOLFSSL_EC_GROUP {
|
||||||
int curve_idx; /* index of curve, used by WolfSSL as a curve reference */
|
int curve_idx; /* index of curve, used by WolfSSL as reference */
|
||||||
int curve_nid; /* NID of curve, used by OpenSSL/OpenSSH as a curve reference */
|
int curve_nid; /* NID of curve, used by OpenSSL/OpenSSH as reference */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WOLFSSL_EC_KEY {
|
struct WOLFSSL_EC_KEY {
|
||||||
@ -51,42 +50,82 @@ struct WOLFSSL_EC_KEY {
|
|||||||
char exSet; /* external set from internal ? */
|
char exSet; /* external set from internal ? */
|
||||||
};
|
};
|
||||||
|
|
||||||
WOLFSSL_API int wolfSSL_ECPoint_i2d(const WOLFSSL_EC_GROUP *curve, const WOLFSSL_EC_POINT *p, unsigned char *out, unsigned int *len);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_ECPoint_d2i(unsigned char *in, unsigned int len, const WOLFSSL_EC_GROUP *curve, WOLFSSL_EC_POINT *p);
|
int wolfSSL_ECPoint_i2d(const WOLFSSL_EC_GROUP *curve,
|
||||||
WOLFSSL_API int wolfSSL_EC_KEY_LoadDer(WOLFSSL_EC_KEY* key, const unsigned char* der, int derSz);
|
const WOLFSSL_EC_POINT *p,
|
||||||
|
unsigned char *out, unsigned int *len);
|
||||||
WOLFSSL_API void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key);
|
WOLFSSL_API
|
||||||
WOLFSSL_API WOLFSSL_EC_POINT *wolfSSL_EC_KEY_get0_public_key(const WOLFSSL_EC_KEY *key);
|
int wolfSSL_ECPoint_d2i(unsigned char *in, unsigned int len,
|
||||||
WOLFSSL_API const WOLFSSL_EC_GROUP *wolfSSL_EC_KEY_get0_group(const WOLFSSL_EC_KEY *key);
|
const WOLFSSL_EC_GROUP *curve, WOLFSSL_EC_POINT *p);
|
||||||
WOLFSSL_API int wolfSSL_EC_KEY_set_private_key(WOLFSSL_EC_KEY *key, const WOLFSSL_BIGNUM *priv_key);
|
WOLFSSL_API
|
||||||
WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_EC_KEY_get0_private_key(const WOLFSSL_EC_KEY *key);
|
int wolfSSL_EC_KEY_LoadDer(WOLFSSL_EC_KEY* key,
|
||||||
WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new_by_curve_name(int nid);
|
const unsigned char* der, int derSz);
|
||||||
WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new(void);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group);
|
void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key);
|
||||||
WOLFSSL_API int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key);
|
WOLFSSL_API
|
||||||
WOLFSSL_API void wolfSSL_EC_KEY_set_asn1_flag(WOLFSSL_EC_KEY *key, int asn1_flag);
|
WOLFSSL_EC_POINT *wolfSSL_EC_KEY_get0_public_key(const WOLFSSL_EC_KEY *key);
|
||||||
WOLFSSL_API int wolfSSL_EC_KEY_set_public_key(WOLFSSL_EC_KEY *key, const WOLFSSL_EC_POINT *pub);
|
WOLFSSL_API
|
||||||
|
const WOLFSSL_EC_GROUP *wolfSSL_EC_KEY_get0_group(const WOLFSSL_EC_KEY *key);
|
||||||
|
WOLFSSL_API
|
||||||
WOLFSSL_API void wolfSSL_EC_GROUP_set_asn1_flag(WOLFSSL_EC_GROUP *group, int flag);
|
int wolfSSL_EC_KEY_set_private_key(WOLFSSL_EC_KEY *key,
|
||||||
WOLFSSL_API WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_new_by_curve_name(int nid);
|
const WOLFSSL_BIGNUM *priv_key);
|
||||||
WOLFSSL_API int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b, WOLFSSL_BN_CTX *ctx);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_EC_GROUP_get_curve_name(const WOLFSSL_EC_GROUP *group);
|
WOLFSSL_BIGNUM *wolfSSL_EC_KEY_get0_private_key(const WOLFSSL_EC_KEY *key);
|
||||||
WOLFSSL_API int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_EC_GROUP_get_order(const WOLFSSL_EC_GROUP *group, WOLFSSL_BIGNUM *order, WOLFSSL_BN_CTX *ctx);
|
WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new_by_curve_name(int nid);
|
||||||
WOLFSSL_API void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group);
|
WOLFSSL_API
|
||||||
|
WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new(void);
|
||||||
WOLFSSL_API void wolfssl_EC_POINT_dump(const char *msg, const WOLFSSL_EC_POINT *p);
|
WOLFSSL_API
|
||||||
WOLFSSL_API WOLFSSL_EC_POINT *wolfSSL_EC_POINT_new(const WOLFSSL_EC_GROUP *group);
|
int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group);
|
||||||
WOLFSSL_API int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group, const WOLFSSL_EC_POINT *p,
|
WOLFSSL_API
|
||||||
WOLFSSL_BIGNUM *x, WOLFSSL_BIGNUM *y, WOLFSSL_BN_CTX *ctx);
|
int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key);
|
||||||
WOLFSSL_API int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r, const WOLFSSL_BIGNUM *n,
|
WOLFSSL_API
|
||||||
const WOLFSSL_EC_POINT *q, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx);
|
void wolfSSL_EC_KEY_set_asn1_flag(WOLFSSL_EC_KEY *key, int asn1_flag);
|
||||||
WOLFSSL_API void wolfSSL_EC_POINT_clear_free(WOLFSSL_EC_POINT *point);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_EC_POINT_cmp(const WOLFSSL_EC_GROUP *group, const WOLFSSL_EC_POINT *a,
|
int wolfSSL_EC_KEY_set_public_key(WOLFSSL_EC_KEY *key,
|
||||||
const WOLFSSL_EC_POINT *b, WOLFSSL_BN_CTX *ctx);
|
const WOLFSSL_EC_POINT *pub);
|
||||||
WOLFSSL_API void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *point);
|
WOLFSSL_API
|
||||||
WOLFSSL_API int wolfSSL_EC_POINT_is_at_infinity(const WOLFSSL_EC_GROUP *group, const WOLFSSL_EC_POINT *a);
|
void wolfSSL_EC_GROUP_set_asn1_flag(WOLFSSL_EC_GROUP *group, int flag);
|
||||||
|
WOLFSSL_API
|
||||||
|
WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_new_by_curve_name(int nid);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b,
|
||||||
|
WOLFSSL_BN_CTX *ctx);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_GROUP_get_curve_name(const WOLFSSL_EC_GROUP *group);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_GROUP_get_order(const WOLFSSL_EC_GROUP *group,
|
||||||
|
WOLFSSL_BIGNUM *order, WOLFSSL_BN_CTX *ctx);
|
||||||
|
WOLFSSL_API
|
||||||
|
void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group);
|
||||||
|
WOLFSSL_API
|
||||||
|
void wolfssl_EC_POINT_dump(const char *msg, const WOLFSSL_EC_POINT *p);
|
||||||
|
WOLFSSL_API
|
||||||
|
WOLFSSL_EC_POINT *wolfSSL_EC_POINT_new(const WOLFSSL_EC_GROUP *group);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group,
|
||||||
|
const WOLFSSL_EC_POINT *p,
|
||||||
|
WOLFSSL_BIGNUM *x,
|
||||||
|
WOLFSSL_BIGNUM *y,
|
||||||
|
WOLFSSL_BN_CTX *ctx);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r,
|
||||||
|
const WOLFSSL_BIGNUM *n,
|
||||||
|
const WOLFSSL_EC_POINT *q, const WOLFSSL_BIGNUM *m,
|
||||||
|
WOLFSSL_BN_CTX *ctx);
|
||||||
|
WOLFSSL_API
|
||||||
|
void wolfSSL_EC_POINT_clear_free(WOLFSSL_EC_POINT *point);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_POINT_cmp(const WOLFSSL_EC_GROUP *group,
|
||||||
|
const WOLFSSL_EC_POINT *a, const WOLFSSL_EC_POINT *b,
|
||||||
|
WOLFSSL_BN_CTX *ctx);
|
||||||
|
WOLFSSL_API
|
||||||
|
void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *point);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wolfSSL_EC_POINT_is_at_infinity(const WOLFSSL_EC_GROUP *group,
|
||||||
|
const WOLFSSL_EC_POINT *a);
|
||||||
|
|
||||||
#define EC_KEY_free wolfSSL_EC_KEY_free
|
#define EC_KEY_free wolfSSL_EC_KEY_free
|
||||||
#define EC_KEY_get0_public_key wolfSSL_EC_KEY_get0_public_key
|
#define EC_KEY_get0_public_key wolfSSL_EC_KEY_get0_public_key
|
||||||
@ -109,7 +148,8 @@ WOLFSSL_API int wolfSSL_EC_POINT_is_at_infinity(const WOLFSSL_EC_GROUP *group, c
|
|||||||
#define EC_GROUP_free wolfSSL_EC_GROUP_free
|
#define EC_GROUP_free wolfSSL_EC_GROUP_free
|
||||||
|
|
||||||
#define EC_POINT_new wolfSSL_EC_POINT_new
|
#define EC_POINT_new wolfSSL_EC_POINT_new
|
||||||
#define EC_POINT_get_affine_coordinates_GFp wolfSSL_EC_POINT_get_affine_coordinates_GFp
|
#define EC_POINT_get_affine_coordinates_GFp \
|
||||||
|
wolfSSL_EC_POINT_get_affine_coordinates_GFp
|
||||||
#define EC_POINT_mul wolfSSL_EC_POINT_mul
|
#define EC_POINT_mul wolfSSL_EC_POINT_mul
|
||||||
#define EC_POINT_clear_free wolfSSL_EC_POINT_clear_free
|
#define EC_POINT_clear_free wolfSSL_EC_POINT_clear_free
|
||||||
#define EC_POINT_cmp wolfSSL_EC_POINT_cmp
|
#define EC_POINT_cmp wolfSSL_EC_POINT_cmp
|
||||||
|
@ -11,8 +11,13 @@ extern C {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_API int wolfSSL_ECDH_compute_key(void *out, size_t outlen, const WOLFSSL_EC_POINT *pub_key,
|
WOLFSSL_API int wolfSSL_ECDH_compute_key(void *out, size_t outlen,
|
||||||
WOLFSSL_EC_KEY *ecdh, void *(*KDF) (const void *in, size_t inlen, void *out, size_t *outlen));
|
const WOLFSSL_EC_POINT *pub_key,
|
||||||
|
WOLFSSL_EC_KEY *ecdh,
|
||||||
|
void *(*KDF) (const void *in,
|
||||||
|
size_t inlen,
|
||||||
|
void *out,
|
||||||
|
size_t *outlen));
|
||||||
|
|
||||||
#define ECDH_compute_key wolfSSL_ECDH_compute_key
|
#define ECDH_compute_key wolfSSL_ECDH_compute_key
|
||||||
|
|
||||||
|
@ -14,17 +14,17 @@ extern "C" {
|
|||||||
struct WOLFSSL_ECDSA_SIG {
|
struct WOLFSSL_ECDSA_SIG {
|
||||||
WOLFSSL_BIGNUM *r;
|
WOLFSSL_BIGNUM *r;
|
||||||
WOLFSSL_BIGNUM *s;
|
WOLFSSL_BIGNUM *s;
|
||||||
#if 0
|
|
||||||
void* internal; /* our EC DSA */
|
|
||||||
char inSet; /* internal set from external ? */
|
|
||||||
char exSet; /* external set from internal ? */
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WOLFSSL_API void wolfSSL_ECDSA_SIG_free(WOLFSSL_ECDSA_SIG *sig);
|
WOLFSSL_API void wolfSSL_ECDSA_SIG_free(WOLFSSL_ECDSA_SIG *sig);
|
||||||
WOLFSSL_API WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_SIG_new(void);
|
WOLFSSL_API WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_SIG_new(void);
|
||||||
WOLFSSL_API WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_do_sign(const unsigned char *dgst, int dgst_len, WOLFSSL_EC_KEY *eckey);
|
WOLFSSL_API WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_do_sign(const unsigned char *dgst,
|
||||||
WOLFSSL_API int wolfSSL_ECDSA_do_verify(const unsigned char *dgst, int dgst_len, const WOLFSSL_ECDSA_SIG *sig, WOLFSSL_EC_KEY *eckey);
|
int dgst_len,
|
||||||
|
WOLFSSL_EC_KEY *eckey);
|
||||||
|
WOLFSSL_API int wolfSSL_ECDSA_do_verify(const unsigned char *dgst,
|
||||||
|
int dgst_len,
|
||||||
|
const WOLFSSL_ECDSA_SIG *sig,
|
||||||
|
WOLFSSL_EC_KEY *eckey);
|
||||||
|
|
||||||
#define ECDSA_SIG_free wolfSSL_ECDSA_SIG_free
|
#define ECDSA_SIG_free wolfSSL_ECDSA_SIG_free
|
||||||
#define ECDSA_SIG_new wolfSSL_ECDSA_SIG_new
|
#define ECDSA_SIG_new wolfSSL_ECDSA_SIG_new
|
||||||
|
@ -150,8 +150,8 @@ WOLFSSL_API void wc_InitCert(Cert*);
|
|||||||
WOLFSSL_API int wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
WOLFSSL_API int wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
||||||
ecc_key*, RNG*);
|
ecc_key*, RNG*);
|
||||||
#ifdef WOLFSSL_CERT_REQ
|
#ifdef WOLFSSL_CERT_REQ
|
||||||
WOLFSSL_API int wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
WOLFSSL_API int wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz,
|
||||||
ecc_key*);
|
RsaKey*, ecc_key*);
|
||||||
#endif
|
#endif
|
||||||
WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte* derBuffer,
|
WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte* derBuffer,
|
||||||
word32 derSz, RsaKey*, ecc_key*, RNG*);
|
word32 derSz, RsaKey*, ecc_key*, RNG*);
|
||||||
@ -188,8 +188,8 @@ WOLFSSL_API int wc_SetDatesBuffer(Cert*, const byte*, int);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* DER encode signature */
|
/* DER encode signature */
|
||||||
WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest, word32 digSz,
|
WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest,
|
||||||
int hashOID);
|
word32 digSz, int hashOID);
|
||||||
WOLFSSL_API int wc_GetCTC_HashOID(int type);
|
WOLFSSL_API int wc_GetCTC_HashOID(int type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -54,19 +54,16 @@ typedef struct DsaKey {
|
|||||||
int type; /* public or private */
|
int type; /* public or private */
|
||||||
} DsaKey;
|
} DsaKey;
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_API void wc_InitDsaKey(DsaKey* key);
|
WOLFSSL_API void wc_InitDsaKey(DsaKey* key);
|
||||||
WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
|
WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
|
||||||
|
WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out,
|
||||||
WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
|
DsaKey* key, RNG* rng);
|
||||||
WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
|
WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig,
|
||||||
int* answer);
|
DsaKey* key, int* answer);
|
||||||
|
WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||||
WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
|
DsaKey*, word32);
|
||||||
word32);
|
WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
|
||||||
WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
|
DsaKey*, word32);
|
||||||
word32);
|
|
||||||
|
|
||||||
WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen);
|
WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -141,7 +141,8 @@ WOLFSSL_API
|
|||||||
int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
|
int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
|
||||||
word32* outlen);
|
word32* outlen);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point, byte* out, word32 *outlen);
|
int wc_ecc_shared_secret_ssh(ecc_key* private_key, ecc_point* point,
|
||||||
|
byte* out, word32 *outlen);
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||||
RNG* rng, ecc_key* key);
|
RNG* rng, ecc_key* key);
|
||||||
@ -195,8 +196,11 @@ WOLFSSL_API
|
|||||||
int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
|
int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
|
||||||
|
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
int wc_ecc_export_point_der(const int curve_idx, ecc_point* point, byte* out, word32* outLen);
|
int wc_ecc_export_point_der(const int curve_idx, ecc_point* point,
|
||||||
int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx, ecc_point* point);
|
byte* out, word32* outLen);
|
||||||
|
WOLFSSL_API
|
||||||
|
int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
|
||||||
|
ecc_point* point);
|
||||||
|
|
||||||
/* size helper */
|
/* size helper */
|
||||||
WOLFSSL_API
|
WOLFSSL_API
|
||||||
|
Reference in New Issue
Block a user