catacomb-python.h: Don't inhibit 64-bit type detection any more.
[pyke] / catacomb-python.h
CommitLineData
b6a86d2e 1/* -*-c-*-
2 *
b6a86d2e 3 * Definitions for Catacomb bindings
4 *
5 * (c) 2004 Straylight/Edgeware
6 */
7
0b1eafbf 8/*----- Licensing notice --------------------------------------------------*
b6a86d2e 9 *
10 * This file is part of the Python interface to Catacomb.
11 *
12 * Catacomb/Python is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
0b1eafbf 16 *
b6a86d2e 17 * Catacomb/Python is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
0b1eafbf 21 *
b6a86d2e 22 * You should have received a copy of the GNU General Public License
23 * along with Catacomb/Python; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27#ifndef CATACOMB_PYTHON_H
28#define CATACOMB_PYTHON_H
29
30#ifdef __cplusplus
31 extern "C" {
32#endif
33
34/*----- Header files ------------------------------------------------------*/
35
36#include <Python.h>
37#include <longintrepr.h>
38#include <structmember.h>
39
40#include <mLib/darray.h>
41#include <mLib/dstr.h>
42#include <mLib/macros.h>
73a712fa 43#include <mLib/quis.h>
b06387d2 44#include <mLib/unihash.h>
b6a86d2e 45
46#include <catacomb/buf.h>
47
48#include <catacomb/grand.h>
49#include <catacomb/rand.h>
50#include <catacomb/noise.h>
51#include <catacomb/bbs.h>
52#include <catacomb/mprand.h>
53#include <catacomb/lcrand.h>
54#include <catacomb/fibrand.h>
55#include <catacomb/dsarand.h>
56#include <catacomb/sslprf.h>
57#include <catacomb/tlsprf.h>
62058916 58#include <catacomb/blkc.h>
b6a86d2e 59
60#include <catacomb/gcipher.h>
61#include <catacomb/ghash.h>
62#include <catacomb/gmac.h>
63#include <catacomb/md5.h>
64#include <catacomb/md5-hmac.h>
65#include <catacomb/sha.h>
66#include <catacomb/sha-mgf.h>
67#include <catacomb/sha-hmac.h>
68
69#include <catacomb/mp.h>
70#include <catacomb/mpint.h>
71#include <catacomb/mpmul.h>
72#include <catacomb/mpcrt.h>
73#include <catacomb/mpmont.h>
74#include <catacomb/mpbarrett.h>
75#include <catacomb/mpreduce.h>
9c034c56 76#include <catacomb/mp-fibonacci.h>
b6a86d2e 77
78#include <catacomb/pgen.h>
79#include <catacomb/pfilt.h>
80#include <catacomb/strongprime.h>
81#include <catacomb/limlee.h>
82#include <catacomb/dh.h>
83#include <catacomb/ptab.h>
84#include <catacomb/bintab.h>
85#include <catacomb/dsa.h>
86
87#include <catacomb/gf.h>
88#include <catacomb/gfreduce.h>
89#include <catacomb/gfn.h>
90
91#include <catacomb/field.h>
92#include <catacomb/field-guts.h>
93
94#include <catacomb/ec.h>
95#include <catacomb/ec-raw.h>
96#include <catacomb/ectab.h>
97
98#include <catacomb/group.h>
99#include <catacomb/group-guts.h>
100
101#include <catacomb/gdsa.h>
102#include <catacomb/gkcdsa.h>
103#include <catacomb/rsa.h>
104
105#include <catacomb/key.h>
106#include <catacomb/passphrase.h>
107#include <catacomb/pixie.h>
108
73a712fa 109#include <catacomb/share.h>
110#include <catacomb/gfshare.h>
111
b6a86d2e 112/*----- Utility macros ----------------------------------------------------*/
113
114#define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0)
115#define RETURN_NONE RETURN_OBJ(Py_None)
116#define RETURN_NOTIMPL RETURN_OBJ(Py_NotImplemented)
117#define RETURN_TRUE RETURN_OBJ(Py_True)
118#define RETURN_FALSE RETURN_OBJ(Py_False)
119#define RETURN_ME RETURN_OBJ(me)
120
121#define EXCERR(exc, str) do { \
122 PyErr_SetString(exc, str); \
123 goto end; \
124} while (0)
125#define VALERR(str) EXCERR(PyExc_ValueError, str)
126#define TYERR(str) EXCERR(PyExc_TypeError, str)
127#define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
b6a86d2e 128#define SYSERR(str) EXCERR(PyExc_SystemError, str)
68ec53f3 129#define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
73a712fa 130#define INDEXERR(idx) do { \
131 PyErr_SetObject(PyExc_KeyError, idx); \
132 goto end; \
133} while (0)
b6a86d2e 134#define OSERR(name) do { \
135 PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); \
136 goto end; \
137} while (0)
138#define PGENERR do { pgenerr(); goto end; } while (0)
139
140#define CONVFUNC(ty, cty, ext) \
141 int conv##ty(PyObject *o, void *p) \
142 { \
143 if (!PyObject_TypeCheck(o, ty##_pytype)) \
144 TYERR("wanted a " #ty); \
145 *(cty *)p = ext(o); \
146 return (1); \
147 end: \
148 return (0); \
149 }
150
d4a9e7e7
MW
151#if PY_VERSION_HEX < 0x02050000 /* Compatibility hack */
152# define ht_name name
153# define ht_type type
154#endif
155
b6a86d2e 156#define root_pytype 0
157#define type_pytype &PyType_Type
158#define INITTYPE(ty, base) do { \
159 ty##_pytype_skel.tp_base = base##_pytype; \
160 ty##_pytype = inittype(&ty##_pytype_skel); \
161} while (0)
162
163#define INSERT(name, ob) do { \
164 PyObject *_o = (PyObject *)(ob); \
0b1eafbf 165 Py_INCREF(_o); \
b6a86d2e 166 PyModule_AddObject(mod, name, _o); \
167} while (0)
168
73a712fa 169#define INSEXC(name, var, base, meth) \
170 INSERT(name, var = mkexc(mod, base, name, meth))
171
b6a86d2e 172#define METH(func, doc) \
173 { #func, METHNAME(func), METH_VARARGS, doc },
174#define KWMETH(func, doc) \
175 { #func, (PyCFunction)METHNAME(func), \
176 METH_VARARGS | METH_KEYWORDS, doc },
177
178#define GET(func, doc) \
179 { #func, GETSETNAME(get, func), 0, doc },
180#define GETSET(func, doc) \
181 { #func, GETSETNAME(get, func), GETSETNAME(set, func), doc },
182
183#define MEMBER(name, ty, f, doc) \
184 { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },
185
73a712fa 186#define MODULES(_) \
dfe0a897 187 _(util) \
73a712fa 188 _(bytestring) _(buffer) \
189 _(rand) _(algorithms) _(pubkey) _(pgen) \
190 _(mp) _(field) _(ec) _(group) \
dfe0a897 191 _(passphrase) _(share) _(key)
b6a86d2e 192#define DOMODINIT(m) m##_pyinit();
193#define DOMODINSERT(m) m##_pyinsert(mod);
194#define INIT_MODULES do { MODULES(DOMODINIT) } while (0)
195#define INSERT_MODULES do { MODULES(DOMODINSERT) } while (0)
196
197#define DO(m) \
198 extern void m##_pyinit(void); \
199 extern void m##_pyinsert(PyObject *);
200MODULES(DO)
201#undef DO
202
ba45a729 203#define FREEOBJ(obj) \
204 (((PyObject *)(obj))->ob_type->tp_free((PyObject *)(obj)))
205
68ec53f3
MW
206#define GEN(func, base) \
207 static PyObject *func(void) \
208 { \
209 PyObject *d = PyDict_New(); \
210 PyObject *o; \
211 int i; \
212 \
213 for (i = 0; g##base##tab[i]; i++) { \
214 o = gc##base##_pywrap((/*unconst*/ gc##base *)g##base##tab[i]); \
215 PyDict_SetItemString(d, \
216 (/*unconst*/ char *)g##base##tab[i]->name, \
217 o); \
218 Py_DECREF(o); \
219 } \
220 return (d); \
221 }
222
223struct nameval { const char *name; unsigned long value; };
224extern void setconstants(PyObject *, const struct nameval *);
225
226extern PyObject *mexp_common(PyObject *, PyObject *, size_t,
227 PyObject *(*id)(PyObject *),
228 int (*fill)(void *, PyObject *,
229 PyObject *, PyObject *),
230 PyObject *(*exp)(PyObject *, void *, int),
231 void (*drop)(void *));
232
233extern int convulong(PyObject *, void *);
234#define DECL_CONVU_(n) extern int convu##n(PyObject *, void *);
235DOUINTSZ(DECL_CONVU_)
236extern int convmpw(PyObject *, void *);
237extern int convuint(PyObject *, void *);
238extern int convszt(PyObject *, void *);
239extern int convbool(PyObject *, void *);
240extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);
241extern PyObject *getbool(int);
1e082a86 242extern PyObject *getulong(unsigned long);
68ec53f3
MW
243extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *);
244
d2421f3c 245extern PyObject *mkexc(PyObject *, PyObject *, const char *, PyMethodDef *);
0156e402 246extern void typeready(PyTypeObject *);
68ec53f3
MW
247extern PyTypeObject *inittype(PyTypeObject *);
248extern void addmethods(const PyMethodDef *);
249extern PyMethodDef *donemethods(void);
250
251/*----- Mapping methods ---------------------------------------------------*/
252
253#define GMAP_METH(func, doc) { #func, gmapmeth_##func, METH_VARARGS, doc },
254#define GMAP_KWMETH(func, doc) \
255 { #func, (PyCFunction)gmapmeth_##func, METH_VARARGS|METH_KEYWORDS, doc },
256#define GMAP_METHDECL(func, doc) \
257 extern PyObject *gmapmeth_##func(PyObject *, PyObject *);
258#define GMAP_KWMETHDECL(func, doc) \
259 extern PyObject *gmapmeth_##func(PyObject *, PyObject *, PyObject *);
260
2a509510 261#define GMAP_DOROMETHODS(METH, KWMETH) \
68ec53f3
MW
262 METH (has_key, "D.has_key(KEY) -> BOOL") \
263 METH (keys, "D.keys() -> LIST") \
264 METH (values, "D.values() -> LIST") \
265 METH (items, "D.items() -> LIST") \
266 METH (iterkeys, "D.iterkeys() -> ITER") \
267 METH (itervalues, "D.itervalues() -> ITER") \
0b1eafbf 268 METH (iteritems, "D.iteritems() -> ITER") \
68ec53f3 269 KWMETH(get, "D.get(KEY, [default = None]) -> VALUE") \
2a509510
MW
270
271#define GMAP_DOMETHODS(METH, KWMETH) \
272 GMAP_DOROMETHODS(METH, KWMETH) \
273 METH (clear, "D.clear()") \
68ec53f3
MW
274 KWMETH(setdefault, "D.setdefault(K, [default = None]) -> VALUE") \
275 KWMETH(pop, "D.pop(KEY, [default = <error>]) -> VALUE") \
276 METH (popitem, "D.popitem() -> (KEY, VALUE)") \
277 METH (update, "D.update(MAP)")
278
279GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL)
2a509510 280#define GMAP_ROMETHODS GMAP_DOROMETHODS(GMAP_METH, GMAP_KWMETH)
68ec53f3 281#define GMAP_METHODS GMAP_DOMETHODS(GMAP_METH, GMAP_KWMETH)
9d73ed80 282extern Py_ssize_t gmap_pysize(PyObject *);
68ec53f3
MW
283extern PySequenceMethods gmap_pysequence;
284extern PyMethodDef gmap_pymethods[];
285
b6a86d2e 286/*----- Bytestrings -------------------------------------------------------*/
287
288PyTypeObject *bytestring_pyobj;
289PyObject *bytestring_pywrap(const void *, size_t);
290PyObject *bytestring_pywrapbuf(buf *);
291
292/*----- Multiprecision arithmetic -----------------------------------------*/
293
294typedef struct mp_pyobj {
295 PyObject_HEAD
296 mp *x;
297} mp_pyobj;
298
299extern PyTypeObject *mp_pytype;
300extern PyTypeObject *gf_pytype;
301#define MP_X(o) (((mp_pyobj *)(o))->x)
302#define MP_PYCHECK(o) PyObject_TypeCheck((o), mp_pytype)
303#define GF_PYCHECK(o) PyObject_TypeCheck((o), gf_pytype)
304
8d57d6ea
MW
305extern mp *mp_frompylong(PyObject *);
306extern PyObject *mp_topylong(mp *);
b6a86d2e 307extern mp *tomp(PyObject *);
308extern mp *getmp(PyObject *);
309extern int convmp(PyObject *, void *);
310extern mp *getgf(PyObject *);
311extern int convgf(PyObject *, void *);
312extern PyObject *mp_pywrap(mp *);
313extern PyObject *gf_pywrap(mp *);
314extern mp *mp_frompyobject(PyObject *, int);
315extern PyObject *mp_topystring(mp *, int,
316 const char *, const char *, const char *);
317extern int mp_tolong_checked(mp *, long *);
318
319/*----- Abstract fields ---------------------------------------------------*/
320
321typedef struct field_pyobj {
f0526039 322 PyHeapTypeObject ty;
b6a86d2e 323 field *f;
324} field_pyobj;
325
326extern PyTypeObject *fe_pytype;
327#define FE_PYCHECK(o) PyObject_TypeCheck((o), fe_pytype)
328#define FE_F(o) (((fe_pyobj *)(o))->f)
329#define FE_FOBJ(o) ((PyObject *)(o)->ob_type)
330#define FE_X(o) (((fe_pyobj *)(o))->x)
331extern PyObject *fe_pywrap(PyObject *, mp *);
332extern mp *getfe(field *, PyObject *);
333
334typedef struct fe_pyobj {
335 PyObject_HEAD
336 field *f;
b6a86d2e 337 mp *x;
338} fe_pyobj;
0b1eafbf 339
b6a86d2e 340extern PyTypeObject *field_pytype;
341extern PyTypeObject *primefield_pytype;
342extern PyTypeObject *niceprimefield_pytype;
343extern PyTypeObject *binfield_pytype;
344extern PyTypeObject *binpolyfield_pytype;
345extern PyTypeObject *binnormfield_pytype;
346#define FIELD_PYCHECK(o) PyObject_TypeCheck((o), field_pytype)
347#define FIELD_F(o) (((field_pyobj *)(o))->f)
348extern PyObject *field_pywrap(field *);
349extern field *field_copy(field *);
350
351/*----- Elliptic curves ---------------------------------------------------*/
352
353typedef struct ecpt_pyobj {
354 PyObject_HEAD
355 ec_curve *c;
356 ec p;
357} ecpt_pyobj;
358
359extern PyTypeObject *ecpt_pytype, *ecptcurve_pytype;
360#define ECPT_PYCHECK(o) PyObject_TypeCheck((o), ecpt_pytype)
361#define ECPTCURVE_PYCHECK(o) PyObject_TypeCheck((o), ecptcurve_pytype)
362#define ECPT_C(o) (((ecpt_pyobj *)(o))->c)
363#define ECPT_COBJ(o) ((PyObject *)(o)->ob_type)
364#define ECPT_FOBJ(o) ECCURVE_FOBJ(ECPT_COBJ((o)))
365#define ECPT_P(o) (&((ecpt_pyobj *)(o))->p)
366extern PyObject *ecpt_pywrap(PyObject *, ec *);
367extern PyObject *ecpt_pywrapout(void *, ec *);
368extern int toecpt(ec_curve *, ec *, PyObject *);
369extern int getecpt(ec_curve *, ec *, PyObject *);
370extern void getecptout(ec *, PyObject *);
73a712fa 371extern int convecpt(PyObject *, void *);
b6a86d2e 372
373typedef struct eccurve_pyobj {
f0526039 374 PyHeapTypeObject ty;
b6a86d2e 375 ec_curve *c;
376 PyObject *fobj;
377} eccurve_pyobj;
378
379extern PyTypeObject *eccurve_pytype;
380extern PyTypeObject *ecprimecurve_pytype;
381extern PyTypeObject *ecprimeprojcurve_pytype;
382extern PyTypeObject *ecbincurve_pytype;
383extern PyTypeObject *ecbinprojcurve_pytype;
384#define ECCURVE_PYCHECK(o) PyObject_TypeCheck((o), eccurve_pytype)
385#define ECCURVE_C(o) (((eccurve_pyobj *)(o))->c)
386#define ECCURVE_FOBJ(o) (((eccurve_pyobj *)(o))->fobj)
387extern PyObject *eccurve_pywrap(PyObject *, ec_curve *);
388extern ec_curve *eccurve_copy(ec_curve *);
389
390typedef struct ecinfo_pyobj {
391 PyObject_HEAD
392 ec_info ei;
393 PyObject *cobj;
394} ecinfo_pyobj;
0b1eafbf 395
b6a86d2e 396extern PyTypeObject *ecinfo_pytype;
397#define ECINFO_PYCHECK(o) PyObject_TypeCheck((o), ecinfo_pytype)
398#define ECINFO_EI(o) (&((ecinfo_pyobj *)(o))->ei)
399#define ECINFO_COBJ(o) (((ecinfo_pyobj *)(o))->cobj)
400extern void ecinfo_copy(ec_info *, const ec_info *);
401extern PyObject *ecinfo_pywrap(ec_info *);
402
403/*----- Cyclic groups -----------------------------------------------------*/
404
405typedef struct fginfo_pyobj {
406 PyObject_HEAD
407 gprime_param dp;
408} fginfo_pyobj;
409
410PyTypeObject *fginfo_pytype, *dhinfo_pytype, *bindhinfo_pytype;
411#define FGINFO_DP(fg) (&((fginfo_pyobj *)(fg))->dp)
412PyObject *fginfo_pywrap(gprime_param *, PyTypeObject *);
413
414typedef struct ge_pyobj {
415 PyObject_HEAD
416 ge *x;
417 group *g;
418} ge_pyobj;
419
420extern PyTypeObject *ge_pytype;
421#define GE_PYCHECK(o) PyObject_TypeCheck((o), ge_pytype)
422#define GE_X(o) (((ge_pyobj *)(o))->x)
423#define GE_G(o) (((ge_pyobj *)(o))->g)
424#define GE_GOBJ(o) ((PyObject *)(group_pyobj *)(o)->ob_type)
425extern PyObject *ge_pywrap(PyObject *, ge *);
426
427typedef struct group_pyobj {
f0526039 428 PyHeapTypeObject ty;
b6a86d2e 429 group *g;
430} group_pyobj;
431
432extern PyTypeObject *group_pytype;
433extern PyTypeObject *primegroup_pytype, *bingroup_pytype, *ecgroup_pytype;
434#define GROUP_G(o) (((group_pyobj *)(o))->g)
435extern PyObject *group_pywrap(group *);
436extern group *group_copy(group *);
437
438/*----- Random number generators ------------------------------------------*/
439
440#define f_freeme 1u
441
442typedef struct grand_pyobj {
443 PyObject_HEAD
444 unsigned f;
445 grand *r;
446} grand_pyobj;
447
448extern PyTypeObject *grand_pytype, *truerand_pytype;
449extern PyTypeObject *lcrand_pytype,* fibrand_pytype;
450extern PyTypeObject *dsarand_pytype, *bbs_pytype;
451extern PyObject *rand_pyobj;
452#define GRAND_PYCHECK(o) PyObject_TypeCheck((o), grand_pytype)
453#define GRAND_F(o) (((grand_pyobj *)(o))->f)
454#define GRAND_R(o) (((grand_pyobj *)(o))->r)
455extern PyObject *grand_pywrap(grand *, unsigned);
456extern int convgrand(PyObject *, void *);
457
458/*----- Key sizes ---------------------------------------------------------*/
459
460typedef struct keysz_pyobj {
461 PyObject_HEAD
462 int dfl;
463} keysz_pyobj;
464
465typedef struct keyszrange_pyobj {
466 PyObject_HEAD
467 int dfl;
468 int min, max, mod;
469} keyszrange_pyobj;
470
471typedef struct keyszset_pyobj {
472 PyObject_HEAD
473 int dfl;
474 PyObject *set;
475} keyszset_pyobj;
476
477#define KEYSZ_PYCHECK(o) PyObject_TypeCheck((o), keysz_pytype)
478extern PyObject *keysz_pywrap(const octet *);
479
480/*----- Symmetric cryptography --------------------------------------------*/
481
482typedef struct gccipher_pyobj {
f0526039 483 PyHeapTypeObject ty;
b6a86d2e 484 gccipher *cc;
485} gccipher_pyobj;
486
487extern PyTypeObject *gccipher_pytype;
488#define GCCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gccipher_pytype)
489#define GCCIPHER_CC(o) (((gccipher_pyobj *)(o))->cc)
490#define GCCIPHER_F(o) (((gccipher_pyobj *)(o))->f)
491extern PyObject *gccipher_pywrap(gccipher *);
492extern int convgccipher(PyObject *, void *);
493extern int convgcipher(PyObject *, void *);
494
495typedef struct gcipher_pyobj {
496 PyObject_HEAD
497 unsigned f;
498 gcipher *c;
499} gcipher_pyobj;
500
501extern PyTypeObject *gcipher_pytype;
502#define GCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gcipher_pytype)
503#define GCIPHER_C(o) (((gcipher_pyobj *)(o))->c)
504#define GCIPHER_F(o) (((gcipher_pyobj *)(o))->f)
505extern PyObject *gcipher_pywrap(PyObject *, gcipher *, unsigned);
506extern int convgcipher(PyObject *, void *);
507
508typedef struct gchash_pyobj {
f0526039 509 PyHeapTypeObject ty;
b6a86d2e 510 gchash *ch;
511} gchash_pyobj;
512
513extern PyTypeObject *gchash_pytype;
514#define GCHASH_PYCHECK(o) PyObject_TypeCheck((o), gchash_pytype)
515#define GCHASH_CH(o) (((gchash_pyobj *)(o))->ch)
516#define GCHASH_F(o) (((gchash_pyobj *)(o))->f)
517extern PyObject *gchash_pywrap(gchash *);
518extern int convgchash(PyObject *, void *);
519
520typedef struct ghash_pyobj {
521 PyObject_HEAD
522 unsigned f;
523 ghash *h;
524} ghash_pyobj;
525
526extern PyTypeObject *ghash_pytype, *gmhash_pytype;
527extern PyObject *sha_pyobj, *has160_pyobj;
528#define GHASH_PYCHECK(o) PyObject_TypeCheck((o), ghash_pytype)
529#define GHASH_H(o) (((ghash_pyobj *)(o))->h)
530#define GHASH_F(o) (((ghash_pyobj *)(o))->f)
531extern PyObject *ghash_pywrap(PyObject *, ghash *, unsigned);
532extern int convghash(PyObject *, void *);
533extern int convgmhash(PyObject *, void *);
534
535typedef struct gcmac_pyobj {
f0526039 536 PyHeapTypeObject ty;
b6a86d2e 537 gcmac *cm;
538} gcmac_pyobj;
539
540extern PyTypeObject *gcmac_pytype;
541#define GCMAC_PYCHECK(o) PyObject_TypeCheck((o), gcmac_pytype)
542#define GCMAC_CM(o) (((gcmac_pyobj *)(o))->cm)
543#define GCMAC_F(o) (((gcmac_pyobj *)(o))->f)
544extern PyObject *gcmac_pywrap(gcmac *);
545extern int convgcmac(PyObject *, void *);
546
547typedef struct gmac_pyobj {
f0526039 548 PyHeapTypeObject ty;
b6a86d2e 549 unsigned f;
550 gmac *m;
b6a86d2e 551} gmac_pyobj;
552
553extern PyTypeObject *gmac_pytype;
554#define GMAC_PYCHECK(o) PyObject_TypeCheck((o), gmac_pytype)
555#define GMAC_M(o) (((gmac_pyobj *)(o))->m)
b6a86d2e 556#define GMAC_F(o) (((gmac_pyobj *)(o))->f)
557extern PyObject *gmac_pywrap(PyObject *, gmac *, unsigned);
558extern int convgmac(PyObject *, void *);
559
b6a86d2e 560/*----- Key generation ----------------------------------------------------*/
0b1eafbf 561
b6a86d2e 562typedef struct pfilt_pyobj {
563 PyObject_HEAD
564 pfilt f;
565 int st;
566} pfilt_pyobj;
567
568extern PyTypeObject *pfilt_pytype;
569#define PFILT_PYCHECK(o) PyObject_TypeCheck(o, pfilt_pytype)
570#define PFILT_F(o) (&((pfilt_pyobj *)(o))->f)
571#define PFILT_ST(o) (((pfilt_pyobj *)(o))->st)
572
573typedef struct { pgen_proc *proc; void *ctx; } pgev;
574#define PGEV_HEAD PyObject_HEAD pgev pg;
575
576typedef struct pgev_pyobj {
577 PGEV_HEAD
578} pgev_pyobj;
579
580extern PyTypeObject *pgev_pytype;
581#define PGEV_PYCHECK(o) PyObject_TypeCheck(o, pgev_pytype)
582#define PGEV_PG(o) (&((pgev_pyobj *)(o))->pg)
583
584extern int convpgev(PyObject *, void *);
585extern void droppgev(pgev *);
586extern void pgenerr(void);
587
b6a86d2e 588/*----- That's all, folks -------------------------------------------------*/
589
590#ifdef __cplusplus
591 }
592#endif
593
594#endif