From a55b1a4efbdd0179e8dbc61b25ce46188fd03f2c Mon Sep 17 00:00:00 2001 From: laiwei360735 <1655919897@qq.com> Date: Tue, 9 May 2017 18:00:28 +0800 Subject: [PATCH] a compact c code of SHA-3 --- crypto/SHA-3/Modes/SimpleFIPS202.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 crypto/SHA-3/Modes/SimpleFIPS202.c diff --git a/crypto/SHA-3/Modes/SimpleFIPS202.c b/crypto/SHA-3/Modes/SimpleFIPS202.c new file mode 100644 index 00000000..1258b54f --- /dev/null +++ b/crypto/SHA-3/Modes/SimpleFIPS202.c @@ -0,0 +1,31 @@ +#include "SimpleFIPS202.h" + +int SHAKE128(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge(1344, 256, input, inputByteLen, 0x1F, output, outputByteLen); +} + +int SHAKE256(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x1F, output, outputByteLen); +} + +int SHA3_224(unsigned char *output, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge(1152, 448, input, inputByteLen, 0x06, output, 224/8); +} + +int SHA3_256(unsigned char *output, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x06, output, 256/8); +} + +int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge( 832, 768, input, inputByteLen, 0x06, output, 384/8); +} + +int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen) +{ + return KeccakWidth1600_Sponge(576, 1024, input, inputByteLen, 0x06, output, 512/8); +}