aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-08-25 07:06:12 +0000
committerRoger Dingledine <arma@torproject.org>2003-08-25 07:06:12 +0000
commit58c5d5e918611b7d4d594fcc2ea20b87ad0d6a06 (patch)
tree41ce50db0312085b7fb6965fc8cc7e59171958f2
parent215ca90c058145f68e7c3ab6e072556a58140194 (diff)
downloadtor-58c5d5e918611b7d4d594fcc2ea20b87ad0d6a06.tar
tor-58c5d5e918611b7d4d594fcc2ea20b87ad0d6a06.tar.gz
fix formatting in crypto.c for my sanity
svn:r411
-rw-r--r--src/common/crypto.c94
1 files changed, 46 insertions, 48 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 4e9a98189..da78d06ce 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -115,16 +115,15 @@ crypto_pk_env_t *crypto_new_pk_env(int type)
switch(type) {
case CRYPTO_PK_RSA:
- env->key = (unsigned char *)RSA_new();
- if (!env->key) {
- free((void *)env);
- return NULL;
- }
- break;
+ env->key = (unsigned char *)RSA_new();
+ if (!env->key) {
+ free(env);
+ return NULL;
+ }
+ break;
default:
- free((void *)env);
- return NULL;
- break;
+ free(env);
+ return NULL;
}
return env;
@@ -139,15 +138,14 @@ void crypto_free_pk_env(crypto_pk_env_t *env)
switch(env->type) {
case CRYPTO_PK_RSA:
- if (env->key)
- RSA_free((RSA *)env->key);
- break;
+ if (env->key)
+ RSA_free((RSA *)env->key);
+ break;
default:
- break;
+ break;
}
- free((void *)env);
- return;
+ free(env);
}
@@ -429,13 +427,13 @@ int crypto_pk_write_private_key_to_file(crypto_pk_env_t *env, FILE *dest)
switch(env->type) {
case CRYPTO_PK_RSA:
- if (!env->key)
- return -1;
- if (PEM_write_RSAPrivateKey(dest, (RSA *)env->key, NULL, NULL, 0,0, NULL) == 0)
- return -1;
- break;
+ if (!env->key)
+ return -1;
+ if (PEM_write_RSAPrivateKey(dest, (RSA *)env->key, NULL, NULL, 0,0, NULL) == 0)
+ return -1;
+ break;
default :
- return -1;
+ return -1;
}
return 0;
@@ -446,13 +444,13 @@ int crypto_pk_write_public_key_to_file(crypto_pk_env_t *env, FILE *dest)
switch(env->type) {
case CRYPTO_PK_RSA:
- if (!env->key)
- return -1;
- if (PEM_write_RSAPublicKey(dest, (RSA *)env->key) == 0)
- return -1;
- break;
+ if (!env->key)
+ return -1;
+ if (PEM_write_RSAPublicKey(dest, (RSA *)env->key) == 0)
+ return -1;
+ break;
default :
- return -1;
+ return -1;
}
return 0;
@@ -484,13 +482,13 @@ int crypto_pk_cmp_keys(crypto_pk_env_t *a, crypto_pk_env_t *b) {
switch(a->type) {
case CRYPTO_PK_RSA:
- assert(((RSA *)a->key)->n && ((RSA *)a->key)->e && ((RSA *)b->key)->n && ((RSA *)b->key)->e);
- result = BN_cmp(((RSA *)a->key)->n, ((RSA *)b->key)->n);
- if (result)
- return result;
- return BN_cmp(((RSA *)a->key)->e, ((RSA *)b->key)->e);
+ assert(((RSA *)a->key)->n && ((RSA *)a->key)->e && ((RSA *)b->key)->n && ((RSA *)b->key)->e);
+ result = BN_cmp(((RSA *)a->key)->n, ((RSA *)b->key)->n);
+ if (result)
+ return result;
+ return BN_cmp(((RSA *)a->key)->e, ((RSA *)b->key)->e);
default:
- return -1;
+ return -1;
}
}
@@ -521,9 +519,9 @@ int crypto_pk_public_encrypt(crypto_pk_env_t *env, unsigned char *from, int from
switch(env->type) {
case CRYPTO_PK_RSA:
- return RSA_public_encrypt(fromlen, from, to, (RSA *)env->key, padding);
+ return RSA_public_encrypt(fromlen, from, to, (RSA *)env->key, padding);
default:
- return -1;
+ return -1;
}
}
@@ -532,12 +530,12 @@ int crypto_pk_private_decrypt(crypto_pk_env_t *env, unsigned char *from, int fro
assert(env && from && to);
switch(env->type) {
- case CRYPTO_PK_RSA:
- if (!(((RSA*)env->key)->p))
- return -1;
- return RSA_private_decrypt(fromlen, from, to, (RSA *)env->key, padding);
+ case CRYPTO_PK_RSA:
+ if (!(((RSA*)env->key)->p))
+ return -1;
+ return RSA_private_decrypt(fromlen, from, to, (RSA *)env->key, padding);
default:
- return -1;
+ return -1;
}
}
@@ -546,11 +544,11 @@ int crypto_pk_public_checksig(crypto_pk_env_t *env, unsigned char *from, int fro
assert(env && from && to);
switch(env->type) {
- case CRYPTO_PK_RSA:
- return RSA_public_decrypt(fromlen, from, to, (RSA *)env->key,
+ case CRYPTO_PK_RSA:
+ return RSA_public_decrypt(fromlen, from, to, (RSA *)env->key,
RSA_PKCS1_PADDING);
default:
- return -1;
+ return -1;
}
}
@@ -559,13 +557,13 @@ int crypto_pk_private_sign(crypto_pk_env_t *env, unsigned char *from, int fromle
assert(env && from && to);
switch(env->type) {
- case CRYPTO_PK_RSA:
- if (!(((RSA*)env->key)->p))
- return -1;
- return RSA_private_encrypt(fromlen, from, to, (RSA *)env->key,
+ case CRYPTO_PK_RSA:
+ if (!(((RSA*)env->key)->p))
+ return -1;
+ return RSA_private_encrypt(fromlen, from, to, (RSA *)env->key,
RSA_PKCS1_PADDING);
default:
- return -1;
+ return -1;
}
}