CryptoAuthLib v3.7.6
Microchip CryptoAuthentication Library
 
Loading...
Searching...
No Matches
atcacert_pem.h File Reference

Functions for converting between DER and PEM formats. More...

#include <stdint.h>

Macros

#define PEM_CERT_BEGIN   "-----BEGIN CERTIFICATE-----"
 
#define PEM_CERT_END   "-----END CERTIFICATE-----"
 
#define PEM_CSR_BEGIN   "-----BEGIN CERTIFICATE REQUEST-----"
 
#define PEM_CSR_END   "-----END CERTIFICATE REQUEST-----"
 

Functions

ATCA_STATUS atcacert_encode_pem (const uint8_t *der, size_t der_size, char *pem, size_t *pem_size, const char *header, const char *footer)
 Encode a DER data in PEM format.
 
ATCA_STATUS atcacert_decode_pem (const char *pem, size_t pem_size, uint8_t *der, size_t *der_size, const char *header, const char *footer)
 Decode PEM data into DER format.
 
ATCA_STATUS atcacert_encode_pem_cert (const uint8_t *der_cert, size_t der_cert_size, char *pem_cert, size_t *pem_cert_size)
 Encode a DER certificate in PEM format.
 
ATCA_STATUS atcacert_decode_pem_cert (const char *pem_cert, size_t pem_cert_size, uint8_t *der_cert, size_t *der_cert_size)
 Decode a PEM certificate into DER format.
 
ATCA_STATUS atcacert_encode_pem_csr (const uint8_t *der_csr, size_t der_csr_size, char *pem_csr, size_t *pem_csr_size)
 Encode a DER CSR in PEM format.
 
ATCA_STATUS atcacert_decode_pem_csr (const char *pem_csr, size_t pem_csr_size, uint8_t *der_csr, size_t *der_csr_size)
 Extract the CSR certificate bytes from a PEM encoded CSR certificate.
 

Detailed Description

Functions for converting between DER and PEM formats.

Function Documentation

◆ atcacert_decode_pem()

ATCA_STATUS atcacert_decode_pem ( const char *  pem,
size_t  pem_size,
uint8_t *  der,
size_t *  der_size,
const char *  header,
const char *  footer 
)

Decode PEM data into DER format.

Parameters
[in]pemPEM data to decode to DER.
[in]pem_sizePEM data size in bytes.
[out]derDER data is returned here.
[in,out]der_sizeAs input, the size of the der buffer. As output, the size of the DER data.
[in]headerHeader to find the beginning of the PEM data.
[in]footerFooter to find the end of the PEM data.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ atcacert_decode_pem_cert()

ATCA_STATUS atcacert_decode_pem_cert ( const char *  pem_cert,
size_t  pem_cert_size,
uint8_t *  der_cert,
size_t *  der_cert_size 
)

Decode a PEM certificate into DER format.

Parameters
[in]pem_certPEM certificate to decode to DER.
[in]pem_cert_sizePEM certificate size in bytes.
[out]der_certDER certificate is returned here.
[in,out]der_cert_sizeAs input, the size of the der_cert buffer. As output, the size of the DER certificate.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ atcacert_decode_pem_csr()

ATCA_STATUS atcacert_decode_pem_csr ( const char *  pem_csr,
size_t  pem_csr_size,
uint8_t *  der_csr,
size_t *  der_csr_size 
)

Extract the CSR certificate bytes from a PEM encoded CSR certificate.

Parameters
[in]pem_csrPEM CSR to decode to DER.
[in]pem_csr_sizePEM CSR size in bytes.
[out]der_csrDER CSR is returned here.
[in,out]der_csr_sizeAs input, the size of the der_csr buffer. As output, the size of the DER CSR.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ atcacert_encode_pem()

ATCA_STATUS atcacert_encode_pem ( const uint8_t *  der,
size_t  der_size,
char *  pem,
size_t *  pem_size,
const char *  header,
const char *  footer 
)

Encode a DER data in PEM format.

Parameters
[in]derDER data to be encoded as PEM.
[out]der_sizeDER data size in bytes.
[out]pemPEM encoded data is returned here.
[in,out]pem_sizeAs input, the size of the pem buffer. As output, the size of the PEM data.
[in]headerHeader to place at the beginning of the PEM data.
[in]footerFooter to place at the end of the PEM data.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ atcacert_encode_pem_cert()

ATCA_STATUS atcacert_encode_pem_cert ( const uint8_t *  der_cert,
size_t  der_cert_size,
char *  pem_cert,
size_t *  pem_cert_size 
)

Encode a DER certificate in PEM format.

Parameters
[in]der_certDER certificate to be encoded as PEM.
[out]der_cert_sizeDER certificate size in bytes.
[out]pem_certPEM encoded certificate is returned here.
[in,out]pem_cert_sizeAs input, the size of the pem_cert buffer. As output, the size of the PEM certificate.
Returns
ATCA_SUCCESS on success, otherwise an error code.

◆ atcacert_encode_pem_csr()

ATCA_STATUS atcacert_encode_pem_csr ( const uint8_t *  der_csr,
size_t  der_csr_size,
char *  pem_csr,
size_t *  pem_csr_size 
)

Encode a DER CSR in PEM format.

Parameters
[in]der_csrDER CSR to be encoded as PEM.
[out]der_csr_sizeDER CSR size in bytes.
[out]pem_csrPEM encoded CSR is returned here.
[in,out]pem_csr_sizeAs input, the size of the pem_csr buffer. As output, the size of the PEM CSR.
Returns
ATCA_SUCCESS on success, otherwise an error code.