Merge branch '1.3.x'
authorMark Wooding <mdw@distorted.org.uk>
Wed, 27 Nov 2019 15:12:23 +0000 (15:12 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 27 Nov 2019 15:12:23 +0000 (15:12 +0000)
* 1.3.x: (101 commits)
  rand.c: Show keyword argument as optional.
  mp.c: Fix punctuation error in docstrings.
  t/t-*.py: Use the `WriteBuffer.contents' property.
  t/t-bytes.py: Check that indexing, slicing, etc. return `C.ByteString'.
  t/t-algorithms.py: Add a simple test for `Keccak1600.copy'.
  t/t-algorithms.py: Add tests for other HSalsa20 and HChaCha key sizes.
  t/t-algorithms.py: Add AEAD tests.
  t/t-algorithms.py: Add tests for the new `KeySZ.pad' method.
  catacomb/__init__.py (KeySZRange.pad): Return correct value.
  algorithms.c: Propagate `AEADF_NOAAD' to `aad' objects.
  algorithms.c (AEADAAD.copy): Propagate the hashed length to the copy.
  t/: Add a test suite.
  ec.c: Don't lose error status when constructing points from a sequence.
  ec.c: Free partially constructed points coordinatewise.
  *.c: Be more careful about `PySequence_Size'.
  key.c: Reformat the rest of the `KeyError' constructor.
  key.c: Parse `KeyError' constructor arguments by hand.
  catacomb-python.h: Add a macro for raising `OverflowError'.
  key.c: Collect `KeyError' argument count as a separate step.
  key.c: Use tuple functions on `KeyError' argument tuple.
  ...

algorithms.c
catacomb-python.h
catacomb.c
debian/changelog
debian/compat
debian/control
ec.c
field.c
group.c
rand.c
setup.py

index 064fb03..888ceb0 100644 (file)
@@ -27,7 +27,9 @@
 /*----- Header files ------------------------------------------------------*/
 
 #include "catacomb-python.h"
+PUBLIC_SYMBOLS;
 #include "algorithms.h"
+PRIVATE_SYMBOLS;
 
 /*----- Key sizes ---------------------------------------------------------*/
 
@@ -2667,8 +2669,7 @@ typedef struct kxvik_pyobj {
   unsigned n;
 } kxvik_pyobj;
 
-static PyObject *kxvik_pynew(PyTypeObject *ty,
-                                 PyObject *arg, PyObject *kw)
+static PyObject *kxvik_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   unsigned n = 24;
   kxvik_pyobj *rc = 0;
index 6c1ae21..bf3d426 100644 (file)
 #include <catacomb/share.h>
 #include <catacomb/gfshare.h>
 
+/*----- Other preliminaries -----------------------------------------------*/
+
+#define GOBBLE_SEMI extern int notexist
+#if defined(__GNUC__) && defined(__ELF__)
+#  define PRIVATE_SYMBOLS _Pragma("GCC visibility push(hidden)") GOBBLE_SEMI
+#  define PUBLIC_SYMBOLS _Pragma("GCC visibility pop") GOBBLE_SEMI
+#  define EXPORT __attribute__((__visibility__("default")))
+#else
+#  define PRIVATE_SYMBOLS GOBBLE_SEMI
+#  define PUBLIC_SYMBOLS GOBBLE_SEMI
+#  define EXPORT
+#endif
+
+PRIVATE_SYMBOLS;
+
 /*----- Utility macros ----------------------------------------------------*/
 
 #define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0)
index e9c9513..e868f0f 100644 (file)
@@ -144,7 +144,7 @@ static PyObject *meth__ego(PyObject *me, PyObject *arg)
   char *argv0;
   if (!PyArg_ParseTuple(arg, "s:_ego", &argv0))
     return (0);
-  if (strcmp(QUIS, "<UNNAMED>") == 0)
+  if (STRCMP(QUIS, ==, "<UNNAMED>"))
     ego(argv0);
   RETURN_NONE;
 }
