summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-21 21:57:42 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-21 21:57:42 +0000
commitb375472d14cb9165e3acab899e4388a36c03bf25 (patch)
treeae14920d819371d594d45a7020ea44a593bd44d6 /src/common/crypto.c
parent1cd90948ab6b82f65600ed9bae45a201dfae4a3d (diff)
downloadtor-b375472d14cb9165e3acab899e4388a36c03bf25.tar.gz
tor-b375472d14cb9165e3acab899e4388a36c03bf25.zip
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
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c23
1 files changed, 15 insertions, 8 deletions
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(len<INT_MAX);
b = BIO_new(BIO_s_mem()); /* Create a memory BIO */
- BIO_write(b, src, len);
+ BIO_write(b, src, (int)len);
if (env->key)
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(fromlen<INT_MAX);
- r = RSA_public_encrypt(fromlen, (unsigned char*)from, (unsigned char*)to,
+ r = RSA_public_encrypt((int)fromlen, (unsigned char*)from, (unsigned char*)to,
env->key, 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(fromlen<INT_MAX);
if (!env->key->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