Commit 356084ee3104b05d84f3e2a0bb69267e7b043aaf

Steffen Jaeckel 2017-08-29T23:53:02

improve mp_lshd This fixes #61

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/bn_mp_lshd.c b/bn_mp_lshd.c
index 888989a..b49b545 100644
--- a/bn_mp_lshd.c
+++ b/bn_mp_lshd.c
@@ -24,6 +24,10 @@ int mp_lshd(mp_int *a, int b)
    if (b <= 0) {
       return MP_OKAY;
    }
+   /* no need to shift 0 around */
+   if (mp_iszero(a) == MP_YES) {
+      return MP_OKAY;
+   }
 
    /* grow to fit the new digits */
    if (a->alloc < (a->used + b)) {