diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-08-16 13:12:47 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-09-13 15:23:49 +0200 |
commit | d6b3cc87ca22b4829098685517e5b03d114cad54 (patch) | |
tree | d4f09a9e9748cf44f0035d6e9ccac3511c3a3470 /src | |
parent | 90afd2c9290b3b0bd605444d58c271a15b6df2b3 (diff) | |
download | strongswan-d6b3cc87ca22b4829098685517e5b03d114cad54.tar.bz2 strongswan-d6b3cc87ca22b4829098685517e5b03d114cad54.tar.xz |
openssl: Add support for generic encoding of EC public keys
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_ec_public_key.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c index 38cc8bedf..382c55418 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_ec_public_key.c @@ -245,33 +245,23 @@ METHOD(public_key_t, get_encoding, bool, private_openssl_ec_public_key_t *this, cred_encoding_type_t type, chunk_t *encoding) { + bool success = TRUE; u_char *p; - switch (type) + *encoding = chunk_alloc(i2d_EC_PUBKEY(this->ec, NULL)); + p = encoding->ptr; + i2d_EC_PUBKEY(this->ec, &p); + + if (type != PUBKEY_SPKI_ASN1_DER) { - case PUBKEY_SPKI_ASN1_DER: - case PUBKEY_PEM: - { - bool success = TRUE; - - *encoding = chunk_alloc(i2d_EC_PUBKEY(this->ec, NULL)); - p = encoding->ptr; - i2d_EC_PUBKEY(this->ec, &p); - - if (type == PUBKEY_PEM) - { - chunk_t asn1_encoding = *encoding; - - success = lib->encoding->encode(lib->encoding, PUBKEY_PEM, - NULL, encoding, CRED_PART_ECDSA_PUB_ASN1_DER, - asn1_encoding, CRED_PART_END); - chunk_clear(&asn1_encoding); - } - return success; - } - default: - return FALSE; + chunk_t asn1_encoding = *encoding; + + success = lib->encoding->encode(lib->encoding, type, + NULL, encoding, CRED_PART_ECDSA_PUB_ASN1_DER, + asn1_encoding, CRED_PART_END); + chunk_clear(&asn1_encoding); } + return success; } METHOD(public_key_t, get_ref, public_key_t*, |