Seems like strings of zero bytes are especially useful. Add a class
method to `ByteString' to generate them efficiently, and use it to make
the magic `Z128' constant.
+static PyObject *meth__ByteString_zero(PyObject *me, PyObject *arg)
+{
+ size_t sz;
+ PyObject *rc = 0;
+ if (!PyArg_ParseTuple(arg, "OO&:zero", &me, convszt, &sz)) goto end;
+ rc = bytestring_pywrap(0, sz);
+ memset(PyString_AS_STRING(rc), 0, sz);
+end:
+ return (rc);
+}
+
static PyObject *bytestring_pyrichcompare(PyObject *me,
PyObject *you, int op)
{
static PyObject *bytestring_pyrichcompare(PyObject *me,
PyObject *you, int op)
{
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
METH (ctstreq, "ctstreq(S, T) -> BOOL")
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
METH (ctstreq, "ctstreq(S, T) -> BOOL")
+ METH (_ByteString_zero, "zero(N) -> 0000...00")
for i in b:
if i[0] != '_':
d[i] = b[i];
for i in b:
if i[0] != '_':
d[i] = b[i];
- for i in ['MP', 'GF', 'Field',
+ for i in ['ByteString',
+ 'MP', 'GF', 'Field',
'ECPt', 'ECPtCurve', 'ECCurve', 'ECInfo',
'DHInfo', 'BinDHInfo', 'RSAPriv', 'BBSPriv',
'PrimeFilter', 'RabinMiller',
'ECPt', 'ECPtCurve', 'ECCurve', 'ECInfo',
'DHInfo', 'BinDHInfo', 'RSAPriv', 'BBSPriv',
'PrimeFilter', 'RabinMiller',
X25519_BASE = MP(9).storel(32)
X448_BASE = MP(5).storel(56)
X25519_BASE = MP(9).storel(32)
X448_BASE = MP(5).storel(56)
-Z128 = bytes('00000000000000000000000000000000')
+Z128 = ByteString.zero(16)
class _BoxyPub (object):
def __init__(me, pub, *args, **kw):
class _BoxyPub (object):
def __init__(me, pub, *args, **kw):