Commit 49105f8d8d1119ea75fff20033e880f7efc8f960

Francois Perrad 2019-02-28T11:43:41

explicit logical XOR for coverity CID 332946, see #163

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/bn_mp_tc_xor.c b/bn_mp_tc_xor.c
index 79a02cb..9f3b6f1 100644
--- a/bn_mp_tc_xor.c
+++ b/bn_mp_tc_xor.c
@@ -64,7 +64,7 @@ int mp_tc_xor(const mp_int *a, const mp_int *b, mp_int *c)
 
    res = mp_xor(a, b, c);
 
-   if ((sa != sb) && (res == MP_OKAY)) {
+   if ((((sa == MP_NEG) && (sb != MP_NEG)) || ((sa != MP_NEG) && (sb == MP_NEG))) && (res == MP_OKAY)) {
       res = mp_sub(c, mx, c);
    }