]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
crypto_format: Stop adding padding in ed25519_signature_from_base64()
authorteor <teor@torproject.org>
Fri, 5 Apr 2019 05:10:00 +0000 (15:10 +1000)
committerteor <teor@torproject.org>
Fri, 5 Apr 2019 05:17:19 +0000 (15:17 +1000)
base64_decode() does not require padding.

Part of 29660.

src/lib/crypt_ops/crypto_format.c

index 269e6d9da93e82a57342b7eda18f6957c35bfd19..1827168c7547b7a99cb689548f4ca4e39da547f8 100644 (file)
@@ -246,14 +246,11 @@ int
 ed25519_signature_from_base64(ed25519_signature_t *sig,
                               const char *input)
 {
-
   if (strlen(input) != ED25519_SIG_BASE64_LEN)
     return -1;
-  char buf[ED25519_SIG_BASE64_LEN+3];
+  char buf[ED25519_SIG_BASE64_LEN+1];
   memcpy(buf, input, ED25519_SIG_BASE64_LEN);
-  buf[ED25519_SIG_BASE64_LEN+0] = '=';
-  buf[ED25519_SIG_BASE64_LEN+1] = '=';
-  buf[ED25519_SIG_BASE64_LEN+2] = 0;
+  buf[ED25519_SIG_BASE64_LEN] = 0;
   char decoded[128];
   int n = base64_decode(decoded, sizeof(decoded), buf, strlen(buf));
   if (n < 0 || n != ED25519_SIG_LEN)