diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-03-17 15:22:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-03-17 15:22:36 -0400 |
commit | 3d8c97a9883d295a898b6d32be0b5be3b569b704 (patch) | |
tree | 3429d41ac785c9a144d6f6b0e67ae2c05c73124a /src/feature/dirparse | |
parent | d4595b344a1a32547c8578e1d62cee0beb63dc78 (diff) | |
parent | e0d68ce84fe4536142d7f5e8987a08d9e93ac626 (diff) | |
download | tor-3d8c97a9883d295a898b6d32be0b5be3b569b704.tar.gz tor-3d8c97a9883d295a898b6d32be0b5be3b569b704.zip |
Merge branch 'maint-0.4.3'
Diffstat (limited to 'src/feature/dirparse')
-rw-r--r-- | src/feature/dirparse/parsecommon.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/feature/dirparse/parsecommon.c b/src/feature/dirparse/parsecommon.c index 75ef70d4ee..0c63cd4846 100644 --- a/src/feature/dirparse/parsecommon.c +++ b/src/feature/dirparse/parsecommon.c @@ -403,12 +403,19 @@ get_next_token(memarea_t *area, } if (!strcmp(tok->object_type, "RSA PUBLIC KEY")) { /* If it's a public key */ + if (o_syn != NEED_KEY && o_syn != NEED_KEY_1024 && o_syn != OBJ_OK) { + RET_ERR("Unexpected public key."); + } 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); + tok->object_size, + 1024); if (! tok->key) RET_ERR("Couldn't parse private key."); } |