From ab4c8f149bbb1b8e3ee81a89926927a55e99b684 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:57:51 +0100 Subject: [PATCH] cleanups --- R/base.R | 5 ++++- man/keccak.Rd | 5 ++++- src/secret.c | 19 +++++++++++++++++++ src/secret.h | 31 +++++-------------------------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/R/base.R b/R/base.R index 6c586c4..4190915 100644 --- a/R/base.R +++ b/R/base.R @@ -161,7 +161,10 @@ shake256 <- function(x, bits = 256L, convert = TRUE, file) #' @return A character string, raw or integer vector depending on 'convert'. #' #' @details Keccak is the underlying algorithm for SHA-3, and is identical apart -#' from the padding value. +#' from the value of the padding parameter. +#' +#' The Keccak algorithm was designed by G. Bertoni, J. Daemen, M. Peeters +#' and G. Van Assche. #' #' This implementation is based on one by 'The Mbed TLS Contributors' under #' the 'Mbed TLS' Trusted Firmware Project at diff --git a/man/keccak.Rd b/man/keccak.Rd index d07cf7a..6241d7f 100644 --- a/man/keccak.Rd +++ b/man/keccak.Rd @@ -32,7 +32,10 @@ Returns a Keccak hash of the supplied object or file. } \details{ Keccak is the underlying algorithm for SHA-3, and is identical apart - from the padding value. + from the value of the padding parameter. + + The Keccak algorithm was designed by G. Bertoni, J. Daemen, M. Peeters + and G. Van Assche. This implementation is based on one by 'The Mbed TLS Contributors' under the 'Mbed TLS' Trusted Firmware Project at diff --git a/src/secret.c b/src/secret.c index 1a4f9a0..510b7ab 100644 --- a/src/secret.c +++ b/src/secret.c @@ -32,6 +32,25 @@ * https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.202.pdf */ +typedef enum { + MBEDTLS_SHA3_SHAKE256 = 0, + MBEDTLS_SHA3_224, + MBEDTLS_SHA3_256, + MBEDTLS_SHA3_384, + MBEDTLS_SHA3_512, + MBEDTLS_KECCAK_224, + MBEDTLS_KECCAK_256, + MBEDTLS_KECCAK_384, + MBEDTLS_KECCAK_512, +} mbedtls_sha3_id; + +typedef struct mbedtls_sha3_family_functions { + mbedtls_sha3_id id; + uint16_t r; + uint16_t olen; + uint8_t xor_byte; +} mbedtls_sha3_family_functions; + static mbedtls_sha3_family_functions sha3_families[] = { { MBEDTLS_SHA3_SHAKE256, 1088, 0, 0x1F }, { MBEDTLS_SHA3_224, 1152, 224, 0x06 }, diff --git a/src/secret.h b/src/secret.h index cb5cdc9..9c15d6c 100644 --- a/src/secret.h +++ b/src/secret.h @@ -41,25 +41,6 @@ #define SB_SIPH_SIZE 8 #define SB_SKEY_SIZE 16 -typedef enum { - MBEDTLS_SHA3_SHAKE256 = 0, - MBEDTLS_SHA3_224, - MBEDTLS_SHA3_256, - MBEDTLS_SHA3_384, - MBEDTLS_SHA3_512, - MBEDTLS_KECCAK_224, - MBEDTLS_KECCAK_256, - MBEDTLS_KECCAK_384, - MBEDTLS_KECCAK_512, -} mbedtls_sha3_id; - -typedef struct mbedtls_sha3_family_functions { - mbedtls_sha3_id id; - uint16_t r; - uint16_t olen; - uint8_t xor_byte; -} mbedtls_sha3_family_functions; - typedef struct mbedtls_sha3_context { uint64_t state[25]; uint8_t index; @@ -76,11 +57,6 @@ typedef struct mbedtls_sha256_context { uint32_t state[8]; } mbedtls_sha256_context; -typedef struct secretbase_sha3_context { - int skip; - mbedtls_sha3_context *ctx; -} secretbase_sha3_context; - typedef struct CSipHash { uint64_t v0; uint64_t v1; @@ -90,6 +66,11 @@ typedef struct CSipHash { size_t n_bytes; } CSipHash; +typedef struct secretbase_sha3_context { + int skip; + mbedtls_sha3_context *ctx; +} secretbase_sha3_context; + typedef struct secretbase_sha256_context { int skip; mbedtls_sha256_context *ctx; @@ -113,7 +94,5 @@ SEXP secretbase_sha256(SEXP, SEXP, SEXP); SEXP secretbase_sha256_file(SEXP, SEXP, SEXP); SEXP secretbase_siphash13(SEXP, SEXP, SEXP); SEXP secretbase_siphash13_file(SEXP, SEXP, SEXP); -SEXP secretbase_siphash24(SEXP, SEXP, SEXP); -SEXP secretbase_siphash24_file(SEXP, SEXP, SEXP); #endif