forked from wolfSSL/wolfssl
Fix to improve fp_copy performance without ALT_ECC_SIZE defined. This change is required for async because we can’t memcpy/memset the entire fp_int.
This commit is contained in:
@@ -2348,7 +2348,11 @@ int mp_div_2d(fp_int* a, int b, fp_int* c, fp_int* d)
|
|||||||
|
|
||||||
void fp_copy(fp_int *a, fp_int *b)
|
void fp_copy(fp_int *a, fp_int *b)
|
||||||
{
|
{
|
||||||
if (a != b && b->size >= a->used) {
|
/* if source and destination are different */
|
||||||
|
if (a != b) {
|
||||||
|
#ifdef ALT_ECC_SIZE
|
||||||
|
/* verify a will fit in b */
|
||||||
|
if (b->size >= a->used) {
|
||||||
int x, oldused;
|
int x, oldused;
|
||||||
oldused = b->used;
|
oldused = b->used;
|
||||||
b->used = a->used;
|
b->used = a->used;
|
||||||
@@ -2361,6 +2365,16 @@ void fp_copy(fp_int *a, fp_int *b)
|
|||||||
b->dp[x] = 0;
|
b->dp[x] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* TODO: Handle error case */
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* all dp's are same size, so do straight copy */
|
||||||
|
b->used = a->used;
|
||||||
|
b->sign = a->sign;
|
||||||
|
XMEMCPY(b->dp, a->dp, FP_SIZE * sizeof(fp_digit));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fp_init_copy(fp_int *a, fp_int* b)
|
void fp_init_copy(fp_int *a, fp_int* b)
|
||||||
|
@@ -283,8 +283,8 @@
|
|||||||
|
|
||||||
/* a FP type */
|
/* a FP type */
|
||||||
typedef struct fp_int {
|
typedef struct fp_int {
|
||||||
int used,
|
int used;
|
||||||
sign;
|
int sign;
|
||||||
int size;
|
int size;
|
||||||
fp_digit dp[FP_SIZE];
|
fp_digit dp[FP_SIZE];
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
|
Reference in New Issue
Block a user