From: Andre Noll Date: Wed, 29 Aug 2018 09:56:20 +0000 (+0200) Subject: openssl: Move get_private_key() down. X-Git-Tag: v0.6.3~33^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=0b8b2469b5d2b81ff928bddd10d4ac3b819b75f8 openssl: Move get_private_key() down. Prep patch for supporting RFC4716 keys. The function now comes after read_bignum() and thus may call it. Pure code movement, no actual changes. --- diff --git a/openssl.c b/openssl.c index a27e0ca3..bda5791f 100644 --- a/openssl.c +++ b/openssl.c @@ -60,26 +60,6 @@ void crypt_shutdown(void) CRYPTO_cleanup_all_ex_data(); } -static int get_private_key(const char *path, RSA **rsa) -{ - EVP_PKEY *pkey; - BIO *bio = BIO_new(BIO_s_file()); - - *rsa = NULL; - if (!bio) - return -E_PRIVATE_KEY; - if (BIO_read_filename(bio, path) <= 0) - goto bio_free; - pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL); - if (!pkey) - goto bio_free; - *rsa = EVP_PKEY_get1_RSA(pkey); - EVP_PKEY_free(pkey); -bio_free: - BIO_free(bio); - return *rsa? RSA_size(*rsa) : -E_PRIVATE_KEY; -} - /* * The public key loading functions below were inspired by corresponding code * of openssh-5.2p1, Copyright (c) 1995 Tatu Ylonen , Espoo, @@ -144,6 +124,26 @@ free_rsa: return ret; } +static int get_private_key(const char *path, RSA **rsa) +{ + EVP_PKEY *pkey; + BIO *bio = BIO_new(BIO_s_file()); + + *rsa = NULL; + if (!bio) + return -E_PRIVATE_KEY; + if (BIO_read_filename(bio, path) <= 0) + goto bio_free; + pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL); + if (!pkey) + goto bio_free; + *rsa = EVP_PKEY_get1_RSA(pkey); + EVP_PKEY_free(pkey); +bio_free: + BIO_free(bio); + return *rsa? RSA_size(*rsa) : -E_PRIVATE_KEY; +} + int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) { unsigned char *blob;