Commit de19b264ca15b82bfde1d7c186cbb4fc9bbab20a

Francois Perrad 2018-12-28T09:01:01

introduce new private macros

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/tommath_private.h b/tommath_private.h
index 3546370..8feb1ad 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -51,6 +51,11 @@ extern void *XCALLOC(size_t n, size_t s);
 extern void XFREE(void *p);
 #endif
 
+/* ---> Basic Manipulations <--- */
+#define IS_ZERO(a) ((a)->used == 0)
+#define IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
+#define IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
+
 /* lowlevel functions, do not call! */
 int s_mp_add(const mp_int *a, const mp_int *b, mp_int *c);
 int s_mp_sub(const mp_int *a, const mp_int *b, mp_int *c);