summaryrefslogtreecommitdiff
path: root/src/pki/pki.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 08:09:54 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 08:09:54 +0000
commitb8064f4099997a9e2179f3ad4ace605f5ccac3a1 (patch)
tree81778e976b476374c48b4fe83d084b986b890421 /src/pki/pki.c
parent1ac70afcc1f7d6d2738a34308810719b0976d29f (diff)
downloadvyos-strongswan-b8064f4099997a9e2179f3ad4ace605f5ccac3a1.tar.gz
vyos-strongswan-b8064f4099997a9e2179f3ad4ace605f5ccac3a1.zip
[svn-upgrade] new version strongswan (4.4.1)
Diffstat (limited to 'src/pki/pki.c')
-rw-r--r--src/pki/pki.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/src/pki/pki.c b/src/pki/pki.c
index 0912d5051..d5dd03fa0 100644
--- a/src/pki/pki.c
+++ b/src/pki/pki.c
@@ -21,26 +21,59 @@
/**
* Convert a form string to a encoding type
*/
-bool get_form(char *form, key_encoding_type_t *type, bool pub)
+bool get_form(char *form, cred_encoding_type_t *enc, credential_type_t type)
{
if (streq(form, "der"))
{
- /* der encoded keys usually contain the complete SubjectPublicKeyInfo */
- *type = pub ? KEY_PUB_SPKI_ASN1_DER : KEY_PRIV_ASN1_DER;
+ switch (type)
+ {
+ case CRED_CERTIFICATE:
+ *enc = CERT_ASN1_DER;
+ return TRUE;
+ case CRED_PRIVATE_KEY:
+ *enc = PRIVKEY_ASN1_DER;
+ return TRUE;
+ case CRED_PUBLIC_KEY:
+ /* der encoded keys usually contain the complete
+ * SubjectPublicKeyInfo */
+ *enc = PUBKEY_SPKI_ASN1_DER;
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
else if (streq(form, "pem"))
{
- *type = pub ? KEY_PUB_PEM : KEY_PRIV_PEM;
+ switch (type)
+ {
+ case CRED_CERTIFICATE:
+ *enc = CERT_PEM;
+ return TRUE;
+ case CRED_PRIVATE_KEY:
+ *enc = PRIVKEY_PEM;
+ return TRUE;
+ case CRED_PUBLIC_KEY:
+ *enc = PUBKEY_PEM;
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
else if (streq(form, "pgp"))
{
- *type = pub ? KEY_PUB_PGP : KEY_PRIV_PGP;
+ switch (type)
+ {
+ case CRED_PRIVATE_KEY:
+ *enc = PRIVKEY_PGP;
+ return TRUE;
+ case CRED_PUBLIC_KEY:
+ *enc = PUBKEY_PGP;
+ return TRUE;
+ default:
+ return FALSE;
+ }
}
- else
- {
- return FALSE;
- }
- return TRUE;
+ return FALSE;
}
/**