Merge branch '1.3.x' into HEAD
authorMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2020 23:59:00 +0000 (00:59 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 7 Apr 2020 23:59:00 +0000 (00:59 +0100)
* 1.3.x:
  t/t-rand.py: Set the correct refernce seed value for `dsarand'.
  rand.c: More `Py_ssize_t' fixes.

rand.c
t/t-rand.py

diff --git a/rand.c b/rand.c
index 37ab5e4..926eade 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -940,7 +940,7 @@ static PyTypeObject gclatinrand_pytype_skel = {
 static PyObject *sslprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   char *k, *s;
-  int ksz, ssz;
+  Py_ssize_t ksz, ssz;
   const gchash *hco = &md5, *hci = &sha;
   PyObject *rc = 0;
   static const char *const kwlist[] = { "key", "seed", "ohash", "ihash", 0 };
@@ -957,7 +957,7 @@ end:
 static PyObject *tlsdx_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   char *k, *s;
-  int ksz, ssz;
+  Py_ssize_t ksz, ssz;
   const gcmac *mc = &sha_hmac;
   PyObject *rc = 0;
   static const char *const kwlist[] = { "key", "seed", "mac", 0 };
@@ -974,7 +974,7 @@ end:
 static PyObject *tlsprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   char *k, *s;
-  int ksz, ssz;
+  Py_ssize_t ksz, ssz;
   const gcmac *mcl = &md5_hmac, *mcr = &sha_hmac;
   PyObject *rc = 0;
   static const char *const kwlist[] = { "key", "seed", "lmac", "rmac", 0 };
@@ -1140,7 +1140,7 @@ static PyTypeObject tlsprf_pytype_skel = {
 static PyObject *dsarand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   char *p;
-  int sz;
+  Py_ssize_t sz;
   PyObject *rc = 0;
   static const char *const kwlist[] = { "seed", 0 };
 
index d8d7b00..a45c1d5 100644 (file)
@@ -121,7 +121,10 @@ class TestRandomGenerator (U.TestCase):
     n = C.MP.loadb(seed)
     rng = C.DSARand(seed)
     me.check_rand(rng)
-    me.assertEqual(rng.seed, (n + 153 + 3).storeb(16))
+    if T.MAXFIXNUM == (1 << 31) - 1: steps = 153 + 3
+    elif T.MAXFIXNUM == (1 << 63) - 1: steps = 153
+    else: steps = None
+    if steps is not None: me.assertEqual(rng.seed, (n + steps).storeb(16))
 
   def test_bbs(me):
     ev = T.EventRecorder()