}
assert(b->top <= words);
- memcpy(a, b->d, sizeof(*a) * b->top);
+ if (b->top > 0)
+ memcpy(a, b->d, sizeof(*a) * b->top);
return a;
}
if (bn_wexpand(a, b->top) == NULL)
return NULL;
- memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
+ if (b->top > 0)
+ memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
+
+ if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0)
+ BN_set_flags(a, BN_FLG_CONSTTIME);
a->top = b->top;
a->neg = b->neg;