@@ -164,14 +164,14 @@ static void init_random(void)
 
   if (!Py_HashRandomizationFlag) return;
   seed = getenv("PYTHONHASHSEED");
-  if (!seed || strcmp(seed, "random") == 0) r = GR_WORD(&rand_global);
+  if (!seed || STRCMP(seed, ==, "random")) r = GR_WORD(&rand_global);
   else r = strtoul(seed, 0, 0);
   if (!r) r = 0xe011f220; /* zero doesn't work well */
   unihash_setkey(&unihash_global, r);
 #endif
 }
 
-void init_base(void)
+EXPORT void init_base(void)
 {
   PyObject *mod;
   addmethods(methods);
index 0398864..66c14f7 100644 (file)
@@ -1,3 +1,9 @@
+catacomb-python (1.3.99~) experimental; urgency=medium
+
+  * (placeholder for next release)
+
+ -- Mark Wooding <mdw@distorted.org.uk>  Tue, 01 Oct 2019 12:57:58 +0100
+
 catacomb-python (1.3.0.1) experimental; urgency=medium
 
   * Fix required Catacomb version in `setup.py' script.  Only affects the
index ec63514..f599e28 100644 (file)
@@ -1 +1 @@
-9
+10
index 1bde721..7b7400d 100644 (file)
@@ -3,9 +3,9 @@ Section: python
 Priority: extra
 XS-Python-Version: >= 2.6, << 2.8
 Maintainer: Mark Wooding <mdw@distorted.org.uk>
-Build-Depends: debhelper (>= 9), dh-python, pkg-config,
+Build-Depends: debhelper (>= 10), dh-python, pkg-config,
        python (>= 2.6.6-3~), python-all-dev,
-       mlib-dev (>= 2.2.2.1), catacomb-dev (>= 2.5.0)
+       mlib-dev (>= 2.4.99~), catacomb-dev (>= 2.5.0)
 Standards-Version: 3.8.0
 
 Package: python-catacomb
diff --git a/ec.c b/ec.c
index 184dc9e..a660eb6 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -48,13 +48,13 @@ ec_curve *eccurve_copy(ec_curve *c)
     return (0);
   a = F_OUT(f, MP_NEW, c->a);
   b = F_OUT(f, MP_NEW, c->b);
-  if (strcmp(EC_NAME(c), "prime") == 0)
+  if (STRCMP(EC_NAME(c), ==, "prime"))
     c = ec_prime(f, a, b);
-  else if (strcmp(EC_NAME(c), "primeproj") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "primeproj"))
     c = ec_primeproj(f, a, b);
-  else if (strcmp(EC_NAME(c), "bin") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "bin"))
     c = ec_bin(f, a, b);
-  else if (strcmp(EC_NAME(c), "binproj") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "binproj"))
     c = ec_binproj(f, a, b);
   else
     c = 0;
@@ -983,13 +983,13 @@ PyObject *eccurve_pywrap(PyObject *fobj, ec_curve *c)
   else
     Py_INCREF(fobj);
   assert(FIELD_F(fobj) == c->f);
-  if (strcmp(EC_NAME(c), "prime") == 0)
+  if (STRCMP(EC_NAME(c), ==, "prime"))
     ty = ecprimecurve_pytype;
-  else if (strcmp(EC_NAME(c), "primeproj") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "primeproj"))
     ty = ecprimeprojcurve_pytype;
-  else if (strcmp(EC_NAME(c), "bin") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "bin"))
     ty = ecbincurve_pytype;
-  else if (strcmp(EC_NAME(c), "binproj") == 0)
+  else if (STRCMP(EC_NAME(c), ==, "binproj"))
     ty = ecbinprojcurve_pytype;
   else
     abort();
diff --git a/field.c b/field.c
index c23f311..417c550 100644 (file)
--- a/field.c
+++ b/field.c
@@ -74,23 +74,23 @@ PyObject *field_pywrap(field *f)
 {
   PyTypeObject *ty;
 
-  if (strcmp(F_NAME(f), "prime") == 0) ty = primefield_pytype;
-  else if (strcmp(F_NAME(f), "niceprime") == 0) ty = niceprimefield_pytype;
-  else if (strcmp(F_NAME(f), "binpoly") == 0) ty = binpolyfield_pytype;
-  else if (strcmp(F_NAME(f), "binnorm") == 0) ty = binnormfield_pytype;
+  if (STRCMP(F_NAME(f), ==, "prime")) ty = primefield_pytype;
+  else if (STRCMP(F_NAME(f), ==, "niceprime")) ty = niceprimefield_pytype;
+  else if (STRCMP(F_NAME(f), ==, "binpoly")) ty = binpolyfield_pytype;
+  else if (STRCMP(F_NAME(f), ==, "binnorm")) ty = binnormfield_pytype;
   else abort();
   return (field_dopywrap(ty, f));
 }
 
 field *field_copy(field *f)
 {
-  if (strcmp(F_NAME(f), "prime") == 0)
+  if (STRCMP(F_NAME(f), ==, "prime"))
     f = field_prime(f->m);
-  else if (strcmp(F_NAME(f), "niceprime") == 0)
+  else if (STRCMP(F_NAME(f), ==, "niceprime"))
     f = field_niceprime(f->m);
-  else if (strcmp(F_NAME(f), "binpoly") == 0)
+  else if (STRCMP(F_NAME(f), ==, "binpoly"))
     f = field_binpoly(f->m);
-  else if (strcmp(F_NAME(f), "binnorm") == 0) {
+  else if (STRCMP(F_NAME(f), ==, "binnorm")) {
     fctx_binnorm *fc = (fctx_binnorm *)f;
     f = field_binnorm(f->m, fc->ntop.r[fc->ntop.n - 1]);
   } else
diff --git a/group.c b/group.c
index 3d29070..239456f 100644 (file)
--- a/group.c
+++ b/group.c
@@ -461,7 +461,7 @@ PyTypeObject *primegroup_pytype, *bingroup_pytype, *ecgroup_pytype;
 
 group *group_copy(group *g)
 {
-  if (strcmp(G_NAME(g), "prime") == 0) {
+  if (STRCMP(G_NAME(g), ==, "prime")) {
     gctx_prime *gc = (gctx_prime *)g;
     gprime_param gp;
     gp.g = G_TOINT(g, MP_NEW, g->g);
@@ -469,7 +469,7 @@ group *group_copy(group *g)
     gp.q = gc->g.r;
     g = group_prime(&gp);
     MP_DROP(gp.g);
-  } else if (strcmp(G_NAME(g), "bin") == 0) {
+  } else if (STRCMP(G_NAME(g), ==, "bin")) {
     gctx_bin *gc = (gctx_bin *)g;
     gbin_param gb;
     gb.g = G_TOINT(g, MP_NEW, g->g);
@@ -477,7 +477,7 @@ group *group_copy(group *g)
     gb.q = gc->g.r;
     g = group_binary(&gb);
     MP_DROP(gb.g);
-  } else if (strcmp(G_NAME(g), "ec") == 0) {
+  } else if (STRCMP(G_NAME(g), ==, "ec")) {
     gctx_ec *gc = (gctx_ec *)g;
     ec_info ei;
     if ((ei.c = eccurve_copy(gc->ei.c)) == 0)
@@ -560,9 +560,9 @@ PyObject *group_pywrap(group *g)
 {
   PyTypeObject *ty;
 
-  if (strcmp(G_NAME(g), "prime") == 0) ty = primegroup_pytype;
-  else if (strcmp(G_NAME(g), "bin") == 0) ty = bingroup_pytype;
-  else if (strcmp(G_NAME(g), "ec") == 0) ty = ecgroup_pytype;
+  if (STRCMP(G_NAME(g), ==, "prime")) ty = primegroup_pytype;
+  else if (STRCMP(G_NAME(g), ==, "bin")) ty = bingroup_pytype;
+  else if (STRCMP(G_NAME(g), ==, "ec")) ty = ecgroup_pytype;
   else abort();
   return (group_dopywrap(ty, g));
 }
@@ -740,7 +740,7 @@ static PyObject *gemeth_toec(PyObject *me, PyObject *arg, PyObject *kw)
     if (!PyType_Check(cty) || !PyType_IsSubtype(cty, ecpt_pytype))
       TYERR("want subtype of catacomb.ECPt");
     Py_INCREF((PyObject *)cty);
-  } else if (strcmp(G_NAME(g), "ec") == 0) {
+  } else if (STRCMP(G_NAME(g), ==, "ec")) {
     c = eccurve_copy(((gctx_ec *)g)->ei.c);
     cty = (PyTypeObject *)eccurve_pywrap(0, c);
   } else  {
diff --git a/rand.c b/rand.c
index b662fd5..37ab5e4 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -27,7 +27,9 @@
 /*----- Header files ------------------------------------------------------*/
 
 #include "catacomb-python.h"
+PUBLIC_SYMBOLS;
 #include "algorithms.h"
+PRIVATE_SYMBOLS;
 
 /*----- Main code ---------------------------------------------------------*/
 
@@ -54,14 +56,14 @@ PyObject *grand_pywrap(grand *r, unsigned f)
   PyTypeObject *ty = grand_pytype;
   PyObject *ob;
 
-  if (strcmp(r->ops->name, "rand") == 0) ty = truerand_pytype;
-  else if (strcmp(r->ops->name, "lcrand") == 0) ty = lcrand_pytype;
-  else if (strcmp(r->ops->name, "fibrand") == 0) ty = fibrand_pytype;
-  else if (strcmp(r->ops->name, "dsarand") == 0) ty = dsarand_pytype;
-  else if (strcmp(r->ops->name, "bbs") == 0) ty = bbs_pytype;
-  else if (strcmp(r->ops->name, "sslprf") == 0) ty = sslprf_pytype;
-  else if (strcmp(r->ops->name, "tlsdx") == 0) ty = tlsdx_pytype;
-  else if (strcmp(r->ops->name, "tlsprf") == 0) ty = tlsprf_pytype;
+  if (STRCMP(r->ops->name, ==, "rand")) ty = truerand_pytype;
+  else if (STRCMP(r->ops->name, ==, "lcrand")) ty = lcrand_pytype;
+  else if (STRCMP(r->ops->name, ==, "fibrand")) ty = fibrand_pytype;
+  else if (STRCMP(r->ops->name, ==, "dsarand")) ty = dsarand_pytype;
+  else if (STRCMP(r->ops->name, ==, "bbs")) ty = bbs_pytype;
+  else if (STRCMP(r->ops->name, ==, "sslprf")) ty = sslprf_pytype;
+  else if (STRCMP(r->ops->name, ==, "tlsdx")) ty = tlsdx_pytype;
+  else if (STRCMP(r->ops->name, ==, "tlsprf")) ty = tlsprf_pytype;
   else if ((ob = PyDict_GetItemString(gccrands_dict, r->ops->name)) != 0)
     ty = (PyTypeObject *)ob;
   return (grand_dopywrap(ty, r, f));
index d778177..8ac72ab 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ import distutils.core as DC
 import mdwsetup as MS
 
 MS.pkg_config('catacomb', '2.5.0')
-MS.pkg_config('mLib', '2.2.2.1')
+MS.pkg_config('mLib', '2.4.99~')
 
 cat = DC.Extension('catacomb._base',
                    ['catacomb.c', 'bytestring.c', 'buffer.c',