summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2016-07-16 15:19:53 +0200
committerYves-Alexis Perez <corsac@debian.org>2016-07-16 15:19:53 +0200
commitbf372706c469764d59e9f29c39e3ecbebd72b8d2 (patch)
tree0f0e296e2d50e4a7faf99ae6fa428d2681e81ea1 /src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
parent518dd33c94e041db0444c7d1f33da363bb8e3faf (diff)
downloadvyos-strongswan-bf372706c469764d59e9f29c39e3ecbebd72b8d2.tar.gz
vyos-strongswan-bf372706c469764d59e9f29c39e3ecbebd72b8d2.zip
Imported Upstream version 5.5.0
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
index db928569f..d66d5016e 100644
--- a/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
+++ b/src/libstrongswan/plugins/openssl/openssl_rsa_public_key.c
@@ -28,6 +28,10 @@
#include <openssl/rsa.h>
#include <openssl/x509.h>
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+OPENSSL_KEY_FALLBACK(RSA, key, n, e, d)
+#endif
+
typedef struct private_openssl_rsa_public_key_t private_openssl_rsa_public_key_t;
/**
@@ -224,11 +228,13 @@ bool openssl_rsa_fingerprint(RSA *rsa, cred_encoding_type_t type, chunk_t *fp)
break;
default:
{
+ const BIGNUM *bn_n, *bn_e;
chunk_t n = chunk_empty, e = chunk_empty;
bool success = FALSE;
- if (openssl_bn2chunk(rsa->n, &n) &&
- openssl_bn2chunk(rsa->e, &e))
+ RSA_get0_key(rsa, &bn_n, &bn_e, NULL);
+ if (openssl_bn2chunk(bn_n, &n) &&
+ openssl_bn2chunk(bn_e, &e))
{
success = lib->encoding->encode(lib->encoding, type, rsa, fp,
CRED_PART_RSA_MODULUS, n,
@@ -297,10 +303,12 @@ METHOD(public_key_t, get_encoding, bool,
}
default:
{
+ const BIGNUM *bn_n, *bn_e;
chunk_t n = chunk_empty, e = chunk_empty;
- if (openssl_bn2chunk(this->rsa->n, &n) &&
- openssl_bn2chunk(this->rsa->e, &e))
+ RSA_get0_key(this->rsa, &bn_n, &bn_e, NULL);
+ if (openssl_bn2chunk(bn_n, &n) &&
+ openssl_bn2chunk(bn_e, &e))
{
success = lib->encoding->encode(lib->encoding, type, NULL,
encoding, CRED_PART_RSA_MODULUS, n,
@@ -416,10 +424,15 @@ openssl_rsa_public_key_t *openssl_rsa_public_key_load(key_type_t type,
}
else if (n.ptr && e.ptr && type == KEY_RSA)
{
+ BIGNUM *bn_n, *bn_e;
+
this->rsa = RSA_new();
- this->rsa->n = BN_bin2bn((const u_char*)n.ptr, n.len, NULL);
- this->rsa->e = BN_bin2bn((const u_char*)e.ptr, e.len, NULL);
- return &this->public;
+ bn_n = BN_bin2bn((const u_char*)n.ptr, n.len, NULL);
+ bn_e = BN_bin2bn((const u_char*)e.ptr, e.len, NULL);
+ if (RSA_set0_key(this->rsa, bn_n, bn_e, NULL))
+ {
+ return &this->public;
+ }
}
destroy(this);
return NULL;