summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2015-03-12 20:51:55 +0100
committerNiels Möller <nisse@lysator.liu.se>2015-03-12 20:59:24 +0100
commitb175384e4312a9ee0b8432fd411f4b968da8d557 (patch)
treefbe87e0ec26913ea1d2150426ea13e162b205d3c
parentf8ef502e30c5f2c5e12d43a2c49790862934f065 (diff)
downloadnettle-b175384e4312a9ee0b8432fd411f4b968da8d557.tar.gz
Micro optimization of base64 and base16 context structs.
-rw-r--r--ChangeLog5
-rw-r--r--base16.h4
-rw-r--r--base64.h12
3 files changed, 13 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index aeb55b56..3d12926c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
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.
2015-03-10 Niels Möller <nisse@diamant.hack.org>
diff --git a/base16.h b/base16.h
index 3facfd4e..2579c0ef 100644
--- a/base16.h
+++ b/base16.h
@@ -74,8 +74,8 @@ base16_encode_update(uint8_t *dst,
struct base16_decode_ctx
{
- unsigned word; /* Leftover bits */
- unsigned bits; /* Number buffered bits */
+ unsigned char word; /* Leftover bits */
+ unsigned char bits; /* Number buffered bits */
};
void
diff --git a/base64.h b/base64.h
index 10c4965c..79194bd4 100644
--- a/base64.h
+++ b/base64.h
@@ -73,9 +73,9 @@ extern "C" {
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 */
+ unsigned short word; /* Leftover bits */
+ unsigned char bits; /* Number of bits, always 0, 2, or 4. */
};
/* Initialize encoding context for base-64 */
@@ -126,12 +126,12 @@ base64_encode_group(uint8_t *dst, uint32_t group);
struct base64_decode_ctx
{
- unsigned word; /* Leftover bits */
- unsigned bits; /* Number buffered bits */
+ const signed char *table; /* Decoding table */
+ unsigned short word; /* Leftover bits */
+ unsigned char bits; /* Number buffered bits */
/* Number of padding characters encountered */
- unsigned padding;
- const signed char *table; /* Decoding table */
+ unsigned char padding;
};
/* Initialize decoding context for base-64 */