Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SHA3 Scalar and Simd256 functions #439

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions benchmarks/sha3.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "util.h"

#include "Hacl_Hash_SHA3.h"
#include "Hacl_SHA3_Scalar.h"
#include "Hacl_Hash_SHA3_Scalar.h"

#ifdef HACL_CAN_COMPILE_VEC256
#include "Hacl_SHA3_Vec256.h"
#include "Hacl_Hash_SHA3_Simd256.h"
#endif

const bytes input(1000, 0x37);
Expand Down Expand Up @@ -59,10 +59,10 @@ Hacl_Sha3_224(benchmark::State& state)
BENCHMARK(Hacl_Sha3_224)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_224(benchmark::State& state)
Hacl_Sha3_224_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_sha3_224(
Hacl_Hash_SHA3_Scalar_sha3_224(
input.size(), (uint8_t*)input.data(), digest224_0.data());
}
if (digest224_0 != expected_digest_sha3_224) {
Expand All @@ -71,14 +71,14 @@ Hacl_Scalar_Sha3_224(benchmark::State& state)
}
}

BENCHMARK(Hacl_Scalar_Sha3_224)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_224_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC256
static void
Hacl_Vec256_Sha3_224(benchmark::State& state)
Hacl_Sha3_224_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_sha3_224_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_sha3_224(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -97,7 +97,7 @@ Hacl_Vec256_Sha3_224(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec256_Sha3_224)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_224_Simd256)->Setup(DoSetup);
#endif

#ifndef NO_OPENSSL
Expand Down Expand Up @@ -126,10 +126,10 @@ Hacl_Sha3_256(benchmark::State& state)
BENCHMARK(Hacl_Sha3_256)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_256(benchmark::State& state)
Hacl_Sha3_256_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_sha3_256(
Hacl_Hash_SHA3_Scalar_sha3_256(
input.size(), (uint8_t*)input.data(), digest256_0.data());
}
if (digest256_0 != expected_digest_sha3_256) {
Expand All @@ -138,14 +138,14 @@ Hacl_Scalar_Sha3_256(benchmark::State& state)
}
}

BENCHMARK(Hacl_Scalar_Sha3_256)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_256_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC256
static void
Hacl_Vec256_Sha3_256(benchmark::State& state)
Hacl_Sha3_256_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_sha3_256_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_sha3_256(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -164,7 +164,7 @@ Hacl_Vec256_Sha3_256(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec256_Sha3_256)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_256_Simd256)->Setup(DoSetup);
#endif

#include "sha3.h"
Expand Down Expand Up @@ -220,10 +220,10 @@ Hacl_Sha3_384(benchmark::State& state)
BENCHMARK(Hacl_Sha3_384)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_384(benchmark::State& state)
Hacl_Sha3_384_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_sha3_384(
Hacl_Hash_SHA3_Scalar_sha3_384(
input.size(), (uint8_t*)input.data(), digest384_0.data());
}
if (digest384_0 != expected_digest_sha3_384) {
Expand All @@ -232,14 +232,14 @@ Hacl_Scalar_Sha3_384(benchmark::State& state)
}
}

BENCHMARK(Hacl_Scalar_Sha3_384)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_384_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC384
static void
Hacl_Vec384_Sha3_384(benchmark::State& state)
Hacl_Sha3_384_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_sha3_384_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_sha3_384(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -258,7 +258,7 @@ Hacl_Vec384_Sha3_384(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec384_Sha3_384)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_384_Simd256)->Setup(DoSetup);
#endif

#ifndef NO_OPENSSL
Expand Down Expand Up @@ -287,10 +287,10 @@ Hacl_Sha3_512(benchmark::State& state)
BENCHMARK(Hacl_Sha3_512)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_512(benchmark::State& state)
Hacl_Sha3_512_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_sha3_512(
Hacl_Hash_SHA3_Scalar_sha3_512(
input.size(), (uint8_t*)input.data(), digest512_0.data());
}
if (digest512_0 != expected_digest_sha3_512) {
Expand All @@ -299,14 +299,14 @@ Hacl_Scalar_Sha3_512(benchmark::State& state)
}
}

