Remove unused base64 encoding code.

m17
Rob Riggs 2021-01-01 22:53:29 -06:00
rodzic 1dd1ac6dcc
commit fa8b4660e9
3 zmienionych plików z 0 dodań i 96 usunięć

Wyświetl plik

@ -58,7 +58,6 @@
#include "PortInterface.h"
#include "LEDIndicator.h"
#include "bm78.h"
#include "base64.h"
#include "KissHardware.h"
#include "Log.h"

Wyświetl plik

@ -1,57 +0,0 @@
// Copyright 2018 Rob Riggs <rob@mobilinkd.com>
// All rights reserved.
#include "base64.h"
#include "assert.h"
namespace {
const char alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
}
uint32_t base64encode(const uint8_t* src, uint32_t src_len, char* dest,
uint32_t* dest_len)
{
uint32_t expected = ((src_len * 4) + 2) / 3;
uint32_t dpos = 0;
uint8_t b1, b2, b3, b4;
for (uint32_t i = 0; i < src_len; i += 3)
{
if (dpos == *dest_len) return expected;
b1 = src[i] >> 2;
b2 = ((src[i] & 0x3) << 4);
dest[dpos++] = alphabet[b1];
if (dpos == *dest_len) return expected;
if (i + 1 == src_len)
{
dest[dpos++] = alphabet[b2];
break;
}
else
{
b2 |= (src[i + 1] >> 4);
dest[dpos++] = alphabet[b2];
b3 = (src[i + 1] & 0x0F) << 2;
}
if (dpos == *dest_len) return expected;
if (i + 2 == src_len)
{
dest[dpos++] = alphabet[b3];
break;
}
else
{
b3 |= src[i + 2] >> 6;
dest[dpos++] = alphabet[b3];
b4 = src[i + 2] & 0x3F;
}
if (dpos == *dest_len) return expected;
dest[dpos++] = alphabet[b4];
}
*dest_len = dpos;
assert(*dest_len == expected);
return expected;
}

Wyświetl plik

@ -1,38 +0,0 @@
// Copyright 2018 Rob Riggs <rob@mobilinkd.com>
// All rights reserved.
#ifndef MOBILINKD__TNC__BASE64_H_
#define MOBILINKD__TNC__BASE64_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Base64 encode binary data from src, storing the result in dest. The
* input value of dest_len limits the length of the string which will be
* written to dest. If this value is not >= 4/3 * src_len, the output
* string will be truncated. The amount written will be returned in
* dest_len (in this case in==out) and the amount that would have been
* written is returned.
*
* If the return value and the value returned in dest_len are different,
* dest did not contain enough space to fully encode the result.
*
* @param src is the binary data to be base64 encoded.
* @param src_len is the length of the binary data to encode.
* @param dest is the destination buffer to contain the encoded string.
* @param[in,out] dest_len on input is the size of the dest buffer and on
* output is the number of characters written to dest.
* @return the length of src fully base64 encoded.
*/
uint32_t base64encode(const uint8_t* src, uint32_t src_len, char* dest,
uint32_t* dest_len);
#ifdef __cplusplus
}
#endif
#endif // MOBILINKD__TNC__BASE64_H_