aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-04-04 19:11:18 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-04-04 19:11:18 +0200
commitcea2857263a7fa62e3a3d8cbd791b3de1f4db2c6 (patch)
treee717e11e2e9083fc4a3879938828d1c96e79d6d2 /src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
parente3943f5559b50f9c4a0acc93bbbfd9dc33a27276 (diff)
downloadstrongswan-cea2857263a7fa62e3a3d8cbd791b3de1f4db2c6.tar.bz2
strongswan-cea2857263a7fa62e3a3d8cbd791b3de1f4db2c6.tar.xz
PEM encoding for GMP RSA public and private keys
Diffstat (limited to 'src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c')
-rw-r--r--src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
index d20767177..111533bec 100644
--- a/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
+++ b/src/libstrongswan/plugins/gmp/gmp_rsa_public_key.c
@@ -396,7 +396,13 @@ static bool get_encoding(private_gmp_rsa_public_key_t *this,
key_encoding_type_t type, chunk_t *encoding)
{
chunk_t n, e;
- bool success;
+ bool success, pem = FALSE;
+
+ if (type == KEY_PUB_PEM)
+ {
+ pem = TRUE;
+ type = KEY_PUB_SPKI_ASN1_DER;
+ }
n = gmp_mpz_to_chunk(this->n);
e = gmp_mpz_to_chunk(this->e);
@@ -406,6 +412,15 @@ static bool get_encoding(private_gmp_rsa_public_key_t *this,
chunk_free(&n);
chunk_free(&e);
+ if (pem && success)
+ {
+ chunk_t asn1_encoding = *encoding;
+
+ success = lib->encoding->encode(lib->encoding, KEY_PUB_PEM, NULL,
+ encoding, KEY_PART_RSA_PUB_ASN1_DER,
+ asn1_encoding, KEY_PART_END);
+ chunk_clear(&asn1_encoding);
+ }
return success;
}