Functions for converting between DER and PEM formats.
More...
#include <stdint.h>
|
#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-----" |
|
|
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.
|
|
Functions for converting between DER and PEM formats.
- Copyright
- (c) 2015-2020 Microchip Technology Inc. and its subsidiaries.
◆ 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] | pem | PEM data to decode to DER. |
[in] | pem_size | PEM data size in bytes. |
[out] | der | DER data is returned here. |
[in,out] | der_size | As input, the size of the der buffer. As output, the size of the DER data. |
[in] | header | Header to find the beginning of the PEM data. |
[in] | footer | Footer 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_cert | PEM certificate to decode to DER. |
[in] | pem_cert_size | PEM certificate size in bytes. |
[out] | der_cert | DER certificate is returned here. |
[in,out] | der_cert_size | As 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_csr | PEM CSR to decode to DER. |
[in] | pem_csr_size | PEM CSR size in bytes. |
[out] | der_csr | DER CSR is returned here. |
[in,out] | der_csr_size | As 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] | der | DER data to be encoded as PEM. |
[out] | der_size | DER data size in bytes. |
[out] | pem | PEM encoded data is returned here. |
[in,out] | pem_size | As input, the size of the pem buffer. As output, the size of the PEM data. |
[in] | header | Header to place at the beginning of the PEM data. |
[in] | footer | Footer 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_cert | DER certificate to be encoded as PEM. |
[out] | der_cert_size | DER certificate size in bytes. |
[out] | pem_cert | PEM encoded certificate is returned here. |
[in,out] | pem_cert_size | As 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_csr | DER CSR to be encoded as PEM. |
[out] | der_csr_size | DER CSR size in bytes. |
[out] | pem_csr | PEM encoded CSR is returned here. |
[in,out] | pem_csr_size | As 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.