Commit d22bac82 authored by Niels Möller's avatar Niels Möller
Browse files

Rename *_DATA_SIZE to *_BLOCK_SIZE.

parent 1e79b722
......@@ -85,23 +85,28 @@ _sha3_pad (struct sha3_state *state,
size). */
#define SHA3_224_DIGEST_SIZE 28
#define SHA3_224_DATA_SIZE 144
#define SHA3_224_BLOCK_SIZE 144
#define SHA3_256_DIGEST_SIZE 32
#define SHA3_256_DATA_SIZE 136
#define SHA3_256_BLOCK_SIZE 136
#define SHA3_384_DIGEST_SIZE 48
#define SHA3_384_DATA_SIZE 104
#define SHA3_384_BLOCK_SIZE 104
#define SHA3_512_DIGEST_SIZE 64
#define SHA3_512_DATA_SIZE 72
#define SHA3_512_BLOCK_SIZE 72
/* For backwards compatibility */
#define SHA3_224_DATA_SIZE SHA3_224_BLOCK_SIZE
#define SHA3_256_DATA_SIZE SHA3_256_BLOCK_SIZE
#define SHA3_384_DATA_SIZE SHA3_384_BLOCK_SIZE
#define SHA3_512_DATA_SIZE SHA3_512_BLOCK_SIZE
struct sha3_224_ctx
{
struct sha3_state state;
unsigned index;
uint8_t block[SHA3_224_DATA_SIZE];
uint8_t block[SHA3_224_BLOCK_SIZE];
};
void
......@@ -121,7 +126,7 @@ struct sha3_256_ctx
{
struct sha3_state state;
unsigned index;
uint8_t block[SHA3_256_DATA_SIZE];
uint8_t block[SHA3_256_BLOCK_SIZE];
};
void
......@@ -141,7 +146,7 @@ struct sha3_384_ctx
{
struct sha3_state state;
unsigned index;
uint8_t block[SHA3_384_DATA_SIZE];
uint8_t block[SHA3_384_BLOCK_SIZE];
};
void
......@@ -161,7 +166,7 @@ struct sha3_512_ctx
{
struct sha3_state state;
unsigned index;
uint8_t block[SHA3_512_DATA_SIZE];
uint8_t block[SHA3_512_BLOCK_SIZE];
};
void
......
......@@ -41,7 +41,7 @@ const struct nettle_hash nettle_sha512_224 =
{
"sha512-224", sizeof(struct sha512_ctx),
SHA512_224_DIGEST_SIZE,
SHA512_224_DATA_SIZE,
SHA512_224_BLOCK_SIZE,
(nettle_hash_init_func *) sha512_224_init,
(nettle_hash_update_func *) sha512_224_update,
(nettle_hash_digest_func *) sha512_224_digest
......
......@@ -41,7 +41,7 @@ const struct nettle_hash nettle_sha512_256 =
{
"sha512-256", sizeof(struct sha512_ctx),
SHA512_256_DIGEST_SIZE,
SHA512_256_DATA_SIZE,
SHA512_256_BLOCK_SIZE,
(nettle_hash_init_func *) sha512_256_init,
(nettle_hash_update_func *) sha512_256_update,
(nettle_hash_digest_func *) sha512_256_digest
......
......@@ -172,8 +172,8 @@ sha512_write_digest(struct sha512_ctx *ctx,
/* This is slightly inefficient, as the numbers are converted to
big-endian format, and will be converted back by the compression
function. It's probably not worth the effort to fix this. */
WRITE_UINT64(ctx->block + (SHA512_DATA_SIZE - 16), high);
WRITE_UINT64(ctx->block + (SHA512_DATA_SIZE - 8), low);
WRITE_UINT64(ctx->block + (SHA512_BLOCK_SIZE - 16), high);
WRITE_UINT64(ctx->block + (SHA512_BLOCK_SIZE - 8), low);
COMPRESS(ctx, ctx->block);
words = length / 8;
......
......@@ -86,7 +86,7 @@ _umac_set_key (uint32_t *l1_key, uint32_t *l2_key,
aes128_set_encrypt_key (aes, key);
size = UMAC_DATA_SIZE / 4 + 4*(n-1);
size = UMAC_BLOCK_SIZE / 4 + 4*(n-1);
umac_kdf (aes, 1, size * sizeof(uint32_t), (uint8_t *) l1_key);
BE_SWAP32_N (size, l1_key);
......
......@@ -74,11 +74,13 @@ extern "C" {
#define UMAC64_DIGEST_SIZE 8
#define UMAC96_DIGEST_SIZE 12
#define UMAC128_DIGEST_SIZE 16
#define UMAC_DATA_SIZE 1024
#define UMAC_BLOCK_SIZE 1024
/* For backwards compatibility */
#define UMAC_DATA_SIZE UMAC_BLOCK_SIZE
/* Subkeys and state for UMAC with tag size 32*n bits. */
#define _UMAC_STATE(n) \
uint32_t l1_key[UMAC_DATA_SIZE/4 + 4*((n)-1)]; \
uint32_t l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)]; \
/* Keys in 32-bit pieces, high first */ \
uint32_t l2_key[6*(n)]; \
uint64_t l3_key1[8*(n)]; \
......@@ -99,7 +101,7 @@ extern "C" {
unsigned index; \
/* Complete blocks processed */ \
uint64_t count; \
uint8_t block[UMAC_DATA_SIZE]
uint8_t block[UMAC_BLOCK_SIZE]
#define _UMAC_NONCE_CACHED 0x80
......
......@@ -69,11 +69,11 @@ umac128_set_nonce (struct umac128_ctx *ctx,
#define UMAC128_BLOCK(ctx, block) do { \
uint64_t __umac128_y[4]; \
_umac_nh_n (__umac128_y, 4, ctx->l1_key, UMAC_DATA_SIZE, block); \
__umac128_y[0] += 8*UMAC_DATA_SIZE; \
__umac128_y[1] += 8*UMAC_DATA_SIZE; \
__umac128_y[2] += 8*UMAC_DATA_SIZE; \
__umac128_y[3] += 8*UMAC_DATA_SIZE; \
_umac_nh_n (__umac128_y, 4, ctx->l1_key, UMAC_BLOCK_SIZE, block); \
__umac128_y[0] += 8*UMAC_BLOCK_SIZE; \
__umac128_y[1] += 8*UMAC_BLOCK_SIZE; \
__umac128_y[2] += 8*UMAC_BLOCK_SIZE; \
__umac128_y[3] += 8*UMAC_BLOCK_SIZE; \
_umac_l2 (ctx->l2_key, ctx->l2_state, 4, ctx->count++, __umac128_y); \
} while (0)
......
......@@ -72,8 +72,8 @@ umac32_set_nonce (struct umac32_ctx *ctx,
#define UMAC32_BLOCK(ctx, block) do { \
uint64_t __umac32_y \
= _umac_nh (ctx->l1_key, UMAC_DATA_SIZE, block) \
+ 8*UMAC_DATA_SIZE ; \
= _umac_nh (ctx->l1_key, UMAC_BLOCK_SIZE, block) \
+ 8*UMAC_BLOCK_SIZE ; \
_umac_l2 (ctx->l2_key, ctx->l2_state, 1, ctx->count++, &__umac32_y); \
} while (0)
......
......@@ -72,9 +72,9 @@ umac64_set_nonce (struct umac64_ctx *ctx,
#define UMAC64_BLOCK(ctx, block) do { \
uint64_t __umac64_y[2]; \
_umac_nh_n (__umac64_y, 2, ctx->l1_key, UMAC_DATA_SIZE, block); \
__umac64_y[0] += 8*UMAC_DATA_SIZE; \
__umac64_y[1] += 8*UMAC_DATA_SIZE; \
_umac_nh_n (__umac64_y, 2, ctx->l1_key, UMAC_BLOCK_SIZE, block); \
__umac64_y[0] += 8*UMAC_BLOCK_SIZE; \
__umac64_y[1] += 8*UMAC_BLOCK_SIZE; \
_umac_l2 (ctx->l2_key, ctx->l2_state, 2, ctx->count++, __umac64_y); \
} while (0)
......
......@@ -69,10 +69,10 @@ umac96_set_nonce (struct umac96_ctx *ctx,
#define UMAC96_BLOCK(ctx, block) do { \
uint64_t __umac96_y[3]; \
_umac_nh_n (__umac96_y, 3, ctx->l1_key, UMAC_DATA_SIZE, block); \
__umac96_y[0] += 8*UMAC_DATA_SIZE; \
__umac96_y[1] += 8*UMAC_DATA_SIZE; \
__umac96_y[2] += 8*UMAC_DATA_SIZE; \
_umac_nh_n (__umac96_y, 3, ctx->l1_key, UMAC_BLOCK_SIZE, block); \
__umac96_y[0] += 8*UMAC_BLOCK_SIZE; \
__umac96_y[1] += 8*UMAC_BLOCK_SIZE; \
__umac96_y[2] += 8*UMAC_BLOCK_SIZE; \
_umac_l2 (ctx->l2_key, ctx->l2_state, 3, ctx->count++, __umac96_y); \
} while (0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment