Merge branch '2.5.x'
[catacomb] / progs / cc.h
index 610a765..8ab6d32 100644 (file)
@@ -47,6 +47,8 @@
 
 #include <mLib/dstr.h>
 
+#include "buf.h"
+#include "ct.h"
 #include "key.h"
 #include "gcipher.h"
 #include "ghash.h"
 
 /*----- Cryptographic object tables ---------------------------------------*/
 
+typedef struct bulk {
+  const struct bulkops *ops;
+} bulk;
+
+typedef struct bulkops {
+  bulk *(*init)(key */*k*/, const char */*calg*/, const char */*halg*/);
+  int (*setup)(bulk */*b*/, gcipher */*cx*/);
+  size_t (*overhead)(bulk */*b*/);
+  const char *(*doit)(bulk */*b*/, uint32 /*seq*/, buf */*bb*/,
+                     const void */*p*/, size_t /*sz*/);
+  void (*destroy)(bulk */*b*/);
+} bulkops;
+
+struct bulktab {
+  const char *name;
+  const bulkops *encops;
+  const bulkops *decops;
+};
+
+extern const struct bulktab bulktab[];
+
 /* --- Key encapsulation --- */
 
 typedef struct kem {
   const struct kemops *ops;
   key_packdef *kp;
   void *kd;
-  const gchash *h;
-  const gccipher *c, *cx;
-  const gcmac *m;
+  const gchash *hc;
+  const gccipher *cxc;
+  gcipher *cx;
 } kem;
 
 typedef struct kemops {
@@ -87,29 +110,28 @@ extern const struct kemtab kemtab[];
  * Arguments:  @key *k@ = the key to load
  *             @const char *app@ = application name
  *             @int wantpriv@ = nonzero if we want to decrypt
+ *             @bulk **bc@ = bulk crypto context to set up
  *
  * Returns:    A key-encapsulating thing.
  *
  * Use:                Loads a key.
  */
 
-extern kem *getkem(key */*k*/, const char */*app*/, int /*wantpriv*/);
+extern kem *getkem(key */*k*/, const char */*app*/, int /*wantpriv*/,
+                  bulk **/*bc*/);
 
 /* --- @setupkem@ --- *
  *
  * Arguments:  @kem *k@ = key-encapsulation thing
  *             @dstr *d@ = key-encapsulation data
- *             @gcipher **cx@ = key-expansion function (for IVs)
- *             @gcipher **c@ = where to put initialized encryption scheme
- *             @gmac **m@ = where to put initialized MAC
+ *             @bulk *bc@ = bulk crypto context to set up
  *
  * Returns:    Zero for success, nonzero on faliure.
  *
  * Use:                Initializes all the various symmetric things from a KEM.
  */
 
-extern int setupkem(kem */*k*/, dstr */*d*/,
-                   gcipher **/*cx*/, gcipher **/*c*/, gmac **/*m*/);
+extern int setupkem(kem */*k*/, dstr */*d*/, bulk */*bc*/);
 
 /* --- @freekem@ --- *
  *