/* -*-c-*-
*
- * $Id$
- *
* Secret sharing
*
* (c) 2005 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of the Python interface to Catacomb.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* Catacomb/Python is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with Catacomb/Python; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static PyTypeObject gfshare_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.GFShare", /* @tp_name@ */
+ "GFShare", /* @tp_name@ */
sizeof(gfshare_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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");
static PyTypeObject gfsharesplit_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.GFShareSplit", /* @tp_name@ */
+ "GFShareSplit", /* @tp_name@ */
sizeof(gfshare_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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@ */
{
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");
{
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");
static PyTypeObject gfsharejoin_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.GFShareJoin", /* @tp_name@ */
+ "GFShareJoin", /* @tp_name@ */
sizeof(gfshare_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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@ */
static PyTypeObject share_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.Share", /* @tp_name@ */
+ "Share", /* @tp_name@ */
sizeof(share_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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&: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;
static PyTypeObject sharesplit_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.ShareSplit", /* @tp_name@ */
+ "ShareSplit", /* @tp_name@ */
sizeof(share_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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@ */
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");
static PyTypeObject sharejoin_pytype_skel = {
PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */
- "catacomb.ShareJoin", /* @tp_name@ */
+ "ShareJoin", /* @tp_name@ */
sizeof(share_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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@ */