mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Merge pull request #3884 from SparkiDev/tfm_read_bin
TFM read_unsigned_bin: endian may not be defined
This commit is contained in:
@ -3581,7 +3581,8 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
#error Both LITTLE_ENDIAN_ORDER and BIG_ENDIAN_ORDER defined.
|
#error Both LITTLE_ENDIAN_ORDER and BIG_ENDIAN_ORDER defined.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(LITTLE_ENDIAN_ORDER) || defined(BIG_ENDIAN_ORDER))
|
#if (defined(LITTLE_ENDIAN_ORDER) || defined(BIG_ENDIAN_ORDER)) && \
|
||||||
|
(defined(FP_32BIT) || defined(FP_64BIT))
|
||||||
#ifdef FP_32BIT
|
#ifdef FP_32BIT
|
||||||
/* 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 */
|
||||||
@ -3589,7 +3590,6 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
unsigned char *pd = (unsigned char *)a->dp;
|
unsigned char *pd = (unsigned char *)a->dp;
|
||||||
|
|
||||||
a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
|
a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
|
||||||
/* read the bytes in */
|
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
{
|
{
|
||||||
/* Use Duff's device to unroll the loop. */
|
/* Use Duff's device to unroll the loop. */
|
||||||
@ -3604,6 +3604,7 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
/* read the bytes in one at a time. */
|
||||||
for (c -= 1; c >= 0; c -= 1) {
|
for (c -= 1; c >= 0; c -= 1) {
|
||||||
pd[c] = *b++;
|
pd[c] = *b++;
|
||||||
}
|
}
|
||||||
@ -3616,7 +3617,6 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
unsigned char *pd = (unsigned char *)a->dp;
|
unsigned char *pd = (unsigned char *)a->dp;
|
||||||
|
|
||||||
a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
|
a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit);
|
||||||
/* read the bytes in */
|
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
{
|
{
|
||||||
/* Use Duff's device to unroll the loop. */
|
/* Use Duff's device to unroll the loop. */
|
||||||
@ -3635,6 +3635,7 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
/* read the bytes in one at a time. */
|
||||||
for (c -= 1; c >= 0; c -= 1) {
|
for (c -= 1; c >= 0; c -= 1) {
|
||||||
pd[c] = *b++;
|
pd[c] = *b++;
|
||||||
}
|
}
|
||||||
@ -3642,7 +3643,7 @@ int fp_read_unsigned_bin(fp_int *a, const unsigned char *b, int c)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
/* read the bytes in */
|
/* read the bytes in one at a time - unknown number of bits in digit */
|
||||||
for (; c > 0; c--) {
|
for (; c > 0; c--) {
|
||||||
int err = fp_mul_2d (a, 8, a);
|
int err = fp_mul_2d (a, 8, a);
|
||||||
if (err != FP_OKAY) {
|
if (err != FP_OKAY) {
|
||||||
|
Reference in New Issue
Block a user