X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/d26c1ca84b76aa4c85b33ffbb0ee0a82cb75c092..8ebf420c2d64a7fc9461b6c811d7ea6c309d9d06:/algorithms.c diff --git a/algorithms.c b/algorithms.c index 3d79c03..edd73fd 100644 --- a/algorithms.c +++ b/algorithms.c @@ -138,9 +138,8 @@ static PyObject *keyszset_pynew(PyTypeObject *ty, if (!set) set = PyTuple_New(0); else Py_INCREF(set); if (!PySequence_Check(set)) TYERR("want a sequence"); - n = PySequence_Size(set); - l = PyList_New(0); - if (PyErr_Occurred()) goto end; + n = PySequence_Size(set); if (n < 0) goto end; + l = PyList_New(0); if (!l) goto end; if (dfl < 0) VALERR("key size cannot be negative"); x = PyInt_FromLong(dfl); PyList_Append(l, x); @@ -209,7 +208,7 @@ static PyMemberDef keysz_pymembers[] = { static PyGetSetDef keyszany_pygetset[] = { #define GETSETNAME(op, name) ka##op##_##name GET (min, "KSZ.min -> smallest allowed key size") - GET (max, "KSZ.min -> largest allowed key size") + GET (max, "KSZ.max -> largest allowed key size") #undef GETSETNAME { 0 } }; @@ -217,7 +216,7 @@ static PyGetSetDef keyszany_pygetset[] = { static PyMemberDef keyszrange_pymembers[] = { #define MEMBERSTRUCT keyszrange_pyobj MEMBER(min, T_INT, READONLY, "KSZ.min -> smallest allowed key size") - MEMBER(max, T_INT, READONLY, "KSZ.min -> largest allowed key size") + MEMBER(max, T_INT, READONLY, "KSZ.max -> largest allowed key size") MEMBER(mod, T_INT, READONLY, "KSZ.mod -> key size must be a multiple of this") #undef MEMBERSTRUCT @@ -227,7 +226,7 @@ static PyMemberDef keyszrange_pymembers[] = { static PyGetSetDef keyszset_pygetset[] = { #define GETSETNAME(op, name) ks##op##_##name GET (min, "KSZ.min -> smallest allowed key size") - GET (max, "KSZ.min -> largest allowed key size") + GET (max, "KSZ.max -> largest allowed key size") #undef GETSETNAME { 0 } }; @@ -1568,7 +1567,7 @@ static PyTypeObject poly1305hash_pytype_skel = { if (!PyArg_ParseTuple(arg, "s#s#:" #hdance "_prf", \ &k, &ksz, &n, &nsz)) \ goto end; \ - if (ksz != DANCE##_KEYSZ) VALERR("bad key length"); \ + if (ksz != keysz(ksz, dance##_keysz)) VALERR("bad key length"); \ if (nsz != HDANCE##_INSZ) VALERR("bad input length"); \ rc = bytestring_pywrap(0, HSALSA20_OUTSZ); \ dance##_init(&dance, k, ksz, 0); \ @@ -1645,7 +1644,7 @@ static PyObject *kxvikmeth_extract(PyObject *me, PyObject *arg) unsigned i; unsigned n; - if (!PyArg_ParseTuple(arg, "O&:mix", convuint, &n)) goto end; + if (!PyArg_ParseTuple(arg, "O&:extract", convuint, &n)) goto end; if (n > 200) VALERR("out of range"); rc = bytestring_pywrap(0, n); q = (octet *)PyString_AS_STRING(rc); @@ -1880,7 +1879,7 @@ static PyObject *shakemeth_copy(PyObject *me, PyObject *arg) rc->h = *SHAKE_H(me); rc->st = SHAKE_ST(me); end: - return ((PyObject *)me); + return ((PyObject *)rc); } static PyObject *shakemeth_get(PyObject *me, PyObject *arg)