[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/release-0.4.2] Merge branch 'trove_2020_002_035' into trove_2020_002_041
commit 1a375c3b193f73e73e7c9c640dccdf1eb027234b
Merge: 7afb95d3e d0bce65ce
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Feb 5 12:06:24 2020 -0500
Merge branch 'trove_2020_002_035' into trove_2020_002_041
Resolved Conflicts:
src/feature/dirparse/parsecommon.c
changes/ticket33119 | 8 ++++++++
src/feature/dirparse/parsecommon.c | 9 ++++++++-
src/lib/crypt_ops/crypto_rsa.c | 27 +++++++++++++++++++++------
src/lib/crypt_ops/crypto_rsa.h | 5 ++++-
src/lib/crypt_ops/crypto_rsa_nss.c | 14 +++++++++++++-
src/lib/crypt_ops/crypto_rsa_openssl.c | 11 +++++++++--
6 files changed, 63 insertions(+), 11 deletions(-)
diff --cc src/feature/dirparse/parsecommon.c
index 036a51689,e8269f7ec..6c2c4b06b
--- a/src/feature/dirparse/parsecommon.c
+++ b/src/feature/dirparse/parsecommon.c
@@@ -392,25 -383,28 +392,32 @@@ get_next_token(memarea_t *area
if (next - *s > MAX_UNPARSED_OBJECT_SIZE)
RET_ERR("Couldn't parse object: missing footer or object much too big.");
+ {
+ int r;
+ size_t maxsize = base64_decode_maxsize(next-*s);
+ tok->object_body = ALLOC(maxsize);
+ r = base64_decode(tok->object_body, maxsize, *s, next-*s);
+ if (r<0)
+ RET_ERR("Malformed object: bad base64-encoded data");
+ tok->object_size = r;
+ }
+
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_new();
- if (crypto_pk_read_public_key_from_string(tok->key, obstart, eol-obstart))
+ 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_new();
- if (crypto_pk_read_private_key1024_from_string(tok->key,
- obstart, eol-obstart))
+ 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.");
- } else { /* If it's something else, try to base64-decode it */
- int r;
- tok->object_body = ALLOC(next-*s); /* really, this is too much RAM. */
- r = base64_decode(tok->object_body, next-*s, *s, next-*s);
- if (r<0)
- RET_ERR("Malformed object: bad base64-encoded data");
- tok->object_size = r;
}
*s = eol;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits