36 strlen(
"-----BEGIN -----\n") +
37 strlen(
"-----END -----\n") +
49 pem_encode(
char *dest,
size_t destlen,
const uint8_t *src,
size_t srclen,
52 if (
tor_snprintf(dest, destlen,
"-----BEGIN %s-----\n", objtype) < 0)
55 size_t offset = strlen(dest);
58 (
const char *)src, srclen, BASE64_ENCODE_MULTILINE);
62 if (BUG(offset > destlen))
66 "-----END %s-----\n", objtype) < 0)
80 pem_decode(uint8_t *dest,
size_t destlen,
const char *src,
size_t srclen,
83 const char *eos = src + srclen;
89 if ((
size_t)(eos-src) < strlen(tag) ||
fast_memneq(src, tag, strlen(tag))) {
97 if (src == eos || *src !=
'\n') {
104 const char *end_of_base64 = tor_memstr(src, eos-src, tag);
106 if (end_of_base64 == NULL)
111 return base64_decode((
char*)dest, destlen, src, end_of_base64-src);
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)
size_t base64_encode_size(size_t srclen, int flags)
#define fast_memneq(a, b, c)
Headers for util_malloc.c.
int pem_decode(uint8_t *dest, size_t destlen, const char *src, size_t srclen, const char *objtype)
size_t pem_encoded_size(size_t src_len, const char *objtype)
int pem_encode(char *dest, size_t destlen, const uint8_t *src, size_t srclen, const char *objtype)
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
Macros to manage assertions, fatal and non-fatal.
const char * eat_whitespace_eos_no_nl(const char *s, const char *eos)
const char * eat_whitespace_eos(const char *s, const char *eos)
Header for util_string.c.