From 38c47f7d9fb8599a452f5f2c64ecf4ff1d46d231 Mon Sep 17 00:00:00 2001 From: Christian Paquin Date: Fri, 27 Mar 2020 10:49:43 -0400 Subject: [PATCH] Properly namespace the picnic internal functions (#676) * Properly namespaced the picnic internal functions * Added namespacing for KeccakWidth1600times4 functions. * Namespace KeccakWidth1600times4 sponge structure. * Merged macro files and namespaced assembly files. * Namespaced .name statemetns in avx2 assembly files * Fixed macro include paths * Un-namespaced KeccakP1600_AddByte because it is sometimes defined as a macro. * Namespace function call in assembly. --- src/sig/picnic/external/oqs_picnic_macros.h | 52 +++++++++++ src/sig/picnic/external/picnic_instances.h | 2 + src/sig/picnic/external/sha3/KeccakHash.h | 2 + .../external/sha3/KeccakSpongeWidth1600.c | 2 +- .../external/sha3/KeccakSpongeWidth1600.h | 8 +- .../sha3/KeccakSpongeWidth1600times4.c | 2 +- .../sha3/KeccakSpongeWidth1600times4.h | 4 +- .../armv8a-neon/KeccakP-1600-armv8a-neon.s | 40 ++++---- .../armv8a-neon/KeccakP-1600-times4-on1.c | 2 +- .../external/sha3/avx2/KeccakP-1600-AVX2.s | 92 +++++++++---------- .../external/sha3/avx2/KeccakP-1600-SnP.h | 1 + .../sha3/opt64/KeccakP-1600-times4-on1.c | 2 +- src/sig/picnic/sig_picnic.c | 1 + tests/test_namespace.py | 4 +- 14 files changed, 136 insertions(+), 78 deletions(-) diff --git a/src/sig/picnic/external/oqs_picnic_macros.h b/src/sig/picnic/external/oqs_picnic_macros.h index 69160043b..63676cc1d 100644 --- a/src/sig/picnic/external/oqs_picnic_macros.h +++ b/src/sig/picnic/external/oqs_picnic_macros.h @@ -215,5 +215,57 @@ #define verify_picnic2 oqs_sig_picnic_verify_picnic2 #define xor_array_RC oqs_sig_picnic_xor_array_RC #define xor_word_array oqs_sig_picnic_xor_word_array +#define BitLength oqs_sig_picnic_BitLength +#define BitSequence oqs_sig_picnic_BitSequence +#define HashReturn oqs_sig_picnic_HashReturn +#define KeccakF1600_FastLoop_Absorb oqs_sig_picnic_KeccakF1600_FastLoop_Absorb +#define KeccakP1600_AddBytes oqs_sig_picnic_KeccakP1600_AddBytes +#define KeccakP1600_AddBytesInLane oqs_sig_picnic_KeccakP1600_AddBytesInLane +#define KeccakP1600_AddLanes oqs_sig_picnic_KeccakP1600_AddLanes +#define KeccakP1600_ExtractAndAddBytes oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes +#define KeccakP1600_ExtractAndAddBytesInLane oqs_sig_picnic_KeccakP1600_ExtractAndAddBytesInLane +#define KeccakP1600_ExtractAndAddLanes oqs_sig_picnic_KeccakP1600_ExtractAndAddLanes +#define KeccakP1600_ExtractBytes oqs_sig_picnic_KeccakP1600_ExtractBytes +#define KeccakP1600_ExtractBytesInLane oqs_sig_picnic_KeccakP1600_ExtractBytesInLane +#define KeccakP1600_ExtractLanes oqs_sig_picnic_KeccakP1600_ExtractLanes +#define KeccakP1600_Initialize oqs_sig_picnic_KeccakP1600_Initialize +#define KeccakP1600_OverwriteBytes oqs_sig_picnic_KeccakP1600_OverwriteBytes +#define KeccakP1600_OverwriteBytesInLane oqs_sig_picnic_KeccakP1600_OverwriteBytesInLane +#define KeccakP1600_OverwriteLanes oqs_sig_picnic_KeccakP1600_OverwriteLanes +#define KeccakP1600_OverwriteWithZeroes oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes +#define KeccakP1600_Permute_24rounds oqs_sig_picnic_KeccakP1600_Permute_24rounds +#define KeccakP1600_Permute_Nrounds oqs_sig_picnic_KeccakP1600_Permute_Nrounds +#define KeccakWidth1600_Sponge oqs_sig_picnic_KeccakWidth1600_Sponge +#define KeccakWidth1600_SpongeAbsorb oqs_sig_picnic_KeccakWidth1600_SpongeAbsorb +#define KeccakWidth1600_SpongeAbsorbLastFewBits oqs_sig_picnic_KeccakWidth1600_SpongeAbsorbLastFewBits +#define KeccakWidth1600_SpongeInitialize oqs_sig_picnic_KeccakWidth1600_SpongeInitialize +#define KeccakWidth1600_SpongeInstance oqs_sig_picnic_KeccakWidth1600_SpongeInstance +#define KeccakWidth1600_SpongeSqueeze oqs_sig_picnic_KeccakWidth1600_SpongeSqueeze +#define KeccakWidth1600times4_Sponge oqs_sig_picnic_KeccakWidth1600times4_Sponge +#define KeccakWidth1600times4_SpongeAbsorb oqs_sig_picnic_KeccakWidth1600times4_SpongeAbsorb +#define KeccakWidth1600times4_SpongeAbsorbLastFewBits oqs_sig_picnic_KeccakWidth1600times4_SpongeAbsorbLastFewBits +#define KeccakWidth1600times4_SpongeInitialize oqs_sig_picnic_KeccakWidth1600times4_SpongeInitialize +#define KeccakWidth1600times4_SpongeInstance oqs_sig_picnic_KeccakWidth1600times4_SpongeInstance +#define KeccakWidth1600times4_SpongeSqueeze oqs_sig_picnic_KeccakWidth1600times4_SpongeSqueeze +#define Keccak_HashFinal oqs_sig_picnic_Keccak_HashFinal +#define Keccak_HashInitialize oqs_sig_picnic_Keccak_HashInitialize +#define Keccak_HashInstance oqs_sig_picnic_Keccak_HashInstance +#define Keccak_HashSqueeze oqs_sig_picnic_Keccak_HashSqueeze +#define Keccak_HashUpdate oqs_sig_picnic_Keccak_HashUpdate +#define picnic_get_lowmc_block_size oqs_sig_picnic_get_lowmc_block_size +#define picnic_get_param_name oqs_sig_picnic_get_param_name +#define picnic_get_private_key_size oqs_sig_picnic_get_private_key_size +#define picnic_get_public_key_size oqs_sig_picnic_get_public_key_size +#define picnic_keygen oqs_sig_picnic_keygen +#define picnic_read_private_key oqs_sig_picnic_read_private_key +#define picnic_read_public_key oqs_sig_picnic_read_public_key +#define picnic_sign oqs_sig_picnic_sign +#define picnic_signature_size oqs_sig_picnic_signature_size +#define picnic_sk_to_pk oqs_sig_picnic_sk_to_pk +#define picnic_validate_keypair oqs_sig_picnic_validate_keypair +#define picnic_verify oqs_sig_picnic_verify +#define picnic_write_private_key oqs_sig_picnic_write_private_key +#define picnic_write_public_key oqs_sig_picnic_write_public_key +#define picnic_instance_get oqs_sig_picnic_instance_get #endif diff --git a/src/sig/picnic/external/picnic_instances.h b/src/sig/picnic/external/picnic_instances.h index 5f8614d80..34fd2be2b 100644 --- a/src/sig/picnic/external/picnic_instances.h +++ b/src/sig/picnic/external/picnic_instances.h @@ -10,6 +10,8 @@ #ifndef PICNIC_INSTANCES_H #define PICNIC_INSTANCES_H +#include "oqs_picnic_macros.h" + #include "lowmc.h" #if defined(WITH_ZKBPP) #include "mpc_lowmc.h" diff --git a/src/sig/picnic/external/sha3/KeccakHash.h b/src/sig/picnic/external/sha3/KeccakHash.h index ac7b8e4b6..457770274 100644 --- a/src/sig/picnic/external/sha3/KeccakHash.h +++ b/src/sig/picnic/external/sha3/KeccakHash.h @@ -14,6 +14,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ #ifndef _KeccakHashInterface_h_ #define _KeccakHashInterface_h_ +#include "../../oqs_picnic_macros.h" + #ifndef KeccakP1600_excluded #include "KeccakSpongeWidth1600.h" diff --git a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.c b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.c index a1f2cddc3..0724e3c36 100644 --- a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.c +++ b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.c @@ -20,7 +20,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ #ifndef KeccakP1600_excluded #include "KeccakP-1600-SnP.h" - #define prefix KeccakWidth1600 + #define prefix oqs_sig_picnic_KeccakWidth1600 #define SnP KeccakP1600 #define SnP_width 1600 #define SnP_Permute KeccakP1600_Permute_24rounds diff --git a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.h b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.h index 1558256cd..ba5db41c5 100644 --- a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.h +++ b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600.h @@ -18,14 +18,14 @@ http://creativecommons.org/publicdomain/zero/1.0/ #ifndef KeccakP1600_excluded #include "KeccakP-1600-SnP.h" - KCP_DeclareSpongeStructure(KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) - KCP_DeclareSpongeFunctions(KeccakWidth1600) + KCP_DeclareSpongeStructure(oqs_sig_picnic_KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) + KCP_DeclareSpongeFunctions(oqs_sig_picnic_KeccakWidth1600) #endif #ifndef KeccakP1600_excluded #include "KeccakP-1600-SnP.h" - KCP_DeclareSpongeStructure(KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) - KCP_DeclareSpongeFunctions(KeccakWidth1600_12rounds) + KCP_DeclareSpongeStructure(oqs_sig_picnic_KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) + KCP_DeclareSpongeFunctions(oqs_sig_picnic_KeccakWidth1600_12rounds) #endif #endif diff --git a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.c b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.c index efcaed62f..7265be2ad 100644 --- a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.c +++ b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.c @@ -17,7 +17,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ #ifndef KeccakP1600times4_excluded #include "KeccakP-1600-times4-SnP.h" -#define prefix KeccakWidth1600times4 +#define prefix oqs_sig_picnic_KeccakWidth1600times4 #define PlSnP KeccakP1600times4 #define PlSnP_width 1600 #define PlSnP_Permute KeccakP1600times4_PermuteAll_24rounds diff --git a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.h b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.h index 558b69760..66a6dd398 100644 --- a/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.h +++ b/src/sig/picnic/external/sha3/KeccakSpongeWidth1600times4.h @@ -33,8 +33,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ #ifndef KeccakP1600times4_excluded #include "KeccakP-1600-times4-SnP.h" - KCP_DeclareSpongeStructuretimes4(KeccakWidth1600times4, KeccakP1600times4_statesSizeInBytes, KeccakP1600times4_statesAlignment) - KCP_DeclareSpongeFunctionstimes4(KeccakWidth1600times4) + KCP_DeclareSpongeStructuretimes4(oqs_sig_picnic_KeccakWidth1600times4, KeccakP1600times4_statesSizeInBytes, KeccakP1600times4_statesAlignment) + KCP_DeclareSpongeFunctionstimes4(oqs_sig_picnic_KeccakWidth1600times4) #endif #endif diff --git a/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-armv8a-neon.s b/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-armv8a-neon.s index f9477b018..7697ab38b 100644 --- a/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-armv8a-neon.s +++ b/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-armv8a-neon.s @@ -253,8 +253,8 @@ KeccakP1600_Permute_RoundConstants0: // void KeccakP1600_Initialize(void *state) // .align 8 -.global KeccakP1600_Initialize -KeccakP1600_Initialize: +.global oqs_sig_picnic_KeccakP1600_Initialize +oqs_sig_picnic_KeccakP1600_Initialize: movi v0.2d, #0 movi v1.2d, #0 movi v2.2d, #0 @@ -284,8 +284,8 @@ KeccakP1600_AddByte: // void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length) // .align 8 -.global KeccakP1600_AddBytes -KeccakP1600_AddBytes: +.global oqs_sig_picnic_KeccakP1600_AddBytes +oqs_sig_picnic_KeccakP1600_AddBytes: add x0, x0, x2 subs w4, w3, #1 b.cc KeccakP1600_AddBytes_Exit // length 0, move along @@ -328,8 +328,8 @@ KeccakP1600_AddBytes_Exit: // void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length) // .align 8 -.global KeccakP1600_OverwriteBytes -KeccakP1600_OverwriteBytes: +.global oqs_sig_picnic_KeccakP1600_OverwriteBytes +oqs_sig_picnic_KeccakP1600_OverwriteBytes: add x0, x0, x2 subs w4, w3, #1 b.cc KeccakP1600_OverwriteBytes_Exit @@ -364,8 +364,8 @@ KeccakP1600_OverwriteBytes_Exit: // void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount) // .align 8 -.global KeccakP1600_OverwriteWithZeroes -KeccakP1600_OverwriteWithZeroes: +.global oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes +oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes: subs w2, w1, #1 b.cc KeccakP1600_OverwriteWithZeroes_Exit movi v0.2d, #0 @@ -401,8 +401,8 @@ KeccakP1600_OverwriteWithZeroes_Exit: // void KeccakP1600_ExtractBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length) // .align 8 -.global KeccakP1600_ExtractBytes -KeccakP1600_ExtractBytes: +.global oqs_sig_picnic_KeccakP1600_ExtractBytes +oqs_sig_picnic_KeccakP1600_ExtractBytes: add x0, x0, x2 subs w4, w3, #1 b.cc KeccakP1600_ExtractBytes_Exit @@ -437,8 +437,8 @@ KeccakP1600_ExtractBytes_Exit: // void KeccakP800_ExtractAndAddBytes(void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length) // .align 8 -.global KeccakP1600_ExtractAndAddBytes -KeccakP1600_ExtractAndAddBytes: +.global oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes +oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes: add x0, x0, x3 subs w5, w4, #1 b.cc KeccakP1600_ExtractAndAddBytes_Exit @@ -481,8 +481,8 @@ KeccakP1600_ExtractAndAddBytes_Exit: // void KeccakP1600_Permute_Nrounds( void *state, unsigned int nrounds ) // .align 8 -.global KeccakP1600_Permute_Nrounds -KeccakP1600_Permute_Nrounds: +.global oqs_sig_picnic_KeccakP1600_Permute_Nrounds +oqs_sig_picnic_KeccakP1600_Permute_Nrounds: mov x2, x1 adr x1, KeccakP1600_Permute_RoundConstants0 lsl x3, x2, #3 @@ -494,8 +494,8 @@ KeccakP1600_Permute_Nrounds: // void KeccakP1600_Permute_12rounds( void *state ) // .align 8 -.global KeccakP1600_Permute_12rounds -KeccakP1600_Permute_12rounds: +.global oqs_sig_picnic_KeccakP1600_Permute_12rounds +oqs_sig_picnic_KeccakP1600_Permute_12rounds: adr x1, KeccakP1600_Permute_RoundConstants12 mov x2, #12 b KeccakP1600_Permute @@ -506,8 +506,8 @@ KeccakP1600_Permute_12rounds: // void KeccakP1600_Permute_24rounds( void *state ) // .align 8 -.global KeccakP1600_Permute_24rounds -KeccakP1600_Permute_24rounds: +.global oqs_sig_picnic_KeccakP1600_Permute_24rounds +oqs_sig_picnic_KeccakP1600_Permute_24rounds: adr x1, KeccakP1600_Permute_RoundConstants24 mov x2, #24 b KeccakP1600_Permute @@ -517,8 +517,8 @@ KeccakP1600_Permute_24rounds: // void KeccakP1600_Permute( void *state, uint64_t *rc, unsigned int nrounds ) // .align 8 -.global KeccakP1600_Permute -KeccakP1600_Permute: +.global oqs_sig_picnic_KeccakP1600_Permute +oqs_sig_picnic_KeccakP1600_Permute: LoadState KeccakP1600_Permute_RoundLoop: KeccakRound diff --git a/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-times4-on1.c b/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-times4-on1.c index 3855fb472..adf828088 100644 --- a/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-times4-on1.c +++ b/src/sig/picnic/external/sha3/armv8a-neon/KeccakP-1600-times4-on1.c @@ -21,7 +21,7 @@ Please refer to LowLevel.build for the exact list of other files it must be comb #include "KeccakP-1600-SnP.h" -#define prefix KeccakP1600times4 +#define prefix oqs_sig_picnic_KeccakP1600times4 #define PlSnP_baseParallelism 1 #define PlSnP_targetParallelism 4 #define SnP_laneLengthInBytes 8 diff --git a/src/sig/picnic/external/sha3/avx2/KeccakP-1600-AVX2.s b/src/sig/picnic/external/sha3/avx2/KeccakP-1600-AVX2.s index 803e86b32..8e44faaf4 100644 --- a/src/sig/picnic/external/sha3/avx2/KeccakP-1600-AVX2.s +++ b/src/sig/picnic/external/sha3/avx2/KeccakP-1600-AVX2.s @@ -17,11 +17,11 @@ # # void KeccakP1600_Initialize(void *state); # -.globl KeccakP1600_Initialize -.hidden KeccakP1600_Initialize -.type KeccakP1600_Initialize,@function +.globl oqs_sig_picnic_KeccakP1600_Initialize +.hidden oqs_sig_picnic_KeccakP1600_Initialize +.type oqs_sig_picnic_KeccakP1600_Initialize,@function .align 32 -KeccakP1600_Initialize: +oqs_sig_picnic_KeccakP1600_Initialize: vpxor %ymm0,%ymm0,%ymm0 vmovdqa %ymm0,0*32(%rdi) vmovdqa %ymm0,1*32(%rdi) @@ -31,7 +31,7 @@ KeccakP1600_Initialize: vmovdqa %ymm0,5*32(%rdi) movq $0,6*32(%rdi) ret -.size KeccakP1600_Initialize,.-KeccakP1600_Initialize +.size oqs_sig_picnic_KeccakP1600_Initialize,.-oqs_sig_picnic_KeccakP1600_Initialize # ----------------------------------------------------------------------------- # @@ -59,11 +59,11 @@ KeccakP1600_AddByte: # void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length); # %rdi %rsi %rdx %rcx # -.globl KeccakP1600_AddBytes -.hidden KeccakP1600_AddBytes -.type KeccakP1600_AddBytes,@function +.globl oqs_sig_picnic_KeccakP1600_AddBytes +.hidden oqs_sig_picnic_KeccakP1600_AddBytes +.type oqs_sig_picnic_KeccakP1600_AddBytes,@function .align 32 -KeccakP1600_AddBytes: +oqs_sig_picnic_KeccakP1600_AddBytes: cmp $0, %rcx jz KeccakP1600_AddBytes_Exit mov %rdx, %rax # rax offset in lane @@ -112,18 +112,18 @@ KeccakP1600_AddBytes_LastIncompleteLaneLoop: jnz KeccakP1600_AddBytes_LastIncompleteLaneLoop KeccakP1600_AddBytes_Exit: ret -.size KeccakP1600_AddBytes,.-KeccakP1600_AddBytes +.size oqs_sig_picnic_KeccakP1600_AddBytes,.-oqs_sig_picnic_KeccakP1600_AddBytes # ----------------------------------------------------------------------------- # # void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length); # %rdi %rsi %rdx %rcx # -.globl KeccakP1600_OverwriteBytes -.hidden KeccakP1600_OverwriteBytes -.type KeccakP1600_OverwriteBytes,@function +.globl oqs_sig_picnic_KeccakP1600_OverwriteBytes +.hidden oqs_sig_picnic_KeccakP1600_OverwriteBytes +.type oqs_sig_picnic_KeccakP1600_OverwriteBytes,@function .align 32 -KeccakP1600_OverwriteBytes: +oqs_sig_picnic_KeccakP1600_OverwriteBytes: cmp $0, %rcx jz KeccakP1600_OverwriteBytes_Exit mov %rdx, %rax # rax offset in lane @@ -172,18 +172,18 @@ KeccakP1600_OverwriteBytes_LastIncompleteLaneLoop: jnz KeccakP1600_OverwriteBytes_LastIncompleteLaneLoop KeccakP1600_OverwriteBytes_Exit: ret -.size KeccakP1600_OverwriteBytes,.-KeccakP1600_OverwriteBytes +.size oqs_sig_picnic_KeccakP1600_OverwriteBytes,.-oqs_sig_picnic_KeccakP1600_OverwriteBytes # ----------------------------------------------------------------------------- # # void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount); # %rdi %rsi # -.globl KeccakP1600_OverwriteWithZeroes -.hidden KeccakP1600_OverwriteWithZeroes -.type KeccakP1600_OverwriteWithZeroes,@function +.globl oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes +.hidden oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes +.type oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes,@function .align 32 -KeccakP1600_OverwriteWithZeroes: +oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes: cmp $0, %rsi jz KeccakP1600_OverwriteWithZeroes_Exit lea mapState(%rip), %rdx # rdx pointer into state index mapper @@ -208,18 +208,18 @@ KeccakP1600_OverwriteWithZeroes_LastIncompleteLaneLoop: jnz KeccakP1600_OverwriteWithZeroes_LastIncompleteLaneLoop KeccakP1600_OverwriteWithZeroes_Exit: ret -.size KeccakP1600_OverwriteWithZeroes,.-KeccakP1600_OverwriteWithZeroes +.size oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes,.-oqs_sig_picnic_KeccakP1600_OverwriteWithZeroes # ----------------------------------------------------------------------------- # # void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length); # %rdi %rsi %rdx %rcx # -.globl KeccakP1600_ExtractBytes -.hidden KeccakP1600_ExtractBytes -.type KeccakP1600_ExtractBytes,@function +.globl oqs_sig_picnic_KeccakP1600_ExtractBytes +.hidden oqs_sig_picnic_KeccakP1600_ExtractBytes +.type oqs_sig_picnic_KeccakP1600_ExtractBytes,@function .align 32 -KeccakP1600_ExtractBytes: +oqs_sig_picnic_KeccakP1600_ExtractBytes: push %rbx cmp $0, %rcx jz KeccakP1600_ExtractBytes_Exit @@ -271,18 +271,18 @@ KeccakP1600_ExtractBytes_LastIncompleteLaneLoop: KeccakP1600_ExtractBytes_Exit: pop %rbx ret -.size KeccakP1600_ExtractBytes,.-KeccakP1600_ExtractBytes +.size oqs_sig_picnic_KeccakP1600_ExtractBytes,.-oqs_sig_picnic_KeccakP1600_ExtractBytes # ----------------------------------------------------------------------------- # # void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length); # %rdi %rsi %rdx %rcx %r8 # -.globl KeccakP1600_ExtractAndAddBytes -.hidden KeccakP1600_ExtractAndAddBytes -.type KeccakP1600_ExtractAndAddBytes,@function +.globl oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes +.hidden oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes +.type oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes,@function .align 32 -KeccakP1600_ExtractAndAddBytes: +oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes: push %rbx push %r10 cmp $0, %r8 @@ -342,7 +342,7 @@ KeccakP1600_ExtractAndAddBytes_Exit: pop %r10 pop %rbx ret -.size KeccakP1600_ExtractAndAddBytes,.-KeccakP1600_ExtractAndAddBytes +.size oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes,.-oqs_sig_picnic_KeccakP1600_ExtractAndAddBytes # ----------------------------------------------------------------------------- # @@ -492,11 +492,11 @@ __KeccakF1600: -.globl KeccakP1600_Permute_24rounds -.hidden KeccakP1600_Permute_24rounds -.type KeccakP1600_Permute_24rounds,@function +.globl oqs_sig_picnic_KeccakP1600_Permute_24rounds +.hidden oqs_sig_picnic_KeccakP1600_Permute_24rounds +.type oqs_sig_picnic_KeccakP1600_Permute_24rounds,@function .align 32 -KeccakP1600_Permute_24rounds: +oqs_sig_picnic_KeccakP1600_Permute_24rounds: lea rhotates_left+96(%rip),%r8 lea rhotates_right+96(%rip),%r9 lea iotas(%rip),%r10 @@ -520,13 +520,13 @@ KeccakP1600_Permute_24rounds: vmovdqu %ymm6,8+32*5-96(%rdi) vzeroupper ret -.size KeccakP1600_Permute_24rounds,.-KeccakP1600_Permute_24rounds +.size oqs_sig_picnic_KeccakP1600_Permute_24rounds,.-oqs_sig_picnic_KeccakP1600_Permute_24rounds -.globl KeccakP1600_Permute_Nrounds -.hidden KeccakP1600_Permute_Nrounds -.type KeccakP1600_Permute_Nrounds,@function +.globl oqs_sig_picnic_KeccakP1600_Permute_Nrounds +.hidden oqs_sig_picnic_KeccakP1600_Permute_Nrounds +.type oqs_sig_picnic_KeccakP1600_Permute_Nrounds,@function .align 32 -KeccakP1600_Permute_Nrounds: +oqs_sig_picnic_KeccakP1600_Permute_Nrounds: lea rhotates_left+96(%rip),%r8 lea rhotates_right+96(%rip),%r9 lea iotas+24*4*8(%rip),%r10 @@ -552,18 +552,18 @@ KeccakP1600_Permute_Nrounds: vmovdqu %ymm6,8+32*5-96(%rdi) vzeroupper ret -.size KeccakP1600_Permute_Nrounds,.-KeccakP1600_Permute_Nrounds +.size oqs_sig_picnic_KeccakP1600_Permute_Nrounds,.-oqs_sig_picnic_KeccakP1600_Permute_Nrounds # ----------------------------------------------------------------------------- # # size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen); # %rdi %rsi %rdx %rcx # -.globl KeccakF1600_FastLoop_Absorb -.hidden KeccakF1600_FastLoop_Absorb -.type KeccakF1600_FastLoop_Absorb,@function +.globl oqs_sig_picnic_KeccakF1600_FastLoop_Absorb +.hidden oqs_sig_picnic_KeccakF1600_FastLoop_Absorb +.type oqs_sig_picnic_KeccakF1600_FastLoop_Absorb,@function .align 32 -KeccakF1600_FastLoop_Absorb: +oqs_sig_picnic_KeccakF1600_FastLoop_Absorb: push %rbx push %r10 shr $3, %rcx # rcx = data length in lanes @@ -714,7 +714,7 @@ KeccakF1600_FastLoop_Absorb_LanesAddLoop: push %rsi push %rdx push %rcx - call KeccakP1600_Permute_24rounds@PLT + call oqs_sig_picnic_KeccakP1600_Permute_24rounds@PLT pop %rcx pop %rdx pop %rsi @@ -722,7 +722,7 @@ KeccakF1600_FastLoop_Absorb_LanesAddLoop: cmp %rsi, %rcx jae KeccakF1600_FastLoop_Absorb_Not17Lanes jmp KeccakF1600_FastLoop_Absorb_Exit -.size KeccakF1600_FastLoop_Absorb,.-KeccakF1600_FastLoop_Absorb +.size oqs_sig_picnic_KeccakF1600_FastLoop_Absorb,.-oqs_sig_picnic_KeccakF1600_FastLoop_Absorb .equ ALLON, 0xFFFFFFFFFFFFFFFF diff --git a/src/sig/picnic/external/sha3/avx2/KeccakP-1600-SnP.h b/src/sig/picnic/external/sha3/avx2/KeccakP-1600-SnP.h index 8854b9c7f..e3f9aec56 100644 --- a/src/sig/picnic/external/sha3/avx2/KeccakP-1600-SnP.h +++ b/src/sig/picnic/external/sha3/avx2/KeccakP-1600-SnP.h @@ -17,6 +17,7 @@ Please refer to SnP-documentation.h for more details. #define _KeccakP_1600_SnP_h_ #include +#include "oqs_picnic_macros.h" #define KeccakP1600_implementation "AVX2 optimized implementation" #define KeccakP1600_stateSizeInBytes 200 diff --git a/src/sig/picnic/external/sha3/opt64/KeccakP-1600-times4-on1.c b/src/sig/picnic/external/sha3/opt64/KeccakP-1600-times4-on1.c index 3855fb472..adf828088 100644 --- a/src/sig/picnic/external/sha3/opt64/KeccakP-1600-times4-on1.c +++ b/src/sig/picnic/external/sha3/opt64/KeccakP-1600-times4-on1.c @@ -21,7 +21,7 @@ Please refer to LowLevel.build for the exact list of other files it must be comb #include "KeccakP-1600-SnP.h" -#define prefix KeccakP1600times4 +#define prefix oqs_sig_picnic_KeccakP1600times4 #define PlSnP_baseParallelism 1 #define PlSnP_targetParallelism 4 #define SnP_laneLengthInBytes 8 diff --git a/src/sig/picnic/sig_picnic.c b/src/sig/picnic/sig_picnic.c index 6c33bbb29..40fc808d8 100644 --- a/src/sig/picnic/sig_picnic.c +++ b/src/sig/picnic/sig_picnic.c @@ -5,6 +5,7 @@ #include #include #include "sig_picnic.h" +#include "oqs_picnic_macros.h" #include "external/picnic.h" static size_t PRIV_KEY_LEN[] = { diff --git a/tests/test_namespace.py b/tests/test_namespace.py index 3d7243b69..2a80cb76f 100644 --- a/tests/test_namespace.py +++ b/tests/test_namespace.py @@ -23,8 +23,8 @@ def test_namespace(use_liboqs_so): if ' T ' in line or ' D ' in line or ' S ' in line: symbols.append(line) - # ideally this would be just ['oqs', 'pqclean'] but the Picnic implementation has a few more symbols - namespaces = ['oqs', 'pqclean', 'keccak', 'picnic', 'aligned_alloc', 'aligned_free'] + # ideally this would be just ['oqs', 'pqclean'] + namespaces = ['oqs', 'pqclean', 'keccak', 'aligned_alloc', 'aligned_free'] non_namespaced = [] for symbolstr in symbols: