opensc
NPCI secure-component & UPI Lite / Lite X wallet reimplementation
Loading...
Searching...
No Matches
codec.h File Reference

Base64 and hex, reproducing Android's two base64 flags exactly. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for codec.h:

Go to the source code of this file.

Enumerations

enum  { LITE_B64_DEFAULT = 0 , LITE_B64_NO_WRAP = 2 }
 Android base64 flags: DEFAULT wraps at 76 chars and appends '
'; NO_WRAP does neither.
 

Functions

size_t lite_b64_encode_len (size_t in_len, int flag)
 Buffer size (incl. NUL) needed to base64-encode in_len bytes under flag.
 
size_t lite_b64_encode (const uint8_t *in, size_t in_len, int flag, char *out, size_t out_cap)
 Base64-encodes in_len bytes into out (NUL-terminated); returns chars written, 0 if out_cap too small.
 
size_t lite_b64_decode_len (size_t in_len)
 Upper bound on bytes produced by decoding a base64 string of in_len chars.
 
long lite_b64_decode (const char *in, size_t in_len, uint8_t *out, size_t out_cap)
 Base64-decodes in_len chars into out; returns bytes written, or -1 if out_cap too small.
 
size_t lite_hex_encode (const uint8_t *in, size_t in_len, char *out, size_t out_cap)
 Lowercase-hex-encodes in_len bytes into out (NUL-terminated); returns chars written, 0 on overflow.
 
long lite_hex_decode (const char *in, size_t in_len, uint8_t *out, size_t out_cap)
 Hex-decodes in_len chars into out; returns bytes written, or -1 on bad input or overflow.
 

Detailed Description

Base64 and hex, reproducing Android's two base64 flags exactly.