BENCHMARK(Hacl_Scalar_Sha3_512)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_512_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC256
static void
Hacl_Vec512_Sha3_512(benchmark::State& state)
Hacl_Sha3_512_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_sha3_512_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_sha3_512(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -325,7 +325,7 @@ Hacl_Vec512_Sha3_512(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec512_Sha3_512)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_512_Simd256)->Setup(DoSetup);
#endif

static void
Expand Down Expand Up @@ -444,24 +444,24 @@ Hacl_Sha3_shake128(benchmark::State& state)
BENCHMARK(Hacl_Sha3_shake128)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_shake128(benchmark::State& state)
Hacl_Sha3_shake128_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_shake128_hacl(input.size(),
Hacl_Hash_SHA3_Scalar_shake128(input.size(),
(uint8_t*)input.data(),
digest_shake_0.size(),
digest_shake_0.data());
}
}

BENCHMARK(Hacl_Scalar_Sha3_shake128)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_shake128_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC256
static void
Hacl_Vec256_Sha3_shake128(benchmark::State& state)
Hacl_Sha3_shake128_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_shake128_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_shake128(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -474,7 +474,7 @@ Hacl_Vec256_Sha3_shake128(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec256_Sha3_shake128)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_shake128_Simd256)->Setup(DoSetup);
#endif

static void
Expand All @@ -491,24 +491,24 @@ Hacl_Sha3_shake256(benchmark::State& state)
BENCHMARK(Hacl_Sha3_shake256)->Setup(DoSetup);

static void
Hacl_Scalar_Sha3_shake256(benchmark::State& state)
Hacl_Sha3_shake256_Scalar(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Scalar_shake256_hacl(input.size(),
Hacl_Hash_SHA3_Scalar_shake256(input.size(),
(uint8_t*)input.data(),
digest_shake_0.size(),
digest_shake_0.data());
}
}

BENCHMARK(Hacl_Scalar_Sha3_shake256)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_shake256_Scalar)->Setup(DoSetup);

