MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / Base64DecodeClover

Function Base64DecodeClover

rEFIt_UEFI/Platform/b64cdecode.cpp:96–127  ·  view source on GitHub ↗

UEFI interface to base54 decode. * Decodes EncodedData into a new allocated buffer and returns it. Caller is responsible to FreePool() it. * If DecodedSize != NULL, then size od decoded data is put there. * If return value is not NULL, DecodedSize IS > 0 */

Source from the content-addressed store, hash-verified

94 * If return value is not NULL, DecodedSize IS > 0
95 */
96UINT8 *Base64DecodeClover(IN CONST CHAR8 *EncodedData, OUT UINTN *DecodedSize)
97{
98 UINTN EncodedSize;
99 INTN DecodedSizeInternal;
100 UINT8 *DecodedData;
101 base64_decodestate state_in;
102
103 if (EncodedData == NULL) {
104 return NULL;
105 }
106 EncodedSize = strlen(EncodedData);
107 if (EncodedSize == 0) {
108 return NULL;
109 }
110 // to simplify, we'll allocate the same size, although smaller size is needed
111 DecodedData = (__typeof__(DecodedData))AllocateZeroPool(EncodedSize);
112
113 base64_init_decodestate(&state_in);
114 DecodedSizeInternal = base64_decode_block(EncodedData, (const int)EncodedSize, (char*) DecodedData, &state_in);
115
116 if ( DecodedSizeInternal == 0 ) {
117 FreePool(DecodedData);
118 DecodedData = NULL;
119 }
120
121 if (DecodedSize != NULL) {
122 if ( DecodedSizeInternal < 0 ) panic("Base64DecodeClover : DecodedSizeInternal < 0");
123 *DecodedSize = (UINTN)DecodedSizeInternal;
124 }
125
126 return DecodedData;
127}

Callers 2

ParseTagDataFunction · 0.85
parseImageFunction · 0.85

Calls 6

base64_init_decodestateFunction · 0.85
base64_decode_blockFunction · 0.85
strlenFunction · 0.50
AllocateZeroPoolFunction · 0.50
FreePoolFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected