diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:06:17 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:06:17 -0500 |
commit | 08ce39fb0fd50ab0da4201201fa07e7776cb09e7 (patch) | |
tree | 8f77e38d4999a18f9d25532bd5f06867eb0dab63 /src | |
parent | a6a0c7a4ecc22a744b123a47d466963f6023a11f (diff) | |
parent | 1880a6a88e240556a8e6b169f1160aa8220ab0ec (diff) | |
download | tor-08ce39fb0fd50ab0da4201201fa07e7776cb09e7.tar.gz tor-08ce39fb0fd50ab0da4201201fa07e7776cb09e7.zip |
Merge branch 'trove-2017-011_025' into maint-0.2.5
Diffstat (limited to 'src')
-rw-r--r-- | src/common/crypto.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index f7362765d2..8d816652d3 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -592,11 +592,21 @@ crypto_pk_generate_key_with_bits(crypto_pk_t *env, int bits) return 0; } +/** A PEM callback that always reports a failure to get a password */ +static int +pem_no_password_cb(char *buf, int size, int rwflag, void *u) +{ + (void)buf; + (void)size; + (void)rwflag; + (void)u; + return 0; +} + /** Read a PEM-encoded private key from the <b>len</b>-byte string <b>s</b> * into <b>env</b>. Return 0 on success, -1 on failure. If len is -1, * the string is nul-terminated. */ -/* Used here, and used for testing. */ int crypto_pk_read_private_key_from_string(crypto_pk_t *env, const char *s, ssize_t len) @@ -615,7 +625,7 @@ crypto_pk_read_private_key_from_string(crypto_pk_t *env, if (env->key) RSA_free(env->key); - env->key = PEM_read_bio_RSAPrivateKey(b,NULL,NULL,NULL); + env->key = PEM_read_bio_RSAPrivateKey(b,NULL,pem_no_password_cb,NULL); BIO_free(b); @@ -747,7 +757,7 @@ crypto_pk_read_public_key_from_string(crypto_pk_t *env, const char *src, if (env->key) RSA_free(env->key); - env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL); + env->key = PEM_read_bio_RSAPublicKey(b, NULL, pem_no_password_cb, NULL); BIO_free(b); if (!env->key) { crypto_log_errors(LOG_WARN, "reading public key from string"); |