X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/06cd26e87f5b839d40f0e7b57e38aea6c231b385..c41d03718b8dc50076405c3d0f3136cfaa1cb21b:/pubkey.c diff --git a/pubkey.c b/pubkey.c index 56b7d9c..9c43ca7 100644 --- a/pubkey.c +++ b/pubkey.c @@ -96,9 +96,9 @@ static PyObject *dsapub_pynew(PyTypeObject *ty, { PyObject *G, *p, *rng = rand_pyobj, *hash = sha_pyobj; PyObject *rc = 0; - char *kwlist[] = { "G", "p", "hash", "rng", 0 }; + static const char *const kwlist[] = { "G", "p", "hash", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", KWLIST, group_pytype, &G, ge_pytype, &p, gchash_pytype, &hash, @@ -112,7 +112,7 @@ end: static PyObject *dsameth_beginhash(PyObject *me, PyObject *arg) { if (!PyArg_ParseTuple(arg, ":beginhash")) return (0); - return (ghash_pywrap(DSA_HASH(me), gdsa_beginhash(DSA_D(me)), f_freeme)); + return (ghash_pywrap(DSA_HASH(me), gdsa_beginhash(DSA_D(me)))); } static PyObject *dsameth_endhash(PyObject *me, PyObject *arg) @@ -135,9 +135,9 @@ static PyObject *dsameth_sign(PyObject *me, PyObject *arg, PyObject *kw) Py_ssize_t n; mp *k = 0; PyObject *rc = 0; - char *kwlist[] = { "msg", "k", 0 }; + static const char *const kwlist[] = { "msg", "k", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", KWLIST, &p, &n, convmp, &k)) goto end; if (n != DSA_D(me)->h->hashsz) @@ -175,9 +175,9 @@ static PyObject *dsapriv_pynew(PyTypeObject *ty, { PyObject *G, *p = 0, *u, *rng = rand_pyobj, *hash = sha_pyobj; PyObject *rc = 0; - char *kwlist[] = { "G", "u", "p", "hash", "rng", 0 }; + static const char *const kwlist[] = { "G", "u", "p", "hash", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", KWLIST, group_pytype, &G, &u, ge_pytype, &p, @@ -323,9 +323,9 @@ static PyObject *kcdsapub_pynew(PyTypeObject *ty, { PyObject *G, *p, *rng = rand_pyobj, *hash = has160_pyobj; PyObject *rc = 0; - char *kwlist[] = { "G", "p", "hash", "rng", 0 }; + static const char *const kwlist[] = { "G", "p", "hash", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", KWLIST, group_pytype, &G, ge_pytype, &p, gchash_pytype, &hash, @@ -348,9 +348,9 @@ static PyObject *kcdsapriv_pynew(PyTypeObject *ty, { PyObject *G, *u, *p = 0, *rng = rand_pyobj, *hash = has160_pyobj; PyObject *rc = 0; - char *kwlist[] = { "G", "u", "p", "hash", "rng", 0 }; + static const char *const kwlist[] = { "G", "u", "p", "hash", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", KWLIST, group_pytype, &G, &u, ge_pytype, &p, @@ -366,7 +366,7 @@ end: static PyObject *kcdsameth_beginhash(PyObject *me, PyObject *arg) { if (!PyArg_ParseTuple(arg, ":beginhash")) return (0); - return (ghash_pywrap(DSA_HASH(me), gkcdsa_beginhash(DSA_D(me)), f_freeme)); + return (ghash_pywrap(DSA_HASH(me), gkcdsa_beginhash(DSA_D(me)))); } static PyObject *kcdsameth_endhash(PyObject *me, PyObject *arg) @@ -389,9 +389,9 @@ static PyObject *kcdsameth_sign(PyObject *me, PyObject *arg, PyObject *kw) Py_ssize_t n; mp *k = 0; PyObject *r = 0, *rc = 0; - char *kwlist[] = { "msg", "k", 0 }; + static const char *const kwlist[] = { "msg", "k", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", KWLIST, &p, &n, convmp, &k)) goto end; if (n != DSA_D(me)->h->hashsz) @@ -569,9 +569,9 @@ static PyObject *rsapub_pynew(PyTypeObject *ty, { rsa_pub rp = { 0 }; rsapub_pyobj *o; - char *kwlist[] = { "n", "e", 0 }; + static const char *const kwlist[] = { "n", "e", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST, convmp, &rp.n, convmp, &rp.e)) goto end; if (!MP_ODDP(rp.n)) VALERR("RSA modulus must be even"); @@ -636,10 +636,10 @@ static PyObject *rsapriv_pynew(PyTypeObject *ty, { rsa_priv rp = { 0 }; PyObject *rng = Py_None; - char *kwlist[] = + static const char *const kwlist[] = { "n", "e", "d", "p", "q", "dp", "dq", "q_inv", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&O&O&O&O&O:new", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&O&O&O&O&O:new", KWLIST, convmp, &rp.n, convmp, &rp.e, convmp, &rp.d, convmp, &rp.p, convmp, &rp.q, @@ -711,9 +711,9 @@ static PyObject *rsameth_privop(PyObject *me, PyObject *arg, PyObject *kw) PyObject *rng = RSA_RNG(me); mp *x = 0; PyObject *rc = 0; - char *kwlist[] = { "x", "rng", 0 }; + static const char *const kwlist[] = { "x", "rng", 0 }; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O:privop", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O:privop", KWLIST, convmp, &x, &rng)) goto end; if (rng != Py_None && !GRAND_PYCHECK(rng)) @@ -734,10 +734,11 @@ static PyObject *meth__RSAPriv_generate(PyObject *me, rsa_priv rp; mp *e = 0; pgev evt = { 0 }; - char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "e", 0 }; + static const char *const kwlist[] = + { "class", "nbits", "event", "rng", "nsteps", "e", 0 }; PyObject *rc = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", KWLIST, &me, convuint, &nbits, convpgev, &evt, convgrand, &r, convuint, &n, convmp, &e)) @@ -898,10 +899,10 @@ static PyObject *meth__p1crypt_encode(PyObject *me, octet *b = 0; size_t sz; mp *x; - char *kwlist[] = { "msg", "nbits", "ep", "rng", 0 }; + static const char *const kwlist[] = { "msg", "nbits", "ep", "rng", 0 }; p1.r = &rand_global; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", KWLIST, &m, &msz, convulong, &nbits, &ep, &epsz, convgrand, &p1.r)) goto end; @@ -928,10 +929,10 @@ static PyObject *meth__p1crypt_decode(PyObject *me, octet *b = 0; size_t sz; mp *x = 0; - char *kwlist[] = { "ct", "nbits", "ep", "rng", 0 }; + static const char *const kwlist[] = { "ct", "nbits", "ep", "rng", 0 }; p1.r = &rand_global; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|s#O&:decode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|s#O&:decode", KWLIST, convmp, &x, convulong, &nbits, &ep, &epsz, convgrand, &p1.r)) goto end; @@ -959,10 +960,10 @@ static PyObject *meth__p1sig_encode(PyObject *me, octet *b = 0; size_t sz; mp *x; - char *kwlist[] = { "msg", "nbits", "ep", "rng", 0 }; + static const char *const kwlist[] = { "msg", "nbits", "ep", "rng", 0 }; p1.r = &rand_global; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", KWLIST, &m, &msz, convulong, &nbits, &ep, &epsz, convgrand, &p1.r)) goto end; @@ -990,10 +991,11 @@ static PyObject *meth__p1sig_decode(PyObject *me, octet *b = 0; size_t sz; mp *x = 0; - char *kwlist[] = { "msg", "sig", "nbits", "ep", "rng", 0 }; + static const char *const kwlist[] = + { "msg", "sig", "nbits", "ep", "rng", 0 }; p1.r = &rand_global; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|s#O&:decode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|s#O&:decode", KWLIST, &hukairz, convmp, &x, convulong, &nbits, &ep, &epsz, convgrand, &p1.r)) goto end; @@ -1021,10 +1023,11 @@ static PyObject *meth__oaep_encode(PyObject *me, octet *b = 0; size_t sz; mp *x; - char *kwlist[] = { "msg", "nbits", "mgf", "hash", "ep", "rng", 0 }; + static const char *const kwlist[] = + { "msg", "nbits", "mgf", "hash", "ep", "rng", 0 }; o.r = &rand_global; o.cc = &sha_mgf; o.ch = &sha; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&s#O&:encode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&s#O&:encode", KWLIST, &m, &msz, convulong, &nbits, convgccipher, &o.cc, convgchash, &o.ch, @@ -1054,10 +1057,11 @@ static PyObject *meth__oaep_decode(PyObject *me, octet *b = 0; size_t sz; mp *x = 0; - char *kwlist[] = { "ct", "nbits", "mgf", "hash", "ep", "rng", 0 }; + static const char *const kwlist[] = + { "ct", "nbits", "mgf", "hash", "ep", "rng", 0 }; o.r = &rand_global; o.cc = &sha_mgf; o.ch = &sha; ep = 0; epsz = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&s#O&:decode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&s#O&:decode", KWLIST, convmp, &x, convulong, &nbits, convgccipher, &o.cc, convgchash, &o.ch, @@ -1088,10 +1092,11 @@ static PyObject *meth__pss_encode(PyObject *me, octet *b = 0; size_t sz; mp *x = 0; - char *kwlist[] = { "msg", "nbits", "mgf", "hash", "saltsz", "rng", 0 }; + static const char *const kwlist[] = + { "msg", "nbits", "mgf", "hash", "saltsz", "rng", 0 }; p.cc = &sha_mgf; p.ch = &sha; p.r = &rand_global; p.ssz = (size_t)-1; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&O&O&:encode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&O&O&:encode", KWLIST, &m, &msz, convulong, &nbits, convgccipher, &p.cc, convgchash, &p.ch, @@ -1121,11 +1126,11 @@ static PyObject *meth__pss_decode(PyObject *me, size_t sz; int n; mp *x = 0; - char *kwlist[] = + static const char *const kwlist[] = { "msg", "sig", "nbits", "mgf", "hash", "saltsz", "rng", 0 }; p.cc = &sha_mgf; p.ch = &sha; p.r = &rand_global; p.ssz = (size_t)-1; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&O&|O&O&O&O&:decode", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&O&|O&O&O&O&:decode", KWLIST, &m, &msz, convmp, &x, convulong, &nbits, convgccipher, &p.cc, convgchash, &p.ch, @@ -1201,10 +1206,11 @@ XDHS(DEFXDH) int ph = phdflt; \ PyObject *rc = 0; \ octet pp[ED##_PUBSZ]; \ - char *kwlist[] = { "key", "msg", "pub", "perso", "phflag", 0 }; \ + static const char *const kwlist[] = \ + { "key", "msg", "pub", "perso", "phflag", 0 }; \ if (!PyArg_ParseTupleAndKeywords(arg, kw, \ "s#s#|s#s#O&:" #ed "_sign", \ - kwlist, \ + KWLIST, \ &k, &ksz, &m, &msz, &p, &psz, \ &c, &csz, convbool, &ph)) \ goto end; \ @@ -1228,10 +1234,11 @@ XDHS(DEFXDH) Py_ssize_t psz, csz = 0, msz, ssz; \ int ph = phdflt; \ PyObject *rc = 0; \ - char *kwlist[] = { "pub", "msg", "sig", "perso", "phflag", 0 }; \ + static const char *const kwlist[] = \ + { "pub", "msg", "sig", "perso", "phflag", 0 }; \ if (!PyArg_ParseTupleAndKeywords(arg, kw, \ "s#s#s#|s#O&:" #ed "_verify", \ - kwlist, \ + KWLIST, \ &p, &psz, &m, &msz, &s, &ssz, \ &c, &csz, convbool, &ph)) \ goto end; \