summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/sha3/KeccakNISTInterface.h
diff options
context:
space:
mode:
authorRichard Moore <rich@kde.org>2013-01-26 12:52:44 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-06 21:23:43 +0100
commit7765dff1bb8104ea145d55d32da194acb2de03ce (patch)
tree064e60b6fcf29f37e74365a5d308abbe7d71b44a /src/3rdparty/sha3/KeccakNISTInterface.h
parentfd9013658bab096839154ae6e68adfd1a4e10189 (diff)
Add the pristine SHA3 reference sources.
Add the SHA3 reference implementation (public domain) which will be used in a later commit to add support for SHA3 to QCryptographicHash. Change-Id: Id0e9d47d628cc94f1d3d2a7696836bc43f6ddf61 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/sha3/KeccakNISTInterface.h')
-rwxr-xr-xsrc/3rdparty/sha3/KeccakNISTInterface.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/3rdparty/sha3/KeccakNISTInterface.h b/src/3rdparty/sha3/KeccakNISTInterface.h
new file mode 100755
index 0000000000..c6987d420b
--- /dev/null
+++ b/src/3rdparty/sha3/KeccakNISTInterface.h
@@ -0,0 +1,70 @@
+/*
+The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
+Michaƫl Peeters and Gilles Van Assche. For more information, feedback or
+questions, please refer to our website: http://keccak.noekeon.org/
+
+Implementation by the designers,
+hereby denoted as "the implementer".
+
+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/
+*/
+
+#ifndef _KeccakNISTInterface_h_
+#define _KeccakNISTInterface_h_
+
+#include "KeccakSponge.h"
+
+typedef unsigned char BitSequence;
+typedef unsigned long long DataLength;
+typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
+
+typedef spongeState hashState;
+
+/**
+ * Function to initialize the state of the Keccak[r, c] sponge function.
+ * The rate r and capacity c values are determined from @a hashbitlen.
+ * @param state Pointer to the state of the sponge function to be initialized.
+ * @param hashbitlen The desired number of output bits,
+ * or 0 for Keccak[] with default parameters
+ * and arbitrarily-long output.
+ * @pre The value of hashbitlen must be one of 0, 224, 256, 384 and 512.
+ * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
+ */
+HashReturn Init(hashState *state, int hashbitlen);
+/**
+ * Function to give input data for the sponge function to absorb.
+ * @param state Pointer to the state of the sponge function initialized by Init().
+ * @param data Pointer to the input data.
+ * When @a databitLen is not a multiple of 8, the last bits of data must be
+ * in the most significant bits of the last byte.
+ * @param databitLen The number of input bits provided in the input data.
+ * @pre In the previous call to Absorb(), databitLen was a multiple of 8.
+ * @return SUCCESS if successful, FAIL otherwise.
+ */
+HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen);
+/**
+ * Function to squeeze output data from the sponge function.
+ * If @a hashbitlen was not 0 in the call to Init(), the number of output bits is equal to @a hashbitlen.
+ * If @a hashbitlen was 0 in the call to Init(), the output bits must be extracted using the Squeeze() function.
+ * @param state Pointer to the state of the sponge function initialized by Init().
+ * @param hashval Pointer to the buffer where to store the output data.
+ * @return SUCCESS if successful, FAIL otherwise.
+ */
+HashReturn Final(hashState *state, BitSequence *hashval);
+/**
+ * Function to compute a hash using the Keccak[r, c] sponge function.
+ * The rate r and capacity c values are determined from @a hashbitlen.
+ * @param hashbitlen The desired number of output bits.
+ * @param data Pointer to the input data.
+ * When @a databitLen is not a multiple of 8, the last bits of data must be
+ * in the most significant bits of the last byte.
+ * @param databitLen The number of input bits provided in the input data.
+ * @param hashval Pointer to the buffer where to store the output data.
+ * @pre The value of hashbitlen must be one of 224, 256, 384 and 512.
+ * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
+ */
+HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval);
+
+#endif