X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=openssl.c;h=4895e176ba9cf7f86962d365f3d9514aed0f0180;hp=99b3f7a6c3258bc5ef9981f062388a5a7d2854ba;hb=3699a583f3a7e9514c0f47b8b07f56b050430b67;hpb=5f20d9afde364f9ce51aa7841ebe513028a65e81 diff --git a/openssl.c b/openssl.c index 99b3f7a6..4895e176 100644 --- a/openssl.c +++ b/openssl.c @@ -55,6 +55,11 @@ void crypt_init(void) srandom(seed); } +void crypt_shutdown(void) +{ + CRYPTO_cleanup_all_ex_data(); +} + static int get_private_key(const char *path, RSA **rsa) { EVP_PKEY *pkey; @@ -119,11 +124,11 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result) return -E_BIGNUM; ret = read_bignum(p, end - p, &e); if (ret < 0) - goto fail; + goto free_rsa; p += ret; ret = read_bignum(p, end - p, &n); if (ret < 0) - goto fail; + goto free_e; #ifdef HAVE_RSA_SET0_KEY RSA_set0_key(rsa, n, e, NULL); #else @@ -132,12 +137,14 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result) #endif *result = rsa; return 1; -fail: +free_e: + BN_free(e); +free_rsa: RSA_free(rsa); return ret; } -int get_public_key(const char *key_file, struct asymmetric_key **result) +int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) { unsigned char *blob; size_t decoded_size; @@ -164,7 +171,7 @@ out: return ret; } -void free_public_key(struct asymmetric_key *key) +void apc_free_pubkey(struct asymmetric_key *key) { if (!key) return; @@ -172,7 +179,7 @@ void free_public_key(struct asymmetric_key *key) free(key); } -int priv_decrypt(const char *key_file, unsigned char *outbuf, +int apc_priv_decrypt(const char *key_file, unsigned char *outbuf, unsigned char *inbuf, int inlen) { struct asymmetric_key *priv; @@ -207,7 +214,7 @@ out: return ret; } -int pub_encrypt(struct asymmetric_key *pub, unsigned char *inbuf, +int apc_pub_encrypt(struct asymmetric_key *pub, unsigned char *inbuf, unsigned len, unsigned char *outbuf) { int ret, flen = len; /* RSA_public_encrypt expects a signed int */