algorithms.c, knock-on: Eliminate `f_freeme' flags.
[pyke] / catacomb-python.h
index bed97d5..d68026d 100644 (file)
 
 /*----- Header files ------------------------------------------------------*/
 
+#define PY_SSIZE_T_CLEAN
+
 #include <Python.h>
 #include <longintrepr.h>
 #include <structmember.h>
 
-#undef ULLONG_MAX
-#undef ULONG_LONG_MAX
-
 #include <mLib/darray.h>
 #include <mLib/dstr.h>
 #include <mLib/macros.h>
@@ -47,6 +46,7 @@
 #include <mLib/unihash.h>
 
 #include <catacomb/buf.h>
+#include <catacomb/ct.h>
 
 #include <catacomb/grand.h>
 #include <catacomb/rand.h>
 #include <catacomb/gmac.h>
 #include <catacomb/md5.h>
 #include <catacomb/md5-hmac.h>
+#include <catacomb/poly1305.h>
 #include <catacomb/sha.h>
 #include <catacomb/sha-mgf.h>
 #include <catacomb/sha-hmac.h>
+#include <catacomb/keccak1600.h>
+#include <catacomb/sha3.h>
 
 #include <catacomb/mp.h>
 #include <catacomb/mpint.h>
 #include <catacomb/ptab.h>
 #include <catacomb/bintab.h>
 #include <catacomb/dsa.h>
+#include <catacomb/x25519.h>
+#include <catacomb/x448.h>
+#include <catacomb/ed25519.h>
+#include <catacomb/ed448.h>
 
 #include <catacomb/gf.h>
 #include <catacomb/gfreduce.h>
 } while (0)
 #define VALERR(str) EXCERR(PyExc_ValueError, str)
 #define TYERR(str) EXCERR(PyExc_TypeError, str)
+#define IXERR(str) EXCERR(PyExc_IndexError, str)
 #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
 #define SYSERR(str) EXCERR(PyExc_SystemError, str)
 #define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
 
 #define root_pytype 0
 #define type_pytype &PyType_Type
-#define INITTYPE(ty, base) do {                                                \
+#define INITTYPE_META(ty, base, meta) do {                             \
   ty##_pytype_skel.tp_base = base##_pytype;                            \
-  ty##_pytype = inittype(&ty##_pytype_skel);                           \
+  ty##_pytype = inittype(&ty##_pytype_skel, meta##_pytype);            \
 } while (0)
+#define INITTYPE(ty, base) INITTYPE_META(ty, base, type)
 
 #define INSERT(name, ob) do {                                          \
   PyObject *_o = (PyObject *)(ob);                                     \
@@ -223,6 +232,8 @@ MODULES(DO)
     return (d);                                                                \
   }
 
+#define KWLIST (/*unconst*/ char **)kwlist
+
 struct nameval { const char *name; unsigned long value; };
 extern void setconstants(PyObject *, const struct nameval *);
 
@@ -238,16 +249,18 @@ extern int convulong(PyObject *, void *);
 DOUINTSZ(DECL_CONVU_)
 extern int convmpw(PyObject *, void *);
 extern int convuint(PyObject *, void *);
+extern int convk64(PyObject *, void *);
 extern int convszt(PyObject *, void *);
 extern int convbool(PyObject *, void *);
 extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);
 extern PyObject *getbool(int);
 extern PyObject *getulong(unsigned long);
+extern PyObject *getk64(kludge64);
 extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *);
 
 extern PyObject *mkexc(PyObject *, PyObject *, const char *, PyMethodDef *);
 extern void typeready(PyTypeObject *);
-extern PyTypeObject *inittype(PyTypeObject *);
+extern PyTypeObject *inittype(PyTypeObject *, PyTypeObject *);
 extern void addmethods(const PyMethodDef *);
 extern PyMethodDef *donemethods(void);
 
@@ -490,22 +503,18 @@ typedef struct gccipher_pyobj {
 extern PyTypeObject *gccipher_pytype;
 #define GCCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gccipher_pytype)
 #define GCCIPHER_CC(o) (((gccipher_pyobj *)(o))->cc)
-#define GCCIPHER_F(o) (((gccipher_pyobj *)(o))->f)
 extern PyObject *gccipher_pywrap(gccipher *);
 extern int convgccipher(PyObject *, void *);
-extern int convgcipher(PyObject *, void *);
 
 typedef struct gcipher_pyobj {
   PyObject_HEAD
-  unsigned f;
   gcipher *c;
 } gcipher_pyobj;
 
 extern PyTypeObject *gcipher_pytype;
 #define GCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gcipher_pytype)
 #define GCIPHER_C(o) (((gcipher_pyobj *)(o))->c)
-#define GCIPHER_F(o) (((gcipher_pyobj *)(o))->f)
-extern PyObject *gcipher_pywrap(PyObject *, gcipher *, unsigned);
+extern PyObject *gcipher_pywrap(PyObject *, gcipher *);
 extern int convgcipher(PyObject *, void *);
 
 typedef struct gchash_pyobj {
@@ -516,13 +525,11 @@ typedef struct gchash_pyobj {
 extern PyTypeObject *gchash_pytype;
 #define GCHASH_PYCHECK(o) PyObject_TypeCheck((o), gchash_pytype)
 #define GCHASH_CH(o) (((gchash_pyobj *)(o))->ch)
-#define GCHASH_F(o) (((gchash_pyobj *)(o))->f)
 extern PyObject *gchash_pywrap(gchash *);
 extern int convgchash(PyObject *, void *);
 
 typedef struct ghash_pyobj {
   PyObject_HEAD
-  unsigned f;
   ghash *h;
 } ghash_pyobj;
 
@@ -530,8 +537,7 @@ extern PyTypeObject *ghash_pytype, *gmhash_pytype;
 extern PyObject *sha_pyobj, *has160_pyobj;
 #define GHASH_PYCHECK(o) PyObject_TypeCheck((o), ghash_pytype)
 #define GHASH_H(o) (((ghash_pyobj *)(o))->h)
-#define GHASH_F(o) (((ghash_pyobj *)(o))->f)
-extern PyObject *ghash_pywrap(PyObject *, ghash *, unsigned);
+extern PyObject *ghash_pywrap(PyObject *, ghash *);
 extern int convghash(PyObject *, void *);
 extern int convgmhash(PyObject *, void *);
 
@@ -549,7 +555,6 @@ extern int convgcmac(PyObject *, void *);
 
 typedef struct gmac_pyobj {
   PyHeapTypeObject ty;
-  unsigned f;
   gmac *m;
 } gmac_pyobj;
 
@@ -557,7 +562,7 @@ extern PyTypeObject *gmac_pytype;
 #define GMAC_PYCHECK(o) PyObject_TypeCheck((o), gmac_pytype)
 #define GMAC_M(o) (((gmac_pyobj *)(o))->m)
 #define GMAC_F(o) (((gmac_pyobj *)(o))->f)
-extern PyObject *gmac_pywrap(PyObject *, gmac *, unsigned);
+extern PyObject *gmac_pywrap(PyObject *, gmac *);
 extern int convgmac(PyObject *, void *);
 
 /*----- Key generation ----------------------------------------------------*/