Microchip® Advanced Software Framework

pem.c File Reference

This module implements Base64 Decoder.

Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common/include/nm_common.h"
#include "pem.h"

Data Structures

struct  tstrPemDecInfo
 

Functions

sint8 Base64_Decode (uint8 *pu8EncData, uint32 u32EncLength, uint8 **ppu8DecData, uint32 *pu32DecLen)
 
static void Base64_DecodeBlock (uint8 *pu8B64Data, uint8 *pu8BinData)
 
sint8 DecodeBase64File (uint8 *pu8B64File, uint32 u32FileSize, uint8 **ppu8Key, uint32 *pu32KeySize, tenuPEMEncType *penuPemType)
 
sint8 DecodeX509Certificate (uint8 *pu8X509File, uint32 u32X509FileSz, uint8 **ppu8X509Der, uint32 *pu32X509Size)
 

Variables

const tstrPemDecInfo gastrPemTypes []
 
static const uint8 gpau8Ascii2B64 [128]
 

sint8 Base64_Decode ( uint8 pu8EncData,
uint32  u32EncLength,
uint8 **  ppu8DecData,
uint32 pu32DecLen 
)

References Base64_DecodeBlock(), and NULL.

Referenced by DecodeBase64File().

static void Base64_DecodeBlock ( uint8 pu8B64Data,
uint8 pu8BinData 
)
static

References gpau8Ascii2B64.

Referenced by Base64_Decode().

sint8 DecodeBase64File ( uint8 pu8B64File,
uint32  u32FileSize,
uint8 **  ppu8Key,
uint32 pu32KeySize,
tenuPEMEncType penuPemType 
)
sint8 DecodeX509Certificate ( uint8 pu8X509File,
uint32  u32X509FileSz,
uint8 **  ppu8X509Der,
uint32 pu32X509Size 
)

const tstrPemDecInfo gastrPemTypes[]
Initial value:
= {
{PEM_X509_CERT , "-----BEGIN CERTIFICATE-----" , "-----END CERTIFICATE-----"},
{PEM_PRIV_KEY , "-----BEGIN PRIVATE KEY-----" , "-----END PRIVATE KEY-----"},
{PEM_RSA_PRIV_KEY , "-----BEGIN RSA PRIVATE KEY-----" , "-----END RSA PRIVATE KEY-----"}
}
Definition: pem.h:52
Definition: pem.h:51
Definition: pem.h:53

Referenced by DecodeBase64File().

const uint8 gpau8Ascii2B64[128]
static
Initial value:
= {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
}

Referenced by Base64_DecodeBlock().