forked from wolfSSL/wolfssl
ssh non ecc
This commit is contained in:
@@ -202,6 +202,24 @@ int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
word32 inIdx = 0;
|
||||
word32 outIdx = 0;
|
||||
|
||||
if (inLen == 1 && *outLen && in) {
|
||||
byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
|
||||
|
||||
/* sanity check */
|
||||
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||
return ASN_INPUT_E;
|
||||
|
||||
b = hexDecode[b];
|
||||
|
||||
if (b == BAD)
|
||||
return ASN_INPUT_E;
|
||||
|
||||
out[outIdx++] = b;
|
||||
|
||||
*outLen = outIdx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (inLen % 2)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
|
||||
@@ -3664,6 +3664,34 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
}
|
||||
|
||||
|
||||
/* set a 32-bit const */
|
||||
int mp_set_int (mp_int * a, unsigned long b)
|
||||
{
|
||||
int x, res;
|
||||
|
||||
mp_zero (a);
|
||||
|
||||
/* set four bits at a time */
|
||||
for (x = 0; x < 8; x++) {
|
||||
/* shift the number up four bits */
|
||||
if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* OR in the top four bits of the source */
|
||||
a->dp[0] |= (b >> 28) & 15;
|
||||
|
||||
/* shift the source up to the next four bits */
|
||||
b <<= 4;
|
||||
|
||||
/* ensure that digits are not clamped off */
|
||||
a->used += 1;
|
||||
}
|
||||
mp_clamp (a);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
#if defined(CYASSL_KEY_GEN) || defined(HAVE_ECC)
|
||||
|
||||
/* c = a * a (mod b) */
|
||||
@@ -4329,32 +4357,6 @@ LBL_U:mp_clear (&v);
|
||||
}
|
||||
|
||||
|
||||
/* set a 32-bit const */
|
||||
int mp_set_int (mp_int * a, unsigned long b)
|
||||
{
|
||||
int x, res;
|
||||
|
||||
mp_zero (a);
|
||||
|
||||
/* set four bits at a time */
|
||||
for (x = 0; x < 8; x++) {
|
||||
/* shift the number up four bits */
|
||||
if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* OR in the top four bits of the source */
|
||||
a->dp[0] |= (b >> 28) & 15;
|
||||
|
||||
/* shift the source up to the next four bits */
|
||||
b <<= 4;
|
||||
|
||||
/* ensure that digits are not clamped off */
|
||||
a->used += 1;
|
||||
}
|
||||
mp_clamp (a);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
#endif /* CYASSL_KEY_GEN */
|
||||
|
||||
|
||||
@@ -1962,6 +1962,14 @@ int mp_count_bits (mp_int* a)
|
||||
}
|
||||
|
||||
|
||||
/* fast math wrappers */
|
||||
int mp_set_int(fp_int *a, fp_digit b)
|
||||
{
|
||||
fp_set(a, b);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
#if defined(CYASSL_KEY_GEN) || defined (HAVE_ECC)
|
||||
|
||||
/* c = a * a (mod b) */
|
||||
@@ -1996,14 +2004,6 @@ void fp_lcm(fp_int *a, fp_int *b, fp_int *c);
|
||||
int fp_isprime(fp_int *a);
|
||||
int fp_cnt_lsb(fp_int *a);
|
||||
|
||||
/* fast math wrappers */
|
||||
int mp_set_int(fp_int *a, fp_digit b)
|
||||
{
|
||||
fp_set(a, b);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
|
||||
int mp_gcd(fp_int *a, fp_int *b, fp_int *c)
|
||||
{
|
||||
fp_gcd(a, b, c);
|
||||
|
||||
Reference in New Issue
Block a user