#ifdef HACL_CAN_COMPILE_VEC256
static void
Hacl_Vec256_Sha3_shake256(benchmark::State& state)
Hacl_Sha3_shake256_Simd256(benchmark::State& state)
{
for (auto _ : state) {
Hacl_SHA3_Vec256_shake256_vec256(input.size(),
Hacl_Hash_SHA3_Simd256_shake256(input.size(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
(uint8_t*)input.data(),
Expand All @@ -521,7 +521,7 @@ Hacl_Vec256_Sha3_shake256(benchmark::State& state)
}
}

BENCHMARK(Hacl_Vec256_Sha3_shake256)->Setup(DoSetup);
BENCHMARK(Hacl_Sha3_shake256_Simd256)->Setup(DoSetup);
#endif

BENCHMARK_MAIN();
4 changes: 2 additions & 2 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@
],
"sha3-mb": [
{
"file": "Hacl_SHA3_Scalar.c",
"file": "Hacl_Hash_SHA3_Scalar.c",
"features": "std"
},
{
"file": "Hacl_SHA3_Vec256.c",
"file": "Hacl_Hash_SHA3_Simd256.c",
"features": "vec256"
}
]
Expand Down
14 changes: 7 additions & 7 deletions config/default_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set(SOURCES_std
${PROJECT_SOURCE_DIR}/src/EverCrypt_Chacha20Poly1305.c
${PROJECT_SOURCE_DIR}/src/EverCrypt_Poly1305.c
${PROJECT_SOURCE_DIR}/src/EverCrypt_AEAD.c
${PROJECT_SOURCE_DIR}/src/Hacl_SHA3_Scalar.c
${PROJECT_SOURCE_DIR}/src/Hacl_Hash_SHA3_Scalar.c
)
set(SOURCES_vec256
${PROJECT_SOURCE_DIR}/src/Hacl_Hash_Blake2b_Simd256.c
Expand All @@ -65,7 +65,7 @@ set(SOURCES_vec256
${PROJECT_SOURCE_DIR}/src/Hacl_HPKE_Curve51_CP256_SHA256.c
${PROJECT_SOURCE_DIR}/src/Hacl_HPKE_Curve51_CP256_SHA512.c
${PROJECT_SOURCE_DIR}/src/Hacl_HPKE_P256_CP256_SHA256.c
${PROJECT_SOURCE_DIR}/src/Hacl_SHA3_Vec256.c
${PROJECT_SOURCE_DIR}/src/Hacl_Hash_SHA3_Simd256.c
)
set(SOURCES_vec128
${PROJECT_SOURCE_DIR}/src/Hacl_Hash_Blake2s_Simd128.c
Expand Down Expand Up @@ -241,9 +241,9 @@ set(INCLUDES
${PROJECT_SOURCE_DIR}/include/EverCrypt_Chacha20Poly1305.h
${PROJECT_SOURCE_DIR}/include/EverCrypt_Poly1305.h
${PROJECT_SOURCE_DIR}/include/EverCrypt_AEAD.h
${PROJECT_SOURCE_DIR}/include/internal/Hacl_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_SHA3_Vec256.h
${PROJECT_SOURCE_DIR}/include/internal/Hacl_Hash_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_Hash_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_Hash_SHA3_Simd256.h
)
set(PUBLIC_INCLUDES
${PROJECT_SOURCE_DIR}/include/Hacl_NaCl.h
Expand Down Expand Up @@ -354,8 +354,8 @@ set(PUBLIC_INCLUDES
${PROJECT_SOURCE_DIR}/include/EverCrypt_Chacha20Poly1305.h
${PROJECT_SOURCE_DIR}/include/EverCrypt_Poly1305.h
${PROJECT_SOURCE_DIR}/include/EverCrypt_AEAD.h
${PROJECT_SOURCE_DIR}/include/Hacl_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_SHA3_Vec256.h
${PROJECT_SOURCE_DIR}/include/Hacl_Hash_SHA3_Scalar.h
${PROJECT_SOURCE_DIR}/include/Hacl_Hash_SHA3_Simd256.h
)
set(ALGORITHMS
nacl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/


#ifndef __Hacl_SHA3_Scalar_H
#define __Hacl_SHA3_Scalar_H
#ifndef __Hacl_Hash_SHA3_Scalar_H
#define __Hacl_Hash_SHA3_Scalar_H

#if defined(__cplusplus)
extern "C" {
Expand All @@ -36,32 +36,32 @@ extern "C" {
#include "krml/internal/target.h"

void
Hacl_SHA3_Scalar_shake128_hacl(
Hacl_Hash_SHA3_Scalar_shake128(
uint32_t inputByteLen,
uint8_t *input,
uint32_t outputByteLen,
uint8_t *output
);

void
Hacl_SHA3_Scalar_shake256_hacl(
Hacl_Hash_SHA3_Scalar_shake256(
uint32_t inputByteLen,
uint8_t *input,
uint32_t outputByteLen,
uint8_t *output
);

void Hacl_SHA3_Scalar_sha3_224(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
void Hacl_Hash_SHA3_Scalar_sha3_224(uint32_t inputByteLen, uint8_t *input, uint8_t *output);

void Hacl_SHA3_Scalar_sha3_256(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
void Hacl_Hash_SHA3_Scalar_sha3_256(uint32_t inputByteLen, uint8_t *input, uint8_t *output);

void Hacl_SHA3_Scalar_sha3_384(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
void Hacl_Hash_SHA3_Scalar_sha3_384(uint32_t inputByteLen, uint8_t *input, uint8_t *output);

void Hacl_SHA3_Scalar_sha3_512(uint32_t inputByteLen, uint8_t *input, uint8_t *output);
void Hacl_Hash_SHA3_Scalar_sha3_512(uint32_t inputByteLen, uint8_t *input, uint8_t *output);

#if defined(__cplusplus)
}
#endif

#define __Hacl_SHA3_Scalar_H_DEFINED
#define __Hacl_Hash_SHA3_Scalar_H_DEFINED
#endif
Loading
Loading