symm/keccak1600.c: Add new function to overwrite the state.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 17 Nov 2018 22:32:32 +0000 (22:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 9 May 2020 19:57:33 +0000 (20:57 +0100)
This is somewhat more useful for implementing duplex-style
constructions.

debian/catacomb2.symbols
symm/keccak1600.c
symm/keccak1600.h

index b6ffba1..44c2da7 100644 (file)
@@ -4042,6 +4042,7 @@ libcatacomb.so.2 catacomb2 #MINVER#
        keccak1600_init@Base 2.4.0
        keccak1600_p@Base 2.4.0
        keccak1600_mix@Base 2.4.0
        keccak1600_init@Base 2.4.0
        keccak1600_p@Base 2.4.0
        keccak1600_mix@Base 2.4.0
+       keccak1600_set@Base 2.5.99~
        keccak1600_extract@Base 2.4.0
 
 ## sha3 common
        keccak1600_extract@Base 2.4.0
 
 ## sha3 common
index 499ab4f..c2d8292 100644 (file)
@@ -589,6 +589,35 @@ void keccak1600_mix(keccak1600_state *s, const kludge64 *p, size_t n)
     { a = TO_LANE(p[i]); XOR_LANE(s->S[i], s->S[i], a); }
 }
 
     { a = TO_LANE(p[i]); XOR_LANE(s->S[i], s->S[i], a); }
 }
 
+/* --- @keccak1600_set@ --- *
+ *
+ * Arguments:  @keccak1600_state *s@ = a state to update
+ *             @const kludge64 *p@ = pointer to 64-bit words to mix in
+ *             @size_t n@ = size of the input, in 64-bit words
+ *
+ * Returns:    ---
+ *
+ * Use:                Stores data into a %$\Keccak[r, 1600 - r]$% state.  Note that
+ *             it's the caller's responsibility to pass in no more than
+ *             %$r$% bits of data.
+ *
+ *             This is not the operation you wanted for ordinary hashing.
+ *             It's provided for the use of higher-level protocols which use
+ *             duplexing and other fancy sponge features.
+ */
+
+void keccak1600_set(keccak1600_state *s, const kludge64 *p, size_t n)
+{
+  uint32 m = COMPL_MASK;
+  unsigned i;
+  lane a;
+
+  for (i = 0; i < n; i++) {
+    a = TO_LANE(p[i]); if (m&1) NOT_LANE(a, a);
+    s->S[i] = a; m >>= 1;
+  }
+}
+
 /* --- @keccak1600_extract@ --- *
  *
  * Arguments:  @const keccak1600_state *s@ = a state to extract output from
 /* --- @keccak1600_extract@ --- *
  *
  * Arguments:  @const keccak1600_state *s@ = a state to extract output from
index 2867be9..f5aad98 100644 (file)
@@ -112,6 +112,26 @@ extern void keccak1600_init(keccak1600_state */*s*/);
 extern void keccak1600_mix(keccak1600_state */*s*/,
                           const kludge64 */*p*/, size_t /*n*/);
 
 extern void keccak1600_mix(keccak1600_state */*s*/,
                           const kludge64 */*p*/, size_t /*n*/);
 
+/* --- @keccak1600_set@ --- *
+ *
+ * Arguments:  @keccak1600_state *s@ = a state to update
+ *             @const kludge64 *p@ = pointer to 64-bit words to mix in
+ *             @size_t n@ = size of the input, in 64-bit words
+ *
+ * Returns:    ---
+ *
+ * Use:                Stores data into a %$\Keccak[r, 1600 - r]$% state.  Note that
+ *             it's the caller's responsibility to pass in no more than
+ *             %$r$% bits of data.
+ *
+ *             This is not the operation you wanted for ordinary hashing.
+ *             It's provided for the use of higher-level protocols which use
+ *             duplexing and other fancy sponge features.
+ */
+
+extern void keccak1600_set(keccak1600_state */*s*/,
+                          const kludge64 */*p*/, size_t /*n*/);
+
 /* --- @keccak1600_extract@ --- *
  *
  * Arguments:  @const keccak1600_state *s@ = a state to extract output from
 /* --- @keccak1600_extract@ --- *
  *
  * Arguments:  @const keccak1600_state *s@ = a state to extract output from