X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/850a4b483975ef7081ea7fabfa2e90f99a1844a9..96851f5db8542a4630aaa9b0dbe7cb0495b5ab8b:/rand.c diff --git a/rand.c b/rand.c index 4b40a75..fee2a9b 100644 --- a/rand.c +++ b/rand.c @@ -7,7 +7,7 @@ * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the Python interface to Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * Catacomb/Python 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 General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Catacomb/Python; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -80,7 +80,7 @@ static PyObject *grmeth_byte(PyObject *me, PyObject *arg) static PyObject *grmeth_word(PyObject *me, PyObject *arg) { if (!PyArg_ParseTuple(arg, ":word")) return (0); - return (getu32(grand_word(GRAND_R(me)))); + return (getulong(grand_word(GRAND_R(me)))); } static PyObject *grmeth_range(PyObject *me, PyObject *arg) @@ -524,7 +524,7 @@ static PyObject *trget_goodbits(PyObject *me, void *hunoz) static PyGetSetDef truerand_pygetset[] = { #define GETSETNAME(op, name) tr##op##_##name - GET (goodbits, "R.goodbits -> good bits of entropy remaining") + GET (goodbits, "R.goodbits -> good bits of entropy remaining") #undef GETSETNAME { 0 } }; @@ -619,7 +619,7 @@ static PyObject *gcrand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) if (keysz(n, info->keysz) != n) VALERR("bad key length"); return (grand_dopywrap(ty, info->func(k, n), f_freeme)); end: - return (0); + return (0); } static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) @@ -638,26 +638,26 @@ static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) ((gcirand_func *)info->func)(k, n, i), f_freeme)); end: - return (0); + return (0); } static PyObject *gccrand_pywrap(const gccrand_info *info) { gccrand_pyobj *g = newtype(gccrand_pytype, 0, info->name); g->info = info; - g->ty.type.tp_basicsize = sizeof(grand_pyobj); - g->ty.type.tp_base = gcrand_pytype; + g->ty.ht_type.tp_basicsize = sizeof(grand_pyobj); + g->ty.ht_type.tp_base = gcrand_pytype; Py_INCREF(gcrand_pytype); - g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.type.tp_alloc = PyType_GenericAlloc; - g->ty.type.tp_free = 0; + 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; if (info->f & RNGF_INT) - g->ty.type.tp_new = gcirand_pynew; + g->ty.ht_type.tp_new = gcirand_pynew; else - g->ty.type.tp_new = gcrand_pynew; - PyType_Ready(&g->ty.type); + g->ty.ht_type.tp_new = gcrand_pynew; + PyType_Ready(&g->ty.ht_type); return ((PyObject *)g); } @@ -1076,7 +1076,7 @@ static PyObject *bbsmeth_bits(PyObject *me, PyObject *arg) grand *r = GRAND_R(me); unsigned n; uint32 w; if (!PyArg_ParseTuple(arg, "O&:bits", convuint, &n)) goto end; if (n > 32) VALERR("can't get more than 32 bits"); - r->ops->misc(r, BBS_BITS, n, &w); return (getu32(w)); + r->ops->misc(r, BBS_BITS, n, &w); return (getulong(w)); end: return (0); } @@ -1236,7 +1236,7 @@ static PyObject *meth__BBSPriv_generate(PyObject *me, rc->bp.n = MP_COPY(bp.n); end: mp_drop(bp.p); mp_drop(bp.q); mp_drop(bp.n); mp_drop(x); - return ((PyObject *)rc); + return ((PyObject *)rc); } static void bbspriv_pydealloc(PyObject *me) @@ -1281,9 +1281,9 @@ static PyMethodDef bbspriv_pymethods[] = { static PyGetSetDef bbspriv_pygetset[] = { #define GETSETNAME(op, name) bp##op##_##name - GET (n, "R.n -> Blum modulus") - GET (p, "R.p -> one of the factors of the modulus") - GET (q, "R.q -> one of the factors of the modulus") + GET (n, "R.n -> Blum modulus") + GET (p, "R.p -> one of the factors of the modulus") + GET (q, "R.q -> one of the factors of the modulus") #undef GETSETNAME { 0 } };