[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] change crypto_digest_new_env to crypto_new_digest_env



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	crypto.c crypto.h 
Log Message:
change crypto_digest_new_env to crypto_new_digest_env
(and same with _free_)
to match our conventions
i think our conventions may be getting too ad hoc


Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- crypto.c	16 Dec 2003 05:47:21 -0000	1.48
+++ crypto.c	16 Dec 2003 08:13:26 -0000	1.49
@@ -66,8 +66,8 @@
 static INLINE int
 crypto_cipher_iv_length(int type) {
   /*
-  printf("%d -> %d IV\n",type, EVP_CIPHER_iv_length(
-						  crypto_cipher_evp_cipher(type,0)));
+  printf("%d -> %d IV\n",type,
+         EVP_CIPHER_iv_length(crypto_cipher_evp_cipher(type,0)));
   */
   switch(type)
     {
@@ -83,8 +83,8 @@
 static INLINE int
 crypto_cipher_key_length(int type) {
   /*
-  printf("%d -> %d\n",type, EVP_CIPHER_key_length(
-						  crypto_cipher_evp_cipher(type,0)));
+  printf("%d -> %d\n",type,
+         EVP_CIPHER_key_length(crypto_cipher_evp_cipher(type,0)));
   */
   switch(type)
     {
@@ -618,7 +618,7 @@
   switch(env->type) {
     case CRYPTO_PK_RSA:
       return RSA_public_decrypt(fromlen, from, to, (RSA *)env->key,
-			      RSA_PKCS1_PADDING);
+                                RSA_PKCS1_PADDING);
     default:
       return -1;
   }
@@ -633,7 +633,7 @@
       if (!(((RSA*)env->key)->p))
         return -1;
       return RSA_private_encrypt(fromlen, from, to, (RSA *)env->key,
-			       RSA_PKCS1_PADDING);
+                                 RSA_PKCS1_PADDING);
     default:
       return -1;
   }
@@ -830,7 +830,7 @@
 };
 
 crypto_digest_env_t *
-crypto_digest_new_env(int type)
+crypto_new_digest_env(int type)
 {
   crypto_digest_env_t *r;
   assert(type == CRYPTO_SHA1_DIGEST);
@@ -840,7 +840,7 @@
 }
 
 void
-crypto_digest_free(crypto_digest_env_t *digest) {
+crypto_free_digest_env(crypto_digest_env_t *digest) {
   assert(digest);
   tor_free(digest);
 }
@@ -902,14 +902,14 @@
       2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 }
   */
   r = BN_hex2bn(&p,
-		"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
-		"29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
-		"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
-		"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
-		"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
-		"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
-		"83655D23DCA3AD961C62F356208552BB9ED529077096966D"
-		"670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF");
+                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
+                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
+                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
+                "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
+                "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
+                "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
+                "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
+                "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF");
 #endif
 
   /* This is from rfc2409, section 6.2.  It's a safe prime, and
@@ -918,11 +918,11 @@
   */
   /* See also rfc 3536 */
   r = BN_hex2bn(&p,
-		"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08"
-		"8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B"
-		"302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9"
-		"A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE6"
-		"49286651ECE65381FFFFFFFFFFFFFFFF");
+                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08"
+                "8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B"
+                "302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9"
+                "A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE6"
+                "49286651ECE65381FFFFFFFFFFFFFFFF");
   assert(r);
 
   r = BN_set_word(g, 2);
@@ -982,8 +982,8 @@
 #undef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
 int crypto_dh_compute_secret(crypto_dh_env_t *dh,
-			     char *pubkey, int pubkey_len,
-			     char *secret_out, int secret_bytes_out)
+                             char *pubkey, int pubkey_len,
+                             char *secret_out, int secret_bytes_out)
 {
   unsigned char hash[20];
   unsigned char *secret_tmp = NULL;
@@ -997,6 +997,7 @@
     goto error;
   secret_tmp = tor_malloc(crypto_dh_get_bytes(dh)+1);
   secret_len = DH_compute_key(secret_tmp, pubkey_bn, dh->dh);
+  assert(secret_len == crypto_dh_get_bytes(dh));
   for (i = 0; i < secret_bytes_out; i += 20) {
     secret_tmp[secret_len] = (unsigned char) i/20;
     if (crypto_SHA_digest(secret_tmp, secret_len+1, hash))

Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- crypto.h	16 Dec 2003 05:47:21 -0000	1.25
+++ crypto.h	16 Dec 2003 08:13:26 -0000	1.26
@@ -99,8 +99,8 @@
 
 /* SHA-1 */
 int crypto_SHA_digest(const unsigned char *m, int len, unsigned char *digest);
-crypto_digest_env_t *crypto_new_digest_env(int type);
-void crypto_digest_free(crypto_digest_env_t *digest);
+crypto_digest_env_t *crypto_digest_new_env(int type);
+void crypto_free_digest_env(crypto_digest_env_t *digest);
 void crypto_digest_add_bytes(crypto_digest_env_t *digest, const char *data,
                              size_t len);
 void crypto_digest_get_digest(crypto_digest_env_t *digest,