diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-03-08 14:51:57 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-27 22:37:55 -0400 |
commit | 00b4784575c88d5de15886b440096c1e2b9fb080 (patch) | |
tree | 3eabb1c323705719ad469767d79dd064d3fb4ddc /src/common/crypto.c | |
parent | fc35674567b005f1d096488fc92d81f662aaebe5 (diff) | |
download | tor-00b4784575c88d5de15886b440096c1e2b9fb080.tar.gz tor-00b4784575c88d5de15886b440096c1e2b9fb080.zip |
Remove support for PK_NO_PADDING in crypto_pk_public_hybrid_encrypt
We never use it, and it would be a stupid thing if we started using it.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 41f81ebd77..02f3d2fbba 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1001,8 +1001,7 @@ crypto_pk_private_sign_digest(crypto_pk_t *env, char *to, size_t tolen, * bytes of data from <b>from</b>, with padding type 'padding', * storing the results on <b>to</b>. * - * If no padding is used, the public key must be at least as large as - * <b>from</b>. + * (Padding is required; the PK_NO_PADDING value is not supported.) * * Returns the number of bytes written on success, -1 on failure. * @@ -1030,13 +1029,11 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_t *env, tor_assert(from); tor_assert(to); tor_assert(fromlen < SIZE_T_CEILING); + tor_assert(padding != PK_NO_PADDING); overhead = crypto_get_rsa_padding_overhead(crypto_get_rsa_padding(padding)); pkeylen = crypto_pk_keysize(env); - if (padding == PK_NO_PADDING && fromlen < pkeylen) - return -1; - if (!force && fromlen+overhead <= pkeylen) { /* It all fits in a single encrypt. */ return crypto_pk_public_encrypt(env,to, @@ -1050,14 +1047,6 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_t *env, if (!cipher) return -1; if (crypto_cipher_generate_key(cipher)<0) goto err; - /* You can't just run around RSA-encrypting any bitstream: if it's - * greater than the RSA key, then OpenSSL will happily encrypt, and - * later decrypt to the wrong value. So we set the first bit of - * 'cipher->key' to 0 if we aren't padding. This means that our - * symmetric key is really only 127 bits. - */ - if (padding == PK_NO_PADDING) - cipher->key[0] &= 0x7f; if (crypto_cipher_encrypt_init_cipher(cipher)<0) goto err; buf = tor_malloc(pkeylen+1); |