summaryrefslogtreecommitdiff
path: root/lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h
diff options
context:
space:
mode:
authorRobert Relyea <rrelyea@redhat.com>2023-02-27 17:19:39 -0800
committerRobert Relyea <rrelyea@redhat.com>2023-02-27 17:19:39 -0800
commitfceb08b2428170ae51938fa93bc2b2c00bd1d5ad (patch)
treebea248d594fa867f3995d63990d313eb72c5af68 /lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h
parentf4262a3db99a22b38fc8d6d9e8103ad31a697f9f (diff)
downloadnss-hg-fceb08b2428170ae51938fa93bc2b2c00bd1d5ad.tar.gz
Add liboqs
Diffstat (limited to 'lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h')
-rw-r--r--lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h b/lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h
new file mode 100644
index 000000000..19fc335e2
--- /dev/null
+++ b/lib/liboqs/src/sig/sphincs/pqclean_sphincs-sha256-192s-simple_clean/hash_state.h
@@ -0,0 +1,26 @@
+#ifndef SPX_HASH_STATE_H
+#define SPX_HASH_STATE_H
+
+/**
+ * Defines the type of the hash function state.
+ *
+ * Don't be fooled into thinking this instance of SPHINCS+ isn't stateless!
+ *
+ * From Section 7.2.2 from the SPHINCS+ round-2 specification:
+ *
+ * Each of the instances of the tweakable hash function take PK.seed as its
+ * first input, which is constant for a given key pair – and, thus, across
+ * a single signature. This leads to a lot of redundant computation. To remedy
+ * this, we pad PK.seed to the length of a full 64-byte SHA-256 input block.
+ * Because of the Merkle-Damgård construction that underlies SHA-256, this
+ * allows for reuse of the intermediate SHA-256 state after the initial call to
+ * the compression function which improves performance.
+ *
+ * We pass this hash state around in functions, because otherwise we need to
+ * have a global variable.
+ */
+
+#include "sha2.h"
+#define hash_state sha256ctx
+
+#endif