diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:07:59 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:07:59 -0500 |
commit | fd73a168ca5bf8ea6a0fa01878dd16d356d14cfa (patch) | |
tree | 1bb4b3739bd2db84ca5bc5752b7eb833c83964eb /src/common/crypto.c | |
parent | 25d50decb275854c312c8ee4ce5fd7e3f2945e5c (diff) | |
parent | ee48eb1eb5e643cd8af2a32df3cf8c48965f6ce4 (diff) | |
download | tor-fd73a168ca5bf8ea6a0fa01878dd16d356d14cfa.tar.gz tor-fd73a168ca5bf8ea6a0fa01878dd16d356d14cfa.zip |
Merge branch 'maint-0.3.1' into maint-0.3.2
Diffstat (limited to 'src/common/crypto.c')
-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 6fe3c661c8..80137b0d88 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -645,11 +645,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) @@ -668,7 +678,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); @@ -800,7 +810,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"); |