X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/6b54260d1f5312a3ec58be3ee1eb168ddf9cf2e2..dad564fa66dd0ab52058f25a0eaf6a8e5b3c4316:/share.c diff --git a/share.c b/share.c index 2caa718..77da423 100644 --- a/share.c +++ b/share.c @@ -117,8 +117,8 @@ static PyObject *gfsharesplit_pynew(PyTypeObject *ty, 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"); @@ -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@ */