diff options
author | Tobias Brunner <tobias@strongswan.org> | 2014-03-14 17:33:22 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2014-03-22 09:55:03 +0100 |
commit | 01632eccf3a3343c14496d845c3c821ff10d8e54 (patch) | |
tree | f8a6aeff58a2c946c0df1a0b470c00c2eb0633e8 /src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c | |
parent | 22e1aa51f94e566dd54e0eae37cc3f045cf59854 (diff) | |
download | strongswan-01632eccf3a3343c14496d845c3c821ff10d8e54.tar.bz2 strongswan-01632eccf3a3343c14496d845c3c821ff10d8e54.tar.xz |
openssl: Add default fallback when calculating fingerprints of RSA keys
We still try to calculate these directly as it can avoid a dependency on
the pkcs1 or other plugins. But for e.g. PGPv3 keys we need to delegate the
actual fingerprint calculation to the pgp plugin.
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c index f0c172629..9748e28f2 100644 --- a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c @@ -222,7 +222,21 @@ bool openssl_rsa_fingerprint(RSA *rsa, cred_encoding_type_t type, chunk_t *fp) i2d_RSA_PUBKEY(rsa, &p); break; default: - return FALSE; + { + chunk_t n = chunk_empty, e = chunk_empty; + bool success = FALSE; + + if (openssl_bn2chunk(rsa->n, &n) && + openssl_bn2chunk(rsa->e, &e)) + { + success = lib->encoding->encode(lib->encoding, type, rsa, fp, + CRED_PART_RSA_MODULUS, n, + CRED_PART_RSA_PUB_EXP, e, CRED_PART_END); + } + chunk_free(&n); + chunk_free(&e); + return success; + } } hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1); if (!hasher || !hasher->allocate_hash(hasher, key, fp)) |