chiark / gitweb /
Merge branch '1.1.x'
authorMark Wooding <mdw@distorted.org.uk>
Sun, 14 May 2017 03:28:02 +0000 (04:28 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 14 May 2017 03:28:02 +0000 (04:28 +0100)
* 1.1.x:
  Release 1.1.2.
  catacomb/__init__.py: Fix up cipher etc. names better.
  algorithms.c: Support the new 16-bit key-size descriptors.
  group.c: Track Catacomb group internals change.
  utils.c: Raise exceptions from `convTHING' with null arguments.
  Return `long' objects when `int' is requested but the value won't fit.
  bytestring.c: Check for cached hash more carefully.
  rand.c: Careful range checking on `block' and `mp'.
  *.c: Fix docstrings for methods.
  Further fixing to use `Py_ssize_t' in place of int.

Conflicts:
debian/control (already wanted later catacomb-dev)
group.c (no need for compatibility with older Catacombs)

algorithms.c
catacomb/__init__.py
debian/changelog
util.c

index 5b4f14b0e7d982922a8f0145efd1246c0269ada6..5703901fae129b68ea01e366884c6cbe94ff8e63 100644 (file)
@@ -35,21 +35,31 @@ PyTypeObject *keysz_pytype;
 PyTypeObject *keyszany_pytype, *keyszrange_pytype, *keyszset_pytype;
 PyObject *sha_pyobj, *has160_pyobj;
 
+#ifndef KSZ_OPMASK
+#  define KSZ_OPMASK 0x1f
+#endif
+
+#ifndef KSZ_16BIT
+#  define KSZ_16BIT 0x20
+#endif
+
 PyObject *keysz_pywrap(const octet *k)
 {
-  switch (k[0]) {
+  unsigned op = *k++;
+#define ARG(i) (op&KSZ_16BIT ? LOAD16(k + 2*(i)) : k[i])
+  switch (op&KSZ_OPMASK) {
     case KSZ_ANY: {
       keysz_pyobj *o = PyObject_New(keysz_pyobj, keyszany_pytype);
-      o->dfl = k[1];
+      o->dfl = ARG(0);
       return ((PyObject *)o);
     } break;
     case KSZ_RANGE: {
       keyszrange_pyobj *o =
        PyObject_New(keyszrange_pyobj, keyszrange_pytype);
-      o->dfl = k[1];
-      o->min = k[2];
-      o->max = k[3];
-      o->mod = k[4];
+      o->dfl = ARG(0);
+      o->min = ARG(1);
+      o->max = ARG(2);
+      o->mod = ARG(3);
       if (!o->mod) o->mod = 1;
       return ((PyObject *)o);
     } break;
@@ -57,16 +67,17 @@ PyObject *keysz_pywrap(const octet *k)
       keyszset_pyobj *o =
        PyObject_New(keyszset_pyobj, keyszset_pytype);
       int i, n;
-      o->dfl = k[1];
-      for (i = 0; k[i + 1]; i++) ;
+      o->dfl = ARG(0);
+      for (i = 0; ARG(i); i++) ;
       n = i; o->set = PyTuple_New(n);
       for (i = 0; i < n; i++)
-       PyTuple_SET_ITEM(o->set, i, PyInt_FromLong(k[i + 1]));
+       PyTuple_SET_ITEM(o->set, i, PyInt_FromLong(ARG(i)));
       return ((PyObject *)o);
     } break;
     default:
       abort();
   }
+#undef ARG
 }
 
 static PyObject *keyszany_pynew(PyTypeObject *ty,
index 6fc3725abf51aed1bbce16ab42fabe662e8df029..785838e67eb94830a2358670bcd86049ac0e889c 100644 (file)
@@ -34,6 +34,20 @@ from sys import argv as _argv
 ## For the benefit of the default keyreporter, we need the program na,e.
 _base._ego(_argv[0])
 
+## How to fix a name back into the right identifier.  Alas, the rules are not
+## consistent.
+def _fixname(name):
+
+  ## Hyphens consistently become underscores.
+  name = name.replace('-', '_')
+
+  ## But slashes might become underscores or just vanish.
+  if name.startswith('salsa20'): name = name.translate(None, '/')
+  else: name = name.replace('/', '_')
+
+  ## Done.
+  return name
+
 ## Initialize the module.  Drag in the static methods of the various
 ## classes; create names for the various known crypto algorithms.
 def _init():
@@ -56,9 +70,9 @@ def _init():
         setattr(c, j[plen:], classmethod(b[j]))
   for i in [gcciphers, gchashes, gcmacs, gcprps]:
     for c in i.itervalues():
-      d[c.name.replace('-', '_').translate(None, '/')] = c
+      d[_fixname(c.name)] = c
   for c in gccrands.itervalues():
-    d[c.name.replace('-', '_').translate(None, '/') + 'rand'] = c
+    d[_fixname(c.name + 'rand')] = c
 _init()
 
 ## A handy function for our work: add the methods of a named class to an
index c7895ba435b146c21237a6d0e9adefa007f19e60..7f5abd28e6dd29a1c8d38e3cf19184500da168c1 100644 (file)
@@ -1,3 +1,18 @@
+catacomb-python (1.1.2) experimental; urgency=low
+
+  * Further 64-bit compatibility improvements.
+  * Fixed docstrings for a number of native methods.
+  * Fix range checking for `GRand' methods.
+  * Fix crash when deleting natively implemented object attributes.
+  * Fix bug which assigned the wrong hash to bytestrings.
+  * Fix `__int__' methods to return `long' objects when necessary.
+    Without this, there are unnecessary failures and bizarrely timed
+    exceptions.
+  * A couple of patches to provide forward compatibility with upstream
+    library changes.
+
+ -- Mark Wooding <mdw@distorted.org.uk>  Sun, 14 May 2017 04:25:35 +0100
+
 catacomb-python (1.1.1) experimental; urgency=low
 
   * ByteString operators: fix crashes on 64-bit platforms resulting from
diff --git a/util.c b/util.c
index 58d2fe7ebd7525998e4211983541b3ed5125fa6d..d4b7fb060d189ffbea18e68cc1f4d572cb7ef391 100644 (file)
--- a/util.c
+++ b/util.c
@@ -83,6 +83,7 @@ int convulong(PyObject *o, void *pp)
   unsigned long *p = pp;
   PyObject *t;
 
+  if (!o) VALERR("can't delete");
   if (PyInt_Check(o)) {
     i = PyInt_AS_LONG(o);
     if (i < 0) VALERR("must be nonnegative");
@@ -176,8 +177,11 @@ end:
 
 int convbool(PyObject *o, void *pp)
 {
+  if (!o) VALERR("can't delete");
   *(int *)pp = PyObject_IsTrue(o);
   return (1);
+end:
+  return (0);
 }
 
 /*----- Type messing ------------------------------------------------------*/