X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/0e29d9164d5cc4e3cafa509cda19de2e025446c1..dad564fa66dd0ab52058f25a0eaf6a8e5b3c4316:/share.c diff --git a/share.c b/share.c index ad56d31..77da423 100644 --- a/share.c +++ b/share.c @@ -113,12 +113,12 @@ static PyObject *gfsharesplit_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) { char *p; - int n; + Py_ssize_t n; unsigned t; grand *r = &rand_global; gfshare_pyobj *s; - char *kwlist[] = { "threshold", "secret", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", kwlist, + static const char *const kwlist[] = { "threshold", "secret", "rng", 0 }; + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", KWLIST, convuint, &t, &p, &n, convgrand, &r)) goto end; if (!t || t > 255) VALERR("threshold must be nonzero and < 256"); @@ -174,7 +174,8 @@ static PyTypeObject gfsharesplit_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Binary field secret sharing: split secret into shares.", +"GFShareSplit(THRESHOLD, SECRET, [rng = rand]): binary-field sharing:\n\ + split secret into shares.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -202,8 +203,8 @@ static PyObject *gfsharejoin_pynew(PyTypeObject *ty, { unsigned t, sz; gfshare_pyobj *s; - char *kwlist[] = { "threshold", "size", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist, + static const char *const kwlist[] = { "threshold", "size", 0 }; + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST, convuint, &t, convuint, &sz)) goto end; if (!t || t > 255) VALERR("threshold must be nonzero and < 256"); @@ -228,7 +229,7 @@ static PyObject *gfsmeth_add(PyObject *me, PyObject *arg) { unsigned i; char *p; - int n; + Py_ssize_t n; if (!PyArg_ParseTuple(arg, "O&s#:add", convuint, &i, &p, &n)) goto end; if (i > 254) VALERR("index must be < 255"); if (n != GFSHARE_S(me)->sz) VALERR("bad share size"); @@ -295,7 +296,8 @@ static PyTypeObject gfsharejoin_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Binary field secret sharing: join shares to recover secret.", +"GFShareJoin(THRESHOLD, SIZE): binary field sharing:\n\ + join shares to recover secret.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -407,8 +409,10 @@ static PyObject *sharesplit_pynew(PyTypeObject *ty, grand *r = &rand_global; mp *m = 0; share_pyobj *s; - char *kwlist[] = { "threshold", "secret", "modulus", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", kwlist, + static const char *const kwlist[] = + { "threshold", "secret", "modulus", "rng", 0 }; + + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", KWLIST, convuint, &t, convmp, &sec, convmp, &m, convgrand, &r)) goto end; @@ -467,7 +471,8 @@ static PyTypeObject sharesplit_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Prime field secret sharing: split secret into shares.", +"ShareSplit(THRESHOLD, SECRET, [modulus = ?], [rng = rand]):\n\ + prime field secret sharing: split secret into shares.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -496,8 +501,8 @@ static PyObject *sharejoin_pynew(PyTypeObject *ty, unsigned t; mp *m = 0; share_pyobj *s; - char *kwlist[] = { "threshold", "modulus", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist, + static const char *const kwlist[] = { "threshold", "modulus", 0 }; + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST, convuint, &t, convmp, &m)) goto end; if (!t) VALERR("threshold must be nonzero"); @@ -590,7 +595,8 @@ static PyTypeObject sharejoin_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Prime field secret sharing: join shares to recover secret.", +"ShareJoin(THRESHOLD, MODULUS): prime field secret sharing:\n\ + join shares to recover secret.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */