NetBurner 3.5.6
PDF Version |
Privacy-Enhanced Mail (PEM) format conversion and endianness utilities. More...
Topics | |
PEM Data Type Identifiers | |
Return values indicating the type of PEM data that was converted. | |
PEM Format Footers | |
Standard PEM footer markers for different data types. | |
PEM Format Headers | |
Standard PEM header markers for different data types. | |
Macros | |
#define | CONVERT_BUFFER_LENGTH_MAX ((4 * 1024) - 1) |
Maximum data buffer length in bytes for PEM conversion. | |
Functions | |
int | ConvertPEMFormattedData (puint8_t dataPtr, const char *pemEncodedData, uint32_t dataSize, puint32_t convertedDataLength, char **nextPtr=NULL) |
Convert data from Privacy-Enhanced Mail (PEM) format to binary DER format. | |
uint16_t | convertLittleEndianWord (uint16_t hData) |
Convert 16-bit data between host byte order and little-endian format. | |
uint32_t | convertLittleEndianDword (uint32_t hData) |
Convert 32-bit data between host byte order and little-endian format. | |
Privacy-Enhanced Mail (PEM) format conversion and endianness utilities.
#include< convert.h>
This module provides functions for converting between PEM-encoded cryptographic data and binary formats, as well as byte-order conversion utilities. PEM format is commonly used for storing and transmitting cryptographic keys and certificates in a text-based, Base64-encoded format.
#define CONVERT_BUFFER_LENGTH_MAX ((4 * 1024) - 1) |
#include <convert.h>
Maximum data buffer length in bytes for PEM conversion.
This defines the maximum size of the output buffer needed for PEM conversion operations. The buffer must be at least this size to safely convert PEM data.
Value: 4095 bytes (4KB - 1)
uint32_t convertLittleEndianDword | ( | uint32_t | hData | ) |
#include <convert.h>
Convert 32-bit data between host byte order and little-endian format.
Converts a 32-bit value to or from little-endian byte order. This function is bidirectional - it performs the same operation regardless of conversion direction. On little-endian systems (x86, ARM in little-endian mode), this is a no-op. On big-endian systems (ColdFire, PowerPC), it swaps the byte order.
hData | 32-bit value to convert. Can be in either host or little-endian format. |
Expand for Example Usage
uint16_t convertLittleEndianWord | ( | uint16_t | hData | ) |
#include <convert.h>
Convert 16-bit data between host byte order and little-endian format.
Converts a 16-bit value to or from little-endian byte order. This function is bidirectional - it performs the same operation regardless of conversion direction. On little-endian systems (x86, ARM in little-endian mode), this is a no-op. On big-endian systems (ColdFire, PowerPC), it swaps the byte order.
hData | 16-bit value to convert. Can be in either host or little-endian format. |
Expand for Example Usage
int ConvertPEMFormattedData | ( | puint8_t | dataPtr, |
const char * | pemEncodedData, | ||
uint32_t | dataSize, | ||
puint32_t | convertedDataLength, | ||
char ** | nextPtr = NULL ) |
#include <convert.h>
Convert data from Privacy-Enhanced Mail (PEM) format to binary DER format.
This function converts PEM-encoded cryptographic data (certificates or private keys) from Base64-encoded text format to binary DER (Distinguished Encoding Rules) format. It automatically detects the type of PEM data based on the header/footer markers.
The function performs:
[out] | dataPtr | Pointer to buffer for converted binary data. Must be at least CONVERT_BUFFER_LENGTH_MAX bytes. The buffer will contain the DER-encoded binary representation of the key or certificate. |
[in] | pemEncodedData | Pointer to NULL-terminated string containing PEM-encoded data. May contain multiple PEM objects; function will process the first valid one found. |
[in] | dataSize | Size of the output buffer pointed to by dataPtr, in bytes. Should be at least CONVERT_BUFFER_LENGTH_MAX. |
[out] | convertedDataLength | Pointer to uint32_t where the actual length of converted data will be stored. This value will be less than or equal to dataSize. |
[out] | nextPtr | Optional pointer to char pointer. If provided and not NULL, will be set to point to the character immediately following the converted PEM data. Useful for processing multiple PEM objects in a single string. Pass NULL if not needed. |
CONVERT_NONE | Malformed data, calling parameters invalid, or conversion failed |
CONVERT_CERTIFICATE | Successfully converted X.509 certificate |
CONVERT_RSA_PRIVATE_KEY | Successfully converted RSA private key |
CONVERT_DSA_PRIVATE_KEY | Successfully converted DSA private key |
CONVERT_ECDSA_PRIVATE_KEY | Successfully converted ECDSA private key |
Notes:
Warnings:
Expand for Example Usage