13 #ifndef TOR_BINASCII_H
14 #define TOR_BINASCII_H
21 const char *
hex_str(
const char *from,
size_t fromlen);
28 #define BASE64_LEN(n) (CEIL_DIV((n), 3) * 4)
29 #define BASE32_LEN(n) (CEIL_DIV((n), 5) * 8)
30 #define BASE16_LEN(n) ((n) * 2)
32 #define BASE64_BUFSIZE(n) (BASE64_LEN(n) + 1)
33 #define BASE32_BUFSIZE(n) (BASE32_LEN(n) + 1)
34 #define BASE16_BUFSIZE(n) (BASE16_LEN(n) + 1)
36 #define BASE64_NOPAD_LEN(n) (CEIL_DIV((n) * 4, 3))
37 #define BASE32_NOPAD_LEN(n) (CEIL_DIV((n) * 8, 5))
39 #define BASE64_NOPAD_BUFSIZE(n) (BASE64_NOPAD_LEN(n) + 1)
40 #define BASE32_NOPAD_BUFSIZE(n) (BASE32_NOPAD_LEN(n) + 1)
43 #define BASE64_ENCODE_MULTILINE 1
46 int base64_encode(
char *dest,
size_t destlen,
const char *src,
size_t srclen,
48 int base64_decode(
char *dest,
size_t destlen,
const char *src,
size_t srclen);
50 const uint8_t *src,
size_t srclen);
53 #define BASE32_CHARS "abcdefghijklmnopqrstuvwxyz234567"
54 void base32_encode(
char *dest,
size_t destlen,
const char *src,
size_t srclen);
55 int base32_decode(
char *dest,
size_t destlen,
const char *src,
size_t srclen);
56 size_t base32_encoded_size(
size_t srclen);
58 void base16_encode(
char *dest,
size_t destlen,
const char *src,
size_t srclen);
59 int base16_decode(
char *dest,
size_t destlen,
const char *src,
size_t srclen);
int base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
const char * hex_str(const char *from, size_t fromlen)
int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen, int flags)
int base64_encode_nopad(char *dest, size_t destlen, const uint8_t *src, size_t srclen)
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
size_t base64_decode_maxsize(size_t srclen)
size_t base64_encode_size(size_t srclen, int flags)
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
void base32_encode(char *dest, size_t destlen, const char *src, size_t srclen)
Macros to implement mocking and selective exposure for the test code.
Integer definitions used throughout Tor.