chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pubkey: Various stupid DSA bugs fixed.
[catacomb-python]
/
pubkey.c
diff --git
a/pubkey.c
b/pubkey.c
index 735a2c01d771a80fe83ce3830e5f5065d2ca6ac4..e7bfb988865d933ab277632a32003ef1d8db18dd 100644
(file)
--- a/
pubkey.c
+++ b/
pubkey.c
@@
-73,7
+73,7
@@
static PyObject *dsa_setup(PyTypeObject *ty, PyObject *G, PyObject *u,
g->d.r = GRAND_R(rng);
g->d.h = GCHASH_CH(hash);
g->G = G; Py_INCREF(G); g->u = u; Py_INCREF(u); g->p = p; Py_INCREF(p);
g->d.r = GRAND_R(rng);
g->d.h = GCHASH_CH(hash);
g->G = G; Py_INCREF(G); g->u = u; Py_INCREF(u); g->p = p; Py_INCREF(p);
-
rng = g->
rng; Py_INCREF(rng); g->hash = hash; Py_INCREF(hash);
+
g->rng =
rng; Py_INCREF(rng); g->hash = hash; Py_INCREF(hash);
return ((PyObject *)g);
end:
FREEOBJ(g);
return ((PyObject *)g);
end:
FREEOBJ(g);
@@
-87,7
+87,7
@@
static PyObject *dsapub_pynew(PyTypeObject *ty,
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 };
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!
O!|O
O!:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!
|OO!
O!:new", kwlist,
group_pytype, &G,
ge_pytype, &p,
&u,
group_pytype, &G,
ge_pytype, &p,
&u,
@@
-151,7
+151,7
@@
static PyObject *dsameth_verify(PyObject *me, PyObject *arg)
goto end;
if (n != DSA_D(me)->h->hashsz)
VALERR("bad message length (doesn't match hash size)");
goto end;
if (n != DSA_D(me)->h->hashsz)
VALERR("bad message length (doesn't match hash size)");
- rc = getbool(gdsa_verify(DSA_D(me), &s, p));
+ rc = getbool(
!
gdsa_verify(DSA_D(me), &s, p));
end:
mp_drop(s.r);
mp_drop(s.s);
end:
mp_drop(s.r);
mp_drop(s.s);
@@
-165,13
+165,13
@@
static PyObject *dsapriv_pynew(PyTypeObject *ty,
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 };
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "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,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
group_pytype, &G,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
- (rc = dsa_setup(dsapriv_pytype, G,
p, u
, rng, hash)) == 0)
+ (rc = dsa_setup(dsapriv_pytype, G,
u, p
, rng, hash)) == 0)
goto end;
end:
return (rc);
goto end;
end:
return (rc);
@@
-313,13
+313,13
@@
static PyObject *kcdsapub_pynew(PyTypeObject *ty,
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 };
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "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,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
group_pytype, &G,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
- (rc = dsa_setup(kcdsapub_pytype, G,
p, u
, rng, hash)) == 0)
+ (rc = dsa_setup(kcdsapub_pytype, G,
u, p
, rng, hash)) == 0)
goto end;
end:
return (rc);
goto end;
end:
return (rc);
@@
-332,13
+332,13
@@
static PyObject *kcdsapriv_pynew(PyTypeObject *ty,
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 };
PyObject *rc = 0;
char *kwlist[] = { "G", "p", "u", "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,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
group_pytype, &G,
ge_pytype, &p,
&u,
gchash_pytype, &hash,
grand_pytype, &rng) ||
- (rc = dsa_setup(kcdsapriv_pytype, G,
p, u
, rng, hash)) == 0)
+ (rc = dsa_setup(kcdsapriv_pytype, G,
u, p
, rng, hash)) == 0)
goto end;
end:
return (rc);
goto end;
end:
return (rc);
@@
-380,7
+380,7
@@
static PyObject *kcdsameth_sign(PyObject *me, PyObject *arg, PyObject *kw)
r = bytestring_pywrap(0, DSA_D(me)->h->hashsz);
s.r = (octet *)PyString_AS_STRING(r);
gkcdsa_sign(DSA_D(me), &s, p, k);
r = bytestring_pywrap(0, DSA_D(me)->h->hashsz);
s.r = (octet *)PyString_AS_STRING(r);
gkcdsa_sign(DSA_D(me), &s, p, k);
- rc = Py_BuildValue("(
N
N)", r, mp_pywrap(s.s));
+ rc = Py_BuildValue("(
O
N)", r, mp_pywrap(s.s));
end:
Py_XDECREF(r);
mp_drop(k);
end:
Py_XDECREF(r);
mp_drop(k);
@@
-401,7
+401,7
@@
static PyObject *kcdsameth_verify(PyObject *me, PyObject *arg)
VALERR("bad message length (doesn't match hash size)");
if (rn != DSA_D(me)->h->hashsz)
VALERR("bad signature `r' length (doesn't match hash size)");
VALERR("bad message length (doesn't match hash size)");
if (rn != DSA_D(me)->h->hashsz)
VALERR("bad signature `r' length (doesn't match hash size)");
- rc = getbool(gkcdsa_verify(DSA_D(me), &s, p));
+ rc = getbool(
!
gkcdsa_verify(DSA_D(me), &s, p));
end:
mp_drop(s.s);
return (rc);
end:
mp_drop(s.s);
return (rc);