mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-26 21:39:56 +00:00
remove not-needed fields from SHA-3 context
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
bcfd79c699
commit
1789d84282
@ -60,7 +60,6 @@ typedef struct mbedtls_sha3_family_functions {
|
||||
|
||||
uint16_t r;
|
||||
uint16_t olen;
|
||||
uint8_t xor_byte;
|
||||
}
|
||||
mbedtls_sha3_family_functions;
|
||||
|
||||
@ -72,11 +71,7 @@ mbedtls_sha3_family_functions;
|
||||
typedef struct mbedtls_sha3_context {
|
||||
uint64_t state[25];
|
||||
uint8_t index;
|
||||
uint8_t id;
|
||||
|
||||
uint16_t r;
|
||||
uint16_t olen;
|
||||
uint8_t xor_byte;
|
||||
uint16_t max_block_size;
|
||||
}
|
||||
mbedtls_sha3_context;
|
||||
|
@ -36,15 +36,17 @@
|
||||
#include "mbedtls/platform.h"
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#define XOR_BYTE 0x6
|
||||
|
||||
/*
|
||||
* List of supported SHA-3 families
|
||||
*/
|
||||
static mbedtls_sha3_family_functions sha3_families[] = {
|
||||
{ MBEDTLS_SHA3_224, 1152, 224, 0x06 },
|
||||
{ MBEDTLS_SHA3_256, 1088, 256, 0x06 },
|
||||
{ MBEDTLS_SHA3_384, 832, 384, 0x06 },
|
||||
{ MBEDTLS_SHA3_512, 576, 512, 0x06 },
|
||||
{ MBEDTLS_SHA3_NONE, 0, 0, 0 }
|
||||
{ MBEDTLS_SHA3_224, 1152, 224 },
|
||||
{ MBEDTLS_SHA3_256, 1088, 256 },
|
||||
{ MBEDTLS_SHA3_384, 832, 384 },
|
||||
{ MBEDTLS_SHA3_512, 576, 512 },
|
||||
{ MBEDTLS_SHA3_NONE, 0, 0 }
|
||||
};
|
||||
|
||||
static const uint64_t rc[24] = {
|
||||
@ -207,11 +209,8 @@ int mbedtls_sha3_starts(mbedtls_sha3_context *ctx, mbedtls_sha3_id id)
|
||||
return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
ctx->id = id;
|
||||
ctx->r = p->r;
|
||||
ctx->olen = p->olen / 8;
|
||||
ctx->xor_byte = p->xor_byte;
|
||||
ctx->max_block_size = ctx->r / 8;
|
||||
ctx->max_block_size = p->r / 8;
|
||||
|
||||
memset(ctx->state, 0, sizeof(ctx->state));
|
||||
ctx->index = 0;
|
||||
@ -285,7 +284,7 @@ int mbedtls_sha3_finish(mbedtls_sha3_context *ctx,
|
||||
olen = ctx->olen;
|
||||
}
|
||||
|
||||
ABSORB(ctx, ctx->index, ctx->xor_byte);
|
||||
ABSORB(ctx, ctx->index, XOR_BYTE);
|
||||
ABSORB(ctx, ctx->max_block_size - 1, 0x80);
|
||||
keccak_f1600(ctx);
|
||||
ctx->index = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user