simplify mp_complement

This commit is contained in:
Daniel Mendler 2019-11-03 11:00:33 +01:00
parent bcda8fc696
commit 3b710fbd7e
No known key found for this signature in database
GPG Key ID: D88ADB2A2693CA43

View File

@ -6,7 +6,8 @@
/* b = ~a */ /* b = ~a */
mp_err mp_complement(const mp_int *a, mp_int *b) mp_err mp_complement(const mp_int *a, mp_int *b)
{ {
mp_err err = mp_neg(a, b); mp_int a_ = *a;
return (err == MP_OKAY) ? mp_sub_d(b, 1uL, b) : err; a_.sign = ((a_.sign == MP_ZPOS) && !mp_iszero(a)) ? MP_NEG : MP_ZPOS;
return mp_sub_d(&a_, 1uL, b);
} }
#endif #endif