]> Git Repo - secp256k1.git/commitdiff
Simplify control flow in DER parsing
authorTim Ruffing <[email protected]>
Wed, 7 Nov 2018 15:13:27 +0000 (16:13 +0100)
committerTim Ruffing <[email protected]>
Thu, 23 May 2019 13:22:29 +0000 (15:22 +0200)
src/ecdsa_impl.h

index b37aff46c003856a1fc32fc27a19681468a9c1a2..eb099c87dc83fe0898814a8de5e4edaeeeb8f448 100644 (file)
@@ -128,8 +128,11 @@ static int secp256k1_der_parse_integer(secp256k1_scalar *r, const unsigned char
         /* Negative. */
         overflow = 1;
     }
-    while (rlen > 0 && **sig == 0) {
-        /* Skip leading zero bytes */
+    /* There is at most one leading zero byte:
+     * if there were two leading zero bytes, we would have failed and returned 0
+     * because of excessive 0x00 padding already. */
+    if (rlen > 0 && **sig == 0) {
+        /* Skip leading zero byte */
         rlen--;
         (*sig)++;
     }
This page took 0.02112 seconds and 4 git commands to generate.