diff options
author | Martin Willi <martin@strongswan.org> | 2009-06-08 18:59:04 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-06-09 11:03:35 +0200 |
commit | 86ab0bb65e52e140341f25e23f4ef24dc6bde9ca (patch) | |
tree | 8ad4a205f2196c92cc2815075a6e0563ebd2e1d3 /src | |
parent | 3d2745110e1bd075491f2312bb4061db62ce5151 (diff) | |
download | strongswan-86ab0bb65e52e140341f25e23f4ef24dc6bde9ca.tar.bz2 strongswan-86ab0bb65e52e140341f25e23f4ef24dc6bde9ca.tar.xz |
fixed crash in openssl private_key->get_public_key(), using encode/load workaround
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_ec_public_key.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c index 4f826025c..780e67529 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c @@ -329,24 +329,6 @@ bool openssl_ec_public_key_build_id(EC_KEY *ec, identification_t **keyid, } /** - * Create a public key from BIGNUM values, used in openssl_ec_private_key.c - */ -openssl_ec_public_key_t *openssl_ec_public_key_create_from_private_key(EC_KEY *ec) -{ - private_openssl_ec_public_key_t *this = openssl_ec_public_key_create_empty(); - - this->ec = EC_KEY_new(); - EC_KEY_set_public_key(this->ec, EC_KEY_get0_public_key(ec)); - - if (!openssl_ec_public_key_build_id(this->ec, &this->keyid, &this->keyid_info)) - { - destroy(this); - return NULL; - } - return &this->public; -} - -/** * Load a public key from an ASN1 encoded blob */ static openssl_ec_public_key_t *load(chunk_t blob) @@ -372,6 +354,14 @@ static openssl_ec_public_key_t *load(chunk_t blob) return &this->public; } +/** + * Create a public key from BIGNUM values, used in openssl_ec_private_key.c + */ +openssl_ec_public_key_t *openssl_ec_public_key_create_from_private_key(EC_KEY *ec) +{ + return (openssl_ec_public_key_t*)load(get_encoding_full(ec)); +} + typedef struct private_builder_t private_builder_t; /** * Builder implementation for key loading |