aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-04 14:42:06 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-04 14:42:06 +0100
commitc86235085b3cc74cebcf0f634a52382a8299ca7f (patch)
tree5f71e4e774ab34bed49b1837082cf68adb450a12 /src
parentm (diff)
downloadlibkeccak-c86235085b3cc74cebcf0f634a52382a8299ca7f.tar.gz
libkeccak-c86235085b3cc74cebcf0f634a52382a8299ca7f.tar.bz2
libkeccak-c86235085b3cc74cebcf0f634a52382a8299ca7f.tar.xz
specs for sha3, rawshake and shake
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libkeccak/spec.h61
1 files changed, 60 insertions, 1 deletions
diff --git a/src/libkeccak/spec.h b/src/libkeccak/spec.h
index fe6ce98..0d1dd98 100644
--- a/src/libkeccak/spec.h
+++ b/src/libkeccak/spec.h
@@ -21,7 +21,24 @@
/**
- * This datastructure describes the parameters
+ * Message suffix for SHA3 hashing
+ */
+#define LIBKECCAK_SHA3_SUFFIX "01"
+
+/**
+ * Message suffix for RawSHAKE hashing
+ */
+#define LIBKECCAK_RAWSHAKE_SUFFIX "11"
+
+/**
+ * Message suffix for SHAKE hashing
+ */
+#define LIBKECCAK_SHAKE_SUFFIX "1111"
+
+
+
+/**
+ * Datastructure that describes the parameters
* that should be used when hashing
*/
typedef struct libkeccak_spec
@@ -44,5 +61,47 @@ typedef struct libkeccak_spec
} libkeccak_spec_t;
+
+/**
+ * Fill in a `libkeccak_spec_t` for a SHA3-x hashing
+ *
+ * @param spec The specifications datastructure to fill in
+ * @param x The value of x in `SHA3-x`, the output size
+ */
+static inline __attribute__((leaf, nonnull, nothrow))
+void libkeccak_spec_sha3(libkeccak_spec_t* restrict spec, long x)
+{
+ spec->bitrate = 1600 - 2 * x;
+ spec->capacity = 2 * x;
+ spec->output = x;
+}
+
+
+/**
+ * Fill in a `libkeccak_spec_t` for a RawSHAKEx hashing
+ *
+ * @param spec The specifications datastructure to fill in
+ * @param x The value of x in `RawSHAKEx`, half the capacity
+ * @param d The output size
+ */
+static inline __attribute__((leaf, nonnull, nothrow))
+void libkeccak_spec_rawshake(libkeccak_spec_t* restrict spec, long x, long d)
+{
+ spec->bitrate = 1600 - 2 * x;
+ spec->capacity = 2 * x;
+ spec->output = d;
+}
+
+
+/**
+ * Fill in a `libkeccak_spec_t` for a SHAKEx hashing
+ *
+ * @param spec:libkeccak_spec_t* The specifications datastructure to fill in
+ * @param x:long The value of x in `SHAKEx`, half the capacity
+ * @param d:long The output size
+ */
+#define libkeccak_spec_shake libkeccak_spec_rawshake
+
+
#undef