Generic interface.
[u/mdw/catacomb] / gcipher.h
diff --git a/gcipher.h b/gcipher.h
new file mode 100644 (file)
index 0000000..4831913
--- /dev/null
+++ b/gcipher.h
@@ -0,0 +1,83 @@
+/* -*-c-*-
+ *
+ * $Id: gcipher.h,v 1.1 1999/12/10 23:16:01 mdw Exp $
+ *
+ * Generic symmetric cipher interface
+ *
+ * (c) 1999 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------* 
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------* 
+ *
+ * $Log: gcipher.h,v $
+ * Revision 1.1  1999/12/10 23:16:01  mdw
+ * Generic interface.
+ *
+ */
+
+#ifndef CATACOMB_GCIPHER_H
+#define CATACOMB_GCIPHER_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stddef.h>
+
+/*----- Generic symmetric cipher interface --------------------------------*/
+
+typedef struct gccipher_base {
+  const char *name;                    /* Cipher name */
+  size_t keysz;                                /* Preferred key size in bytes */
+  size_t blksz;                                /* Block size or zero if none */
+} gccipher_base;
+
+typedef struct gcipher {
+  const struct gcipher_ops *ops;       /* Pointer to cipher operations */
+} gcipher;
+
+typedef struct gcipher_ops {
+  const struct gccipher_base *b;       /* Pointer to basic information */
+  void (*encrypt)(gcipher */*c*/, const void */*s*/,
+                 void */*t*/, size_t /*sz*/);
+  void (*decrypt)(gcipher */*c*/, const void */*s*/,
+                 void */*t*/, size_t /*sz*/);
+  void (*destroy)(gcipher */*c*/);
+  void (*setiv)(gcipher */*c*/, const void */*iv*/);
+  void (*bdry)(gcipher */*c*/);
+} gcipher_ops;
+
+typedef struct gccipher {
+  gccipher_base b;
+  gcipher *(*init)(const void */*k*/, size_t /*sz*/);
+} gccipher;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif