X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..7b0d1a63587f3cb1ae3bb8b248bbb1b82bdca7bd:/progs/cc.h diff --git a/progs/cc.h b/progs/cc.h index 610a7658..8ab6d32f 100644 --- a/progs/cc.h +++ b/progs/cc.h @@ -47,6 +47,8 @@ #include +#include "buf.h" +#include "ct.h" #include "key.h" #include "gcipher.h" #include "ghash.h" @@ -54,15 +56,36 @@ /*----- 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@ --- * *