1
1
mirror da https://github.com/henrydcase/pqc.git synced 2024-11-22 07:35:38 +00:00
This commit is contained in:
Henry Case 2023-02-14 23:17:15 +00:00
parent e7b5cfe9f8
commit 150f905b41
6 ha cambiato i file con 83 aggiunte e 10 eliminazioni

Vedi File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(cryptocore VERSION 0.0.1 LANGUAGES C)
project(pqc VERSION 0.0.1 LANGUAGES C)
include(FetchContent)
include(ExternalProject)
@ -138,7 +138,7 @@ include(.cmake/common.mk)
# Control Debug/Release mode
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -g3 -O0 -Wno-unused")
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -g3 -O0")
endif()
# Set CPU architecture
@ -184,17 +184,17 @@ if(PQC_WEAK_RANDOMBYTES)
endif()
# Build CPU features
set(CMAKE_C_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "$${PQC_CMAKE_C_CXX_FLAGS} {EXTRA_C_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-O0")
set(CMAKE_CXX_FLAGS "${PQC_CMAKE_C_CXX_FLAGS}")
set(BUILD_PIC ON CACHE BOOL "")
add_subdirectory(3rd/cpu_features)
# PQC library
# Set C, CXX, and LD flags
if(NOT CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wpedantic")
set(CMAKE_C_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
endif()
string(APPEND LDFLAGS "${EXTRA_LDFLAGS}")
include_directories(
public
@ -378,8 +378,8 @@ set(GOOGLETEST_PATH "${CMAKE_SOURCE_DIR}/3rd/gtest" CACHE PATH "Path to the gtes
#endif()
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
set(CMAKE_C_FLAGS "${EXTRA_C_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${EXTRA_C_CXX_FLAGS}")
#set(CMAKE_C_FLAGS "${EXTRA_C_CXX_FLAGS}")
#set(CMAKE_CXX_FLAGS "${EXTRA_C_CXX_FLAGS}")
if (MEMSAN)
set(BENCHMARK_USE_LIBCXX ON CACHE BOOL "" FORCE)
# Since build requires C++20 it is safe to assume that std::regex is available.

Vedi File

@ -38,6 +38,23 @@ extern "C" {
(((uint16_t)(x)[0])<<8 | \
((uint16_t)(x)[1])<<0) \
//#if !defined(NDEBUG)
#include <stdio.h>
static inline void dump_buffer_hex(FILE *f, int ind, const void* data, size_t size) {
if (!f) {
f = stdout;
}
fprintf(f, "%*s", ind, " ");
for (size_t i = 0; i < size; ++i) {
fprintf(f, "%02X:", ((uint8_t*)data)[i]);
if ((i+1) % 32 == 0 || i+1 == size) {
fprintf(f, "\n%*s", ind, " ");
}
}
fprintf(f,"\n");
}
//#endif
#ifdef __cplusplus
const cpu_features::X86Features*
#else

Vedi File

@ -5,6 +5,7 @@
#include "rounding.h"
#include "symmetric.h"
#include <stdint.h>
#include "utils.h"
#define DBENCH_START()
#define DBENCH_STOP(t)
@ -464,6 +465,7 @@ void PQCLEAN_DILITHIUM2_CLEAN_poly_uniform_gamma1(poly *a,
stream256_init(&state, seed, nonce);
stream256_squeezeblocks(buf, POLY_UNIFORM_GAMMA1_NBLOCKS, &state);
stream256_release(&state);
dump_buffer_hex(0,0,buf,4);
PQCLEAN_DILITHIUM2_CLEAN_polyz_unpack(a, buf);
}

Vedi File

@ -7,6 +7,7 @@
#include "sign.h"
#include "symmetric.h"
#include <stdint.h>
#include "utils.h"
/*************************************************
* Name: PQCLEAN_DILITHIUM2_CLEAN_crypto_sign_keypair
@ -116,6 +117,8 @@ int PQCLEAN_DILITHIUM2_CLEAN_crypto_sign_signature(uint8_t *sig,
rej:
/* Sample intermediate vector y */
dump_buffer_hex(0,0,rhoprime,64);
PQCLEAN_DILITHIUM2_CLEAN_polyvecl_uniform_gamma1(&y, rhoprime, nonce++);
/* Matrix-vector multiplication */
@ -129,6 +132,7 @@ rej:
PQCLEAN_DILITHIUM2_CLEAN_polyveck_caddq(&w1);
PQCLEAN_DILITHIUM2_CLEAN_polyveck_decompose(&w1, &w0, &w1);
PQCLEAN_DILITHIUM2_CLEAN_polyveck_pack_w1(sig, &w1);
dump_buffer_hex(0, 4, sig, 10);
shake256_inc_init(&state);
shake256_inc_absorb(&state, mu, CRHBYTES);

Vedi File

@ -74,7 +74,6 @@ static void BenchKeyPair(benchmark::State &st) {
static void BenchSign(benchmark::State &st) {
int64_t t, total = 0;
struct pqcl_asym_t *key_pair = nullptr;
uint32_t id = st.range(0);
uint8_t msg[2048] = {0};
const pqc_ctx_t *ctx;
@ -96,7 +95,6 @@ static void BenchSign(benchmark::State &st) {
static void BenchVerify(benchmark::State &st) {
int64_t t, total = 0;
struct pqcl_asym_t *key_pair = nullptr;
uint32_t id = st.range(0);
const pqc_ctx_t *ctx;
uint8_t msg[2048] = {0};

File diff soppresso perché una o più righe sono troppo lunghe