added case to DerToPem() to add EC header and footer to the PEM output

This commit is contained in:
John Safranek 2013-04-11 14:03:18 -07:00
parent a2bd6e786d
commit a74ac2b22c
2 changed files with 12 additions and 2 deletions

View File

@ -2800,10 +2800,19 @@ int DerToPem(const byte* der, word32 derSz, byte* output, word32 outSz,
if (type == CERT_TYPE) {
XSTRNCPY(header, "-----BEGIN CERTIFICATE-----\n", sizeof(header));
XSTRNCPY(footer, "-----END CERTIFICATE-----\n", sizeof(footer));
} else {
}
else if (type == PRIVATEKEY_TYPE) {
XSTRNCPY(header, "-----BEGIN RSA PRIVATE KEY-----\n", sizeof(header));
XSTRNCPY(footer, "-----END RSA PRIVATE KEY-----\n", sizeof(footer));
}
#ifdef HAVE_ECC
else if (type == ECC_PRIVATEKEY_TYPE) {
XSTRNCPY(header, "-----BEGIN EC PRIVATE KEY-----\n", sizeof(header));
XSTRNCPY(footer, "-----END EC PRIVATE KEY-----\n", sizeof(footer));
}
#endif
else
return BAD_FUNC_ARG;
headerLen = (int)XSTRLEN(header);
footerLen = (int)XSTRLEN(footer);

View File

@ -40,7 +40,8 @@ enum CertType {
PRIVATEKEY_TYPE,
DH_PARAM_TYPE,
CRL_TYPE,
CA_TYPE
CA_TYPE,
ECC_PRIVATEKEY_TYPE
};