[or-cvs] Add assert on crypto_pk_write_private_key,and macros to mak...

Nick Mathewson nickm at seul.org
Sun Apr 25 19:21:46 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv3666/src/common

Modified Files:
	crypto.c 
Log Message:
Add assert on crypto_pk_write_private_key,and macros to make sure we have real keys

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- crypto.c	25 Apr 2004 04:32:59 -0000	1.78
+++ crypto.c	25 Apr 2004 19:21:44 -0000	1.79
@@ -53,6 +53,9 @@
 #define RETURN_SSL_OUTCOME(exp) return !(exp)
 #endif
 
+#define PUBLIC_KEY_OK(k) ((k) && (k)->key && (k)->key->n)
+#define PRIVATE_KEY_OK(k) ((k) && (k)->key && (k)->key->p)
+
 struct crypto_pk_env_t
 {
   int refs; /* reference counting; so we don't have to copy keys */
@@ -373,6 +376,8 @@
   char *s;
   int r;
 
+  assert(PRIVATE_KEY_OK(env));
+
   if (!(bio = BIO_new(BIO_s_mem())))
     return -1;
   if (PEM_write_bio_RSAPrivateKey(bio, env->key, NULL,NULL,0,NULL,NULL)



More information about the tor-commits mailing list