aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-06-02 12:32:59 -0400
committerNick Mathewson <nickm@torproject.org>2011-06-03 11:31:19 -0400
commitbbf2fee8ff7bbb8f645b7d973cd84bc97e93ae54 (patch)
treed9db511a467af11a94c9e4d375f14cc9383638bc /src/or/routerparse.c
parent1d8bcba067ef8d96ebe022f06459d55c308343ec (diff)
downloadtor-bbf2fee8ff7bbb8f645b7d973cd84bc97e93ae54.tar.gz
tor-bbf2fee8ff7bbb8f645b7d973cd84bc97e93ae54.zip
Reject 128-byte keys that are not 1024-bit
When we added the check for key size, we required that the keys be 128 bytes. But RSA_size (which defers to BN_num_bytes) will return 128 for keys of length 1017..1024. This patch adds a new crypto_pk_num_bits() that returns the actual number of significant bits in the modulus, and uses that to enforce key sizes. Also, credit the original bug3318 in the changes file.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 3728e9932b..f855f9d027 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -3765,9 +3765,9 @@ 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_keysize(tok->key) != PK_BYTES) {
+ 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, (int)crypto_pk_keysize(tok->key)*8);
+ kwd, crypto_pk_num_bits(tok->key));
RET_ERR(ebuf);
}
/* fall through */