mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Add assert on crypto_pk_write_private_key,and macros to make sure we have real keys
svn:r1694
This commit is contained in:
parent
0fca143ea1
commit
70bbd0cafa
@ -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 @@ crypto_pk_write_private_key_to_filename(crypto_pk_env_t *env,
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user