From b375472d14cb9165e3acab899e4388a36c03bf25 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 21 Feb 2008 21:57:42 +0000 Subject: r14373@tombo: nickm | 2008-02-21 16:29:18 -0500 Apply warnings about implicit 64-to-32 conversions; some from Sebastian Hahn; some not. svn:r13664 --- src/common/crypto.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/common/crypto.c') diff --git a/src/common/crypto.c b/src/common/crypto.c index a00d07465d..34d19d94ba 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -133,7 +133,7 @@ static int _crypto_global_initialized = 0; static void crypto_log_errors(int severity, const char *doing) { - unsigned int err; + unsigned long err; const char *msg, *lib, *func; while ((err = ERR_get_error()) != 0) { msg = (const char*)ERR_reason_error_string(err); @@ -518,10 +518,11 @@ crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, tor_assert(env); tor_assert(src); + tor_assert(lenkey) RSA_free(env->key); @@ -640,8 +641,9 @@ crypto_pk_public_encrypt(crypto_pk_env_t *env, char *to, tor_assert(env); tor_assert(from); tor_assert(to); + tor_assert(fromlenkey, crypto_get_rsa_padding(padding)); if (r<0) { crypto_log_errors(LOG_WARN, "performing RSA encryption"); @@ -665,11 +667,13 @@ crypto_pk_private_decrypt(crypto_pk_env_t *env, char *to, tor_assert(from); tor_assert(to); tor_assert(env->key); + tor_assert(fromlenkey->p) /* Not a private key */ return -1; - r = RSA_private_decrypt(fromlen, (unsigned char*)from, (unsigned char*)to, + r = RSA_private_decrypt((int)fromlen, + (unsigned char*)from, (unsigned char*)to, env->key, crypto_get_rsa_padding(padding)); if (r<0) { @@ -693,7 +697,8 @@ crypto_pk_public_checksig(crypto_pk_env_t *env, char *to, tor_assert(env); tor_assert(from); tor_assert(to); - r = RSA_public_decrypt(fromlen, (unsigned char*)from, (unsigned char*)to, + tor_assert(fromlen < INT_MAX); + r = RSA_public_decrypt((int)fromlen, (unsigned char*)from, (unsigned char*)to, env->key, RSA_PKCS1_PADDING); if (r<0) { @@ -754,11 +759,13 @@ crypto_pk_private_sign(crypto_pk_env_t *env, char *to, tor_assert(env); tor_assert(from); tor_assert(to); + tor_assert(fromlen < INT_MAX); if (!env->key->p) /* Not a private key */ return -1; - r = RSA_private_encrypt(fromlen, (unsigned char*)from, (unsigned char*)to, + r = RSA_private_encrypt((int)fromlen, + (unsigned char*)from, (unsigned char*)to, env->key, RSA_PKCS1_PADDING); if (r<0) { crypto_log_errors(LOG_WARN, "generating RSA signature"); @@ -1672,8 +1679,8 @@ crypto_seed_rng(void) static const char *filenames[] = { "/dev/srandom", "/dev/urandom", "/dev/random", NULL }; - int fd; - int i, n; + int fd, i; + size_t n; #endif #if USE_RAND_POLL -- cgit v1.2.3-54-g00ecf