/* -*-c-*-
- *
- * $Id$
*
* Random-number generators
*
* (c) 2004 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of the Python interface to Catacomb.
*
* 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.
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)
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 }
};
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)
((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);
}
goto end;
rc = grand_dopywrap(ty, dsarand_create(p, sz), f_freeme);
end:
- return (0);
+ return (rc);
}
static PyObject *drget_seed(PyObject *me, void *hunoz)
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);
}
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)
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 }
};