rand.c: Fix `TrueRand' constructor so it can possibly work.
[catacomb-python] / algorithms.c
index 0f05f75..61459a1 100644 (file)
@@ -1568,7 +1568,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 +1645,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);
@@ -1675,10 +1675,14 @@ static int kxvikset_nround(PyObject *me, PyObject *val, void *hunoz)
 {
   kxvik_pyobj *k = (kxvik_pyobj *)me;
   unsigned n;
+  int rc = -1;
 
-  if (!convuint(val, &n)) return (-1);
+  if (!val) NIERR("__del__");
+  if (!convuint(val, &n)) goto end;
   k->n = n;
-  return (0);
+  rc = 0;
+end:
+  return (rc);
 }
 
 static PyGetSetDef kxvik_pygetset[] = {
@@ -1876,7 +1880,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)