Skip to content
Snippets Groups Projects
Commit b175384e authored by Niels Möller's avatar Niels Möller
Browse files

Micro optimization of base64 and base16 context structs.

parent f8ef502e
No related branches found
No related tags found
No related merge requests found
2015-03-12 Niels Möller <nisse@diamant.hack.org> 2015-03-12 Niels Möller <nisse@diamant.hack.org>
* base64.h (struct base64_encode_ctx): Micro optimization of
struct layout, saving a few bytes.
(struct base64_decode_ctx): Likewise.
* base16.h (struct base16_decode_ctx): Likewise.
* nettle.texinfo (ASCII encoding): Document base64url functions. * nettle.texinfo (ASCII encoding): Document base64url functions.
2015-03-10 Niels Möller <nisse@diamant.hack.org> 2015-03-10 Niels Möller <nisse@diamant.hack.org>
......
...@@ -74,8 +74,8 @@ base16_encode_update(uint8_t *dst, ...@@ -74,8 +74,8 @@ base16_encode_update(uint8_t *dst,
struct base16_decode_ctx struct base16_decode_ctx
{ {
unsigned word; /* Leftover bits */ unsigned char word; /* Leftover bits */
unsigned bits; /* Number buffered bits */ unsigned char bits; /* Number buffered bits */
}; };
void void
......
...@@ -73,9 +73,9 @@ extern "C" { ...@@ -73,9 +73,9 @@ extern "C" {
struct base64_encode_ctx struct base64_encode_ctx
{ {
unsigned word; /* Leftover bits */
unsigned bits; /* Number of bits, always 0, 2, or 4. */
const uint8_t *alphabet; /* Alphabet to use for encoding */ const uint8_t *alphabet; /* Alphabet to use for encoding */
unsigned short word; /* Leftover bits */
unsigned char bits; /* Number of bits, always 0, 2, or 4. */
}; };
/* Initialize encoding context for base-64 */ /* Initialize encoding context for base-64 */
...@@ -126,12 +126,12 @@ base64_encode_group(uint8_t *dst, uint32_t group); ...@@ -126,12 +126,12 @@ base64_encode_group(uint8_t *dst, uint32_t group);
struct base64_decode_ctx struct base64_decode_ctx
{ {
unsigned word; /* Leftover bits */ const signed char *table; /* Decoding table */
unsigned bits; /* Number buffered bits */ unsigned short word; /* Leftover bits */
unsigned char bits; /* Number buffered bits */
/* Number of padding characters encountered */ /* Number of padding characters encountered */
unsigned padding; unsigned char padding;
const signed char *table; /* Decoding table */
}; };
/* Initialize decoding context for base-64 */ /* Initialize decoding context for base-64 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment