]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Remove NEED_SKEY_1024 parsing.
authorNick Mathewson <nickm@torproject.org>
Fri, 23 Apr 2021 19:55:51 +0000 (15:55 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 23 Apr 2021 19:55:51 +0000 (15:55 -0400)
Only v2 onion services needed this, and they are now gone.

Closes #40374.

changes/ticket40374 [new file with mode: 0644]
src/feature/dirparse/parsecommon.c
src/feature/dirparse/parsecommon.h
src/test/test_parsecommon.c

diff --git a/changes/ticket40374 b/changes/ticket40374
new file mode 100644 (file)
index 0000000..8b6e99b
--- /dev/null
@@ -0,0 +1,4 @@
+  o Removed features:
+    - Remove unneeded code for parsing private keys in directory documents.
+      This code was only used for client authentication in v2 onion
+      services, which are now unsupported.  Closes ticket 40374.
index 2519071c8c5db9a10ad2b496f19dd71459aaacac..d7a6d65346391e5c1edd1733f1b50bf9d0cc58ea 100644 (file)
@@ -216,7 +216,6 @@ token_check_object(memarea_t *area, const char *kwd,
       }
       break;
     case NEED_KEY_1024: /* There must be a 1024-bit public key. */
-    case NEED_SKEY_1024: /* There must be a 1024-bit private key. */
       if (tok->key && crypto_pk_num_bits(tok->key) != PK_BYTES*8) {
         tor_snprintf(ebuf, sizeof(ebuf), "Wrong size on key for %s: %d bits",
                      kwd, crypto_pk_num_bits(tok->key));
@@ -228,18 +227,11 @@ token_check_object(memarea_t *area, const char *kwd,
         tor_snprintf(ebuf, sizeof(ebuf), "Missing public key for %s", kwd);
         RET_ERR(ebuf);
       }
-      if (o_syn != NEED_SKEY_1024) {
-        if (crypto_pk_key_is_private(tok->key)) {
-          tor_snprintf(ebuf, sizeof(ebuf),
-               "Private key given for %s, which wants a public key", kwd);
-          RET_ERR(ebuf);
-        }
-      } else { /* o_syn == NEED_SKEY_1024 */
-        if (!crypto_pk_key_is_private(tok->key)) {
-          tor_snprintf(ebuf, sizeof(ebuf),
-               "Public key given for %s, which wants a private key", kwd);
-          RET_ERR(ebuf);
-        }
+
+      if (crypto_pk_key_is_private(tok->key)) {
+        tor_snprintf(ebuf, sizeof(ebuf),
+                "Private key given for %s, which wants a public key", kwd);
+        RET_ERR(ebuf);
       }
       break;
     case OBJ_OK:
@@ -409,15 +401,6 @@ get_next_token(memarea_t *area,
     tok->key = crypto_pk_asn1_decode(tok->object_body, tok->object_size);
     if (! tok->key)
       RET_ERR("Couldn't parse public key.");
-  } else if (!strcmp(tok->object_type, "RSA PRIVATE KEY")) { /* private key */
-    if (o_syn != NEED_SKEY_1024 && o_syn != OBJ_OK) {
-      RET_ERR("Unexpected private key.");
-    }
-    tok->key = crypto_pk_asn1_decode_private(tok->object_body,
-                                             tok->object_size,
-                                             1024);
-    if (! tok->key)
-      RET_ERR("Couldn't parse private key.");
   }
   *s = eol;
 
index 5de2bbe1b36887e0677188651111a2aed39bc613..0f343e9c624f01bd9c1985c911d3d85e25a1ffe3 100644 (file)
@@ -218,7 +218,6 @@ typedef struct directory_token_t {
 typedef enum {
   NO_OBJ,        /**< No object, ever. */
   NEED_OBJ,      /**< Object is required. */
-  NEED_SKEY_1024,/**< Object is required, and must be a 1024 bit private key */
   NEED_KEY_1024, /**< Object is required, and must be a 1024 bit public key */
   NEED_KEY,      /**< Object is required, and must be a public key. */
   OBJ_OK,        /**< Object is optional. */
index d270a430d8b53975ac5a900d85a3c326c5065b64..b32840264e6b34d89709c3e1be6354a7fd4f209e 100644 (file)
@@ -326,18 +326,15 @@ test_parsecommon_get_next_token_parse_keys(void *arg)
   const char *end2 = str2 + strlen(str2);
   const char **s2 = (const char **)&str2;
 
-  token_rule_t rule2 = T01("client-key", C_CLIENT_KEY, NO_ARGS,
-                           NEED_SKEY_1024);
-
+  token_rule_t rule2 = T01("client-key", C_CLIENT_KEY, NO_ARGS, OBJ_OK);
   token2 = get_next_token(area, s2, end2, &rule2);
   tt_assert(token2);
-
   tt_int_op(token2->tp, OP_EQ, C_CLIENT_KEY);
   tt_int_op(token2->n_args, OP_EQ, 0);
   tt_str_op(token2->object_type, OP_EQ, "RSA PRIVATE KEY");
   tt_int_op(token2->object_size, OP_EQ, 608);
   tt_assert(token2->object_body);
-  tt_assert(token2->key);
+  tt_assert(token2->key == NULL);
   tt_assert(!token->error);
 
  done: