/* Implementation by Gilles Van Assche, hereby denoted as "the implementer". For more information, feedback or questions, please refer to our website: https://keccak.team/ To the extent possible under law, the implementer has waived all copyright and related or neighboring rights to the source code in this file. http://creativecommons.org/publicdomain/zero/1.0/ --- This file contains macros that help make a PlSnP-compatible implementation by serially falling back on a SnP-compatible implementation or on a PlSnP-compatible implementation of lower parallism degree. Please refer to PlSnP-documentation.h for more details. */ /* expect PlSnP_baseParallelism, PlSnP_targetParallelism */ /* expect SnP_stateSizeInBytes, SnP_stateAlignment */ /* expect prefix */ /* expect SnP_* */ #define JOIN0(a, b) a ## b #define JOIN(a, b) JOIN0(a, b) #define PlSnP_StaticInitialize JOIN(prefix, _StaticInitialize) #define PlSnP_InitializeAll JOIN(prefix, _InitializeAll) #define PlSnP_AddByte JOIN(prefix, _AddByte) #define PlSnP_AddBytes JOIN(prefix, _AddBytes) #define PlSnP_AddLanesAll JOIN(prefix, _AddLanesAll) #define PlSnP_OverwriteBytes JOIN(prefix, _OverwriteBytes) #define PlSnP_OverwriteLanesAll JOIN(prefix, _OverwriteLanesAll) #define PlSnP_OverwriteWithZeroes JOIN(prefix, _OverwriteWithZeroes) #define PlSnP_ExtractBytes JOIN(prefix, _ExtractBytes) #define PlSnP_ExtractLanesAll JOIN(prefix, _ExtractLanesAll) #define PlSnP_ExtractAndAddBytes JOIN(prefix, _ExtractAndAddBytes) #define PlSnP_ExtractAndAddLanesAll JOIN(prefix, _ExtractAndAddLanesAll) #if (PlSnP_baseParallelism == 1) #define SnP_stateSizeInBytes JOIN(SnP, _stateSizeInBytes) #define SnP_stateAlignment JOIN(SnP, _stateAlignment) #else #define SnP_stateSizeInBytes JOIN(SnP, _statesSizeInBytes) #define SnP_stateAlignment JOIN(SnP, _statesAlignment) #endif #define PlSnP_factor ((PlSnP_targetParallelism)/(PlSnP_baseParallelism)) #define SnP_stateOffset (((SnP_stateSizeInBytes+(SnP_stateAlignment-1))/SnP_stateAlignment)*SnP_stateAlignment) #define stateWithIndex(i) ((unsigned char *)states+((i)*SnP_stateOffset)) #define SnP_StaticInitialize JOIN(SnP, _StaticInitialize) #define SnP_Initialize JOIN(SnP, _Initialize) #define SnP_InitializeAll JOIN(SnP, _InitializeAll) #define SnP_AddByte JOIN(SnP, _AddByte) #define SnP_AddBytes JOIN(SnP, _AddBytes) #define SnP_AddLanesAll JOIN(SnP, _AddLanesAll) #define SnP_OverwriteBytes JOIN(SnP, _OverwriteBytes) #define SnP_OverwriteLanesAll JOIN(SnP, _OverwriteLanesAll) #define SnP_OverwriteWithZeroes JOIN(SnP, _OverwriteWithZeroes) #define SnP_ExtractBytes JOIN(SnP, _ExtractBytes) #define SnP_ExtractLanesAll JOIN(SnP, _ExtractLanesAll) #define SnP_ExtractAndAddBytes JOIN(SnP, _ExtractAndAddBytes) #define SnP_ExtractAndAddLanesAll JOIN(SnP, _ExtractAndAddLanesAll) void PlSnP_StaticInitialize( void ) { SnP_StaticInitialize(); } void PlSnP_InitializeAll(void *states) { unsigned int i; for(i=0; i