Fix bn_cmp_part_words() and move it to bn_lib.c.
[openssl.git] / crypto / bn / bn_lib.c
index a63c031216947fc94ee8caff98a06204878fd1ce..87972ce7b08fcfe7c66c1e2cb408f00e971a46b8 100644 (file)
@@ -777,3 +777,28 @@ int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
                }
        return(0);
        }
+
+int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
+       int cl, int dl)
+       {
+       int n,i;
+       n = cl-1;
+
+       if (dl < 0)
+               {
+               for (i=-dl; i>0; i++)
+                       {
+                       if (b[n+i] != 0)
+                               return -1; /* a < b */
+                       }
+               }
+       if (dl > 0)
+               {
+               for (i=dl; i>0; i--)
+                       {
+                       if (a[n+i] != 0)
+                               return 1; /* a > b */
+                       }
+               }
+       return bn_cmp_words(a,b,cl);
+       }