Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ref
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-02-09 05:39:53 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2016-02-09 05:39:53 +0300
commita6bd49a6efd538caf0df815042049a306c521b89 (patch)
treee670151d2bc2908be6a4d9c4eb585287af5c0ae0 /ref
parent051109d9b09257b61736e03a071985651cfc098c (diff)
Do not pack blake2_state structs
While the param structs need to be packed, because they're compressed as a byte stream, the state structs do not have this requirement. As such, the compiler likely can emit more efficient code in certain circumstances when it can apply the ordinary struct alignment rules.
Diffstat (limited to 'ref')
-rw-r--r--ref/blake2.h63
1 files changed, 32 insertions, 31 deletions
diff --git a/ref/blake2.h b/ref/blake2.h
index cc625cb..abd1f35 100644
--- a/ref/blake2.h
+++ b/ref/blake2.h
@@ -39,22 +39,6 @@ extern "C" {
BLAKE2B_PERSONALBYTES = 16
};
-#pragma pack(push, 1)
- typedef struct __blake2s_param
- {
- uint8_t digest_length; // 1
- uint8_t key_length; // 2
- uint8_t fanout; // 3
- uint8_t depth; // 4
- uint32_t leaf_length; // 8
- uint8_t node_offset[6];// 14
- uint8_t node_depth; // 15
- uint8_t inner_length; // 16
- // uint8_t reserved[0];
- uint8_t salt[BLAKE2S_SALTBYTES]; // 24
- uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32
- } blake2s_param;
-
typedef struct __blake2s_state
{
uint32_t h[8];
@@ -65,21 +49,6 @@ extern "C" {
uint8_t last_node;
} blake2s_state;
- typedef struct __blake2b_param
- {
- uint8_t digest_length; // 1
- uint8_t key_length; // 2
- uint8_t fanout; // 3
- uint8_t depth; // 4
- uint32_t leaf_length; // 8
- uint64_t node_offset; // 16
- uint8_t node_depth; // 17
- uint8_t inner_length; // 18
- uint8_t reserved[14]; // 32
- uint8_t salt[BLAKE2B_SALTBYTES]; // 48
- uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64
- } blake2b_param;
-
typedef struct __blake2b_state
{
uint64_t h[8];
@@ -105,6 +74,38 @@ extern "C" {
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
size_t buflen;
} blake2bp_state;
+
+
+#pragma pack(push, 1)
+ typedef struct __blake2s_param
+ {
+ uint8_t digest_length; // 1
+ uint8_t key_length; // 2
+ uint8_t fanout; // 3
+ uint8_t depth; // 4
+ uint32_t leaf_length; // 8
+ uint8_t node_offset[6];// 14
+ uint8_t node_depth; // 15
+ uint8_t inner_length; // 16
+ // uint8_t reserved[0];
+ uint8_t salt[BLAKE2S_SALTBYTES]; // 24
+ uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32
+ } blake2s_param;
+
+ typedef struct __blake2b_param
+ {
+ uint8_t digest_length; // 1
+ uint8_t key_length; // 2
+ uint8_t fanout; // 3
+ uint8_t depth; // 4
+ uint32_t leaf_length; // 8
+ uint64_t node_offset; // 16
+ uint8_t node_depth; // 17
+ uint8_t inner_length; // 18
+ uint8_t reserved[14]; // 32
+ uint8_t salt[BLAKE2B_SALTBYTES]; // 48
+ uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64
+ } blake2b_param;
#pragma pack(pop)
// Streaming API