+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ PYMETHODS(gaeadenc), /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ PYGETSET(gaeadenc), /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+static const PyTypeObject gcaeaddec_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GAEDecClass", /* @tp_name@ */
+ sizeof(gcaeaddec_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ 0, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Authenticated decryption operation metaclass.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ 0, /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ 0, /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+static const PyTypeObject gaeaddec_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GAEDec", /* @tp_name@ */
+ sizeof(gaeaddec_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ gaeaddec_pydealloc, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Authenticated decryption operation.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ PYMETHODS(gaeaddec), /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ PYGETSET(gaeaddec), /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+/*----- Hash functions ----------------------------------------------------*/
+
+PyTypeObject *gchash_pytype;
+static PyTypeObject *ghash_pytype;
+PyObject *sha_pyobj, *has160_pyobj;
+
+typedef struct ghash_pyobj {
+ PyObject_HEAD
+ ghash *h;
+} ghash_pyobj;
+
+#define GHASH_PYCHECK(o) PyObject_TypeCheck((o), ghash_pytype)
+#define GHASH_H(o) (((ghash_pyobj *)(o))->h)
+
+CONVFUNC(gchash, gchash *, GCHASH_CH)
+CONVFUNC(ghash, ghash *, GHASH_H)
+
+static PyObject *ghash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
+{
+ static const char *const kwlist[] = { 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST))
+ goto end;
+ return (ghash_pywrap((PyObject *)ty, GH_INIT(GCHASH_CH(ty))));
+end:
+ return (0);
+}
+
+static PyObject *gchash_pywrap(gchash *ch)
+{
+ gchash_pyobj *g = newtype(gchash_pytype, 0, ch->name);
+ g->ch = ch;
+ g->ty.ht_type.tp_basicsize = sizeof(ghash_pyobj);
+ g->ty.ht_type.tp_base = ghash_pytype;
+ Py_INCREF(ghash_pytype);
+ g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE |
+ Py_TPFLAGS_HEAPTYPE);
+ g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+ g->ty.ht_type.tp_free = 0;
+ g->ty.ht_type.tp_new = ghash_pynew;
+ typeready(&g->ty.ht_type);
+ return ((PyObject *)g);
+}
+
+PyObject *ghash_pywrap(PyObject *cobj, ghash *h)
+{
+ ghash_pyobj *g;
+ if (!cobj) cobj = gchash_pywrap((/*unconst*/ gchash *)GH_CLASS(h));
+ else Py_INCREF(cobj);
+ g = PyObject_NEW(ghash_pyobj, (PyTypeObject *)cobj);
+ g->h = h;
+ return ((PyObject *)g);
+}
+
+static void ghash_pydealloc(PyObject *me)
+{
+ GH_DESTROY(GHASH_H(me));
+ Py_DECREF(Py_TYPE(me));
+ FREEOBJ(me);
+}
+
+static PyObject *gchget_name(PyObject *me, void *hunoz)
+ { return (TEXT_FROMSTR(GCHASH_CH(me)->name)); }
+
+static PyObject *gchget_hashsz(PyObject *me, void *hunoz)
+ { return (PyInt_FromLong(GCHASH_CH(me)->hashsz)); }
+
+static PyObject *gchget_bufsz(PyObject *me, void *hunoz)
+ { return (PyInt_FromLong(GCHASH_CH(me)->bufsz)); }
+
+static PyObject *ghmeth_copy(PyObject *me)
+ { return (ghash_pywrap((PyObject *)Py_TYPE(me), GH_COPY(GHASH_H(me)))); }
+
+static PyObject *ghmeth_hash(PyObject *me, PyObject *arg)
+{
+ struct bin m;
+ if (!PyArg_ParseTuple(arg, "O&:hash", convbin, &m)) return (0);
+ GH_HASH(GHASH_H(me), m.p, m.sz);
+ RETURN_ME;
+}
+
+#define GHMETH_HASHU_(n, W, w) \
+ static PyObject *ghmeth_hashu##w(PyObject *me, PyObject *arg) \
+ { \
+ uint##n x; \
+ if (!PyArg_ParseTuple(arg, "O&:hashu" #w, convu##n, &x)) return (0); \
+ GH_HASHU##W(GHASH_H(me), x); \
+ RETURN_ME; \
+ }
+DOUINTCONV(GHMETH_HASHU_)
+
+#define GHMETH_HASHBUF_(n, W, w) \
+ static PyObject *ghmeth_hashbuf##w(PyObject *me, PyObject *arg) \
+ { \
+ struct bin in; \
+ if (!PyArg_ParseTuple(arg, "O&:hashbuf" #w, convbin, &in)) goto end; \
+ if (in.sz > MASK##n) VALERR("too large"); \
+ GH_HASHBUF##W(GHASH_H(me), in.p, in.sz); \
+ RETURN_ME; \
+ end: \
+ return (0); \
+ }
+DOUINTCONV(GHMETH_HASHBUF_)
+
+static PyObject *ghmeth_hashstrz(PyObject *me, PyObject *arg)
+{
+ char *p;
+ if (!PyArg_ParseTuple(arg, "s:hashstrz", &p)) return (0);
+ GH_HASHSTRZ(GHASH_H(me), p);
+ RETURN_ME;
+}
+
+static PyObject *ghmeth_done(PyObject *me)
+{
+ ghash *g;
+ PyObject *rc;
+ g = GH_COPY(GHASH_H(me));
+ rc = bytestring_pywrap(0, g->ops->c->hashsz);
+ GH_DONE(g, BIN_PTR(rc));
+ GH_DESTROY(g);
+ return (rc);
+}
+
+static const PyGetSetDef gchash_pygetset[] = {
+#define GETSETNAME(op, name) gch##op##_##name
+ GET (bufsz, "CH.bufsz -> hash buffer size, or zero")
+ GET (hashsz, "CH.hashsz -> hash output size")
+ GET (name, "CH.name -> name of this kind of hash")
+#undef GETSETNAME
+ { 0 }
+};
+
+static const PyMethodDef ghash_pymethods[] = {
+#define METHNAME(name) ghmeth_##name
+ NAMETH(copy, "H.copy() -> HH")
+ METH (hash, "H.hash(M)")
+#define METHU_(n, W, w) METH(hashu##w, "H.hashu" #w "(WORD)")
+ DOUINTCONV(METHU_)
+#undef METHU_
+#define METHBUF_(n, W, w) METH(hashbuf##w, "H.hashbuf" #w "(BYTES)")
+ DOUINTCONV(METHBUF_)
+#undef METHBUF_
+ METH (hashstrz, "H.hashstrz(STRING)")
+ NAMETH(done, "H.done() -> HASH")
+#undef METHNAME
+ { 0 }
+};
+
+static const PyTypeObject gchash_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GCHash", /* @tp_name@ */
+ sizeof(gchash_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ 0, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Hash function metaclass.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ 0, /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ PYGETSET(gchash), /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+static const PyTypeObject ghash_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GHash", /* @tp_name@ */
+ sizeof(ghash_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ ghash_pydealloc, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Hash function, abstract base class.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ PYMETHODS(ghash), /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ 0, /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+/*----- Message authentication --------------------------------------------*/
+
+static PyTypeObject *gcmac_pytype, *gmac_pytype, *gmhash_pytype;
+
+typedef struct gcmac_pyobj {
+ PyHeapTypeObject ty;
+ gcmac *cm;
+} gcmac_pyobj;
+
+#define GCMAC_PYCHECK(o) PyObject_TypeCheck((o), gcmac_pytype)
+#define GCMAC_CM(o) (((gcmac_pyobj *)(o))->cm)
+#define GCMAC_F(o) (((gcmac_pyobj *)(o))->f)
+CONVFUNC(gcmac, gcmac *, GCMAC_CM)
+static PyObject *gmac_pywrap(PyObject *, gmac *);
+
+typedef struct gmac_pyobj {
+ PyHeapTypeObject ty;
+ gmac *m;
+} gmac_pyobj;
+
+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 *);
+extern int convgmac(PyObject *, void *);
+
+static PyObject *gmac_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
+{
+ static const char *const kwlist[] = { "k", 0 };
+ struct bin k;
+
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convbin, &k))
+ goto end;
+ if (keysz(k.sz, GCMAC_CM(ty)->keysz) != k.sz) VALERR("bad key length");
+ return (gmac_pywrap((PyObject *)ty,
+ GM_KEY(GCMAC_CM(ty), k.p, k.sz)));
+end:
+ return (0);
+}
+
+static PyObject *gmhash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
+{
+ static const char *const kwlist[] = { 0 };
+ ghash_pyobj *g;
+
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST)) return (0);
+ g = PyObject_NEW(ghash_pyobj, ty);
+ g->h = GM_INIT(GMAC_M(ty));
+ Py_INCREF(ty);
+ return ((PyObject *)g);
+}
+
+static PyObject *gcmac_pywrap(gcmac *cm)
+{
+ gcmac_pyobj *g = newtype(gcmac_pytype, 0, cm->name);
+ g->cm = cm;
+ g->ty.ht_type.tp_basicsize = sizeof(gmac_pyobj);
+ g->ty.ht_type.tp_base = gmac_pytype;
+ Py_INCREF(gmac_pytype);
+ g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE |
+ Py_TPFLAGS_HEAPTYPE);
+ g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+ g->ty.ht_type.tp_free = 0;
+ g->ty.ht_type.tp_new = gmac_pynew;
+ typeready(&g->ty.ht_type);
+ return ((PyObject *)g);
+}
+
+static PyObject *gmac_pywrap(PyObject *cobj, gmac *m)
+{
+ gmac_pyobj *g;
+ if (!cobj) cobj = gcmac_pywrap((/*unconst*/ gcmac *)GM_CLASS(m));
+ else Py_INCREF(cobj);
+ g = newtype((PyTypeObject *)cobj, 0, 0);
+ g->ty.ht_type.tp_basicsize = sizeof(ghash_pyobj);
+ g->ty.ht_name = TEXT_FORMAT("%s(keyed)", m->ops->c->name);
+ g->ty.ht_type.tp_name = TEXT_PTR(g->ty.ht_name);
+ g->ty.ht_type.tp_base = gmhash_pytype;
+ Py_INCREF(gmac_pytype);
+ g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE |
+ Py_TPFLAGS_HEAPTYPE);
+ g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+ g->ty.ht_type.tp_free = 0;
+ g->ty.ht_type.tp_new = gmhash_pynew;
+ typeready(&g->ty.ht_type);
+ g->m = m;
+ return ((PyObject *)g);
+}
+
+static void gmac_pydealloc(PyObject *me)
+{
+ GM_DESTROY(GMAC_M(me));
+ Py_DECREF(Py_TYPE(me));
+ PyType_Type.tp_dealloc(me);
+}
+
+static PyObject *gcmget_name(PyObject *me, void *hunoz)
+ { return (TEXT_FROMSTR(GCMAC_CM(me)->name)); }
+
+static PyObject *gcmget_keysz(PyObject *me, void *hunoz)
+ { return (keysz_pywrap(GCMAC_CM(me)->keysz)); }
+
+static PyObject *gcmget_tagsz(PyObject *me, void *hunoz)
+ { return (PyInt_FromLong(GCMAC_CM(me)->hashsz)); }
+
+static const PyGetSetDef gcmac_pygetset[] = {
+#define GETSETNAME(op, name) gcm##op##_##name
+ GET (keysz, "CM.keysz -> acceptable key sizes")
+ GET (tagsz, "CM.tagsz -> MAC output size")
+ GET (name, "CM.name -> name of this kind of MAC")
+#undef GETSETNAME
+ { 0 }
+};
+
+static PyObject *gmget_name(PyObject *me, void *hunoz)
+ { return (TEXT_FROMSTR(GMAC_M(me)->ops->c->name)); }
+
+static PyObject *gmget_hashsz(PyObject *me, void *hunoz)
+ { return (PyInt_FromLong(GMAC_M(me)->ops->c->hashsz)); }
+#define gmget_tagsz gmget_hashsz
+
+static const PyGetSetDef gmac_pygetset[] = {
+#define GETSETNAME(op, name) gm##op##_##name
+ GET (hashsz, "M.hashsz -> MAC output size")
+ GET (tagsz, "M.tagsz -> MAC output size")
+ GET (name, "M.name -> name of this kind of MAC")
+#undef GETSETNAME
+ { 0 }
+};
+
+static const PyTypeObject gcmac_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GCMAC", /* @tp_name@ */
+ sizeof(gchash_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ 0, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Message authentication code metametaclass.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ 0, /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ PYGETSET(gcmac), /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+static const PyTypeObject gmac_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GMAC", /* @tp_name@ */
+ sizeof(gmac_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ gmac_pydealloc, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Message authentication code metaclass, abstract base class.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ 0, /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ PYGETSET(gmac), /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+static const PyTypeObject gmhash_pytype_skel = {
+ PyVarObject_HEAD_INIT(0, 0) /* Header */
+ "GMACHash", /* @tp_name@ */
+ sizeof(ghash_pyobj), /* @tp_basicsize@ */
+ 0, /* @tp_itemsize@ */
+
+ ghash_pydealloc, /* @tp_dealloc@ */
+ 0, /* @tp_print@ */
+ 0, /* @tp_getattr@ */
+ 0, /* @tp_setattr@ */
+ 0, /* @tp_compare@ */
+ 0, /* @tp_repr@ */
+ 0, /* @tp_as_number@ */
+ 0, /* @tp_as_sequence@ */
+ 0, /* @tp_as_mapping@ */
+ 0, /* @tp_hash@ */
+ 0, /* @tp_call@ */
+ 0, /* @tp_str@ */
+ 0, /* @tp_getattro@ */
+ 0, /* @tp_setattro@ */
+ 0, /* @tp_as_buffer@ */
+ Py_TPFLAGS_DEFAULT | /* @tp_flags@ */
+ Py_TPFLAGS_BASETYPE,
+
+ /* @tp_doc@ */
+ "Message authentication code, abstract base class.",
+
+ 0, /* @tp_traverse@ */
+ 0, /* @tp_clear@ */
+ 0, /* @tp_richcompare@ */
+ 0, /* @tp_weaklistoffset@ */
+ 0, /* @tp_iter@ */
+ 0, /* @tp_iternext@ */
+ 0, /* @tp_methods@ */
+ 0, /* @tp_members@ */
+ 0, /* @tp_getset@ */
+ 0, /* @tp_base@ */
+ 0, /* @tp_dict@ */
+ 0, /* @tp_descr_get@ */
+ 0, /* @tp_descr_set@ */
+ 0, /* @tp_dictoffset@ */
+ 0, /* @tp_init@ */
+ PyType_GenericAlloc, /* @tp_alloc@ */
+ abstract_pynew, /* @tp_new@ */
+ 0, /* @tp_free@ */
+ 0 /* @tp_is_gc@ */
+};
+
+/*----- Special snowflake for Poly1305 ------------------------------------*/
+
+PyTypeObject *poly1305cls_pytype, *poly1305key_pytype, *poly1305hash_pytype;
+
+typedef struct poly1305key_pyobj {
+ PyHeapTypeObject ty;
+ poly1305_key k;
+} poly1305key_pyobj;
+
+typedef struct poly1305hash_pyobj {
+ PyObject_HEAD
+ unsigned f;
+#define f_mask 1u
+ poly1305_ctx ctx;
+} poly1305hash_pyobj;
+
+#define P1305_F(o) (((poly1305hash_pyobj *)(o))->f)
+#define P1305_CTX(o) (&((poly1305hash_pyobj *)(o))->ctx)