| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef NETTLE_BASE64_H_INCLUDED |
| | #define NETTLE_BASE64_H_INCLUDED |
| |
|
| | #include "nettle-types.h" |
| |
|
| | #ifdef __cplusplus |
| | extern "C" { |
| | #endif |
| |
|
| | |
| | #define base64_encode_init nettle_base64_encode_init |
| | #define base64url_encode_init nettle_base64url_encode_init |
| | #define base64_encode_single nettle_base64_encode_single |
| | #define base64_encode_update nettle_base64_encode_update |
| | #define base64_encode_final nettle_base64_encode_final |
| | #define base64_encode_raw nettle_base64_encode_raw |
| | #define base64_encode_group nettle_base64_encode_group |
| | #define base64_decode_init nettle_base64_decode_init |
| | #define base64url_decode_init nettle_base64url_decode_init |
| | #define base64_decode_single nettle_base64_decode_single |
| | #define base64_decode_update nettle_base64_decode_update |
| | #define base64_decode_final nettle_base64_decode_final |
| |
|
| | #define BASE64_BINARY_BLOCK_SIZE 3 |
| | #define BASE64_TEXT_BLOCK_SIZE 4 |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | #define BASE64_ENCODE_LENGTH(length) (((length) * 8 + 4)/6) |
| |
|
| | |
| | #define BASE64_ENCODE_FINAL_LENGTH 3 |
| |
|
| | |
| | |
| | #define BASE64_ENCODE_RAW_LENGTH(length) ((((length) + 2)/3)*4) |
| |
|
| | struct base64_encode_ctx |
| | { |
| | const char *alphabet; |
| | unsigned short word; |
| | unsigned char bits; |
| | }; |
| |
|
| | |
| | void |
| | base64_encode_init(struct base64_encode_ctx *ctx); |
| |
|
| | |
| | void |
| | base64url_encode_init(struct base64_encode_ctx *ctx); |
| |
|
| | |
| | size_t |
| | base64_encode_single(struct base64_encode_ctx *ctx, |
| | char *dst, |
| | uint8_t src); |
| |
|
| | |
| | |
| | size_t |
| | base64_encode_update(struct base64_encode_ctx *ctx, |
| | char *dst, |
| | size_t length, |
| | const uint8_t *src); |
| |
|
| | |
| | |
| | size_t |
| | base64_encode_final(struct base64_encode_ctx *ctx, |
| | char *dst); |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void |
| | base64_encode_raw(char *dst, size_t length, const uint8_t *src); |
| |
|
| | void |
| | base64_encode_group(char *dst, uint32_t group); |
| |
|
| |
|
| | |
| |
|
| | |
| | |
| | #define BASE64_DECODE_LENGTH(length) ((((length) + 1) * 6) / 8) |
| |
|
| | struct base64_decode_ctx |
| | { |
| | const signed char *table; |
| | unsigned short word; |
| | unsigned char bits; |
| |
|
| | |
| | unsigned char padding; |
| | }; |
| |
|
| | |
| | void |
| | base64_decode_init(struct base64_decode_ctx *ctx); |
| |
|
| | |
| | void |
| | base64url_decode_init(struct base64_decode_ctx *ctx); |
| |
|
| | |
| | |
| | int |
| | base64_decode_single(struct base64_decode_ctx *ctx, |
| | uint8_t *dst, |
| | char src); |
| |
|
| | |
| | |
| | |
| | int |
| | base64_decode_update(struct base64_decode_ctx *ctx, |
| | size_t *dst_length, |
| | uint8_t *dst, |
| | size_t src_length, |
| | const char *src); |
| |
|
| | |
| | int |
| | base64_decode_final(struct base64_decode_ctx *ctx); |
| |
|
| | #ifdef __cplusplus |
| | } |
| | #endif |
| |
|
| | #endif |
| |
|