Mercurial > dropbear
comparison bn_mp_neg.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35
Initial import of libtommath 0.35
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 May 2005 08:59:30 +0000 |
parents | d29b64170cf0 |
children |
comparison
equal
deleted
inserted
replaced
142:d29b64170cf0 | 190:d8254fc979e9 |
---|---|
17 | 17 |
18 /* b = -a */ | 18 /* b = -a */ |
19 int mp_neg (mp_int * a, mp_int * b) | 19 int mp_neg (mp_int * a, mp_int * b) |
20 { | 20 { |
21 int res; | 21 int res; |
22 if ((res = mp_copy (a, b)) != MP_OKAY) { | 22 if (a != b) { |
23 return res; | 23 if ((res = mp_copy (a, b)) != MP_OKAY) { |
24 return res; | |
25 } | |
24 } | 26 } |
27 | |
25 if (mp_iszero(b) != MP_YES) { | 28 if (mp_iszero(b) != MP_YES) { |
26 b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; | 29 b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; |
30 } else { | |
31 b->sign = MP_ZPOS; | |
27 } | 32 } |
33 | |
28 return MP_OKAY; | 34 return MP_OKAY; |
29 } | 35 } |
30 #endif | 36 #endif |