forked from andreafabrizi/DNSProxy
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlibrb64u.h
55 lines (36 loc) · 1.01 KB
/
librb64u.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* re-entrant base64url
* @author jon <[email protected]>
* CC-BY-4.0
*/
#ifndef LIB_RB64U_H
#define LIB_RB64U_H
#include <stdlib.h>
#include <stdint.h>
#define RB64U_RXBUFSZ (4)
typedef struct b64ue b64ue_t;
typedef struct b64ud b64ud_t;
struct b64ue
{
uint8_t f;
size_t q, i, j, n;
uint32_t b[RB64U_RXBUFSZ], t, k;
char r;
};
struct b64ud
{
uint8_t f, s, k, q;
uint32_t a, b, c, t;
char r;
};
int base64url_encode(char *dest, const size_t maxlen, const char *src, const size_t len, size_t *dlen);
int base64url_decode(char *dest, const size_t maxlen, const char *src, const size_t len, size_t *dlen);
void base64url_encode_reset(b64ue_t *state);
int base64url_encode_ingest(b64ue_t *state, char c);
int base64url_encode_getc(b64ue_t *state);
int base64url_encode_finish(b64ue_t *state);
void base64url_decode_reset(b64ud_t *state);
int base64url_decode_ingest(b64ud_t *state, unsigned char c);
int base64url_decode_getc(b64ud_t *state);
int base64url_decode_finish(b64ud_t *state);
#endif