/* -*-c-*-
*
- * $Id$
- *
* Public-key cryptography
*
* (c) 2004 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.
MEMBER(G, T_OBJECT, READONLY, "D.G -> group to work in")
MEMBER(p, T_OBJECT, READONLY, "D.p -> public key (group element")
MEMBER(rng, T_OBJECT, READONLY, "D.rng -> random number generator")
- MEMBER(hash, T_OBJECT, READONLY, "D.hash -> hash class")
+ MEMBER(hash, T_OBJECT, READONLY, "D.hash -> hash class")
#undef MEMBERSTRUCT
{ 0 }
};
static PyTypeObject dsapub_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.DSAPub", /* @tp_name@ */
+ "DSAPub", /* @tp_name@ */
sizeof(dsa_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject dsapriv_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.DSAPriv", /* @tp_name@ */
+ "DSAPriv", /* @tp_name@ */
sizeof(dsa_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject kcdsapub_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.KCDSAPub", /* @tp_name@ */
+ "KCDSAPub", /* @tp_name@ */
sizeof(dsa_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject kcdsapriv_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.KCDSAPriv", /* @tp_name@ */
+ "KCDSAPriv", /* @tp_name@ */
sizeof(dsa_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
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");
o = (rsapub_pyobj *)ty->tp_alloc(ty, 0);
o->pub = rp;
rsa_pubcreate(&o->pubctx, &o->pub);
convmp, &rp.q_inv,
&rng))
goto end;
+ if ((rp.n && !MP_ODDP(rp.n)) ||
+ (rp.p && !MP_ODDP(rp.p)) ||
+ (rp.p && !MP_ODDP(rp.q)))
+ VALERR("RSA modulus and factors must be odd");
if (rsa_recover(&rp)) VALERR("couldn't construct private key");
if (rng != Py_None && !GRAND_PYCHECK(rng))
TYERR("not a random number source");
static PyTypeObject rsapub_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.RSAPub", /* @tp_name@ */
+ "RSAPub", /* @tp_name@ */
sizeof(rsapub_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject rsapriv_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.RSAPriv", /* @tp_name@ */
+ "RSAPriv", /* @tp_name@ */
sizeof(rsapriv_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */