include algorithms.py
include pwsafe
include debian/rules debian/control debian/changelog debian/copyright
-recursive-include catacomb *.py
+recursive-include catacomb *.py
prune py
gmhash
[gmac objects]
-ecinfo(curve = ecprimeprojcurve(),
+ecinfo(curve = ecprimeprojcurve(),
G = ecprimeprojcurve()(),
r = 115792089210356248762697446949407573529996955224135760342422259061068512044369,
- h = 1)
\ No newline at end of file
+ h = 1)
* (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.
} break;
case KSZ_RANGE: {
keyszrange_pyobj *o =
- PyObject_New(keyszrange_pyobj, keyszrange_pytype);
+ PyObject_New(keyszrange_pyobj, keyszrange_pytype);
o->dfl = k[1];
o->min = k[2];
o->max = k[3];
} break;
case KSZ_SET: {
keyszset_pyobj *o =
- PyObject_New(keyszset_pyobj, keyszset_pytype);
+ PyObject_New(keyszset_pyobj, keyszset_pytype);
int i, n;
o->dfl = k[1];
for (i = 0; k[i + 1]; i++) ;
if (xx < 0) VALERR("key size cannot be negative");
PyList_Append(l, x);
Py_DECREF(x);
- x = 0;
+ x = 0;
}
Py_DECREF(set);
if ((set = PySequence_Tuple(l)) == 0) goto end;
g = PyObject_NEW(gcipher_pyobj, (PyTypeObject *)cobj);
g->c = c;
g->f = f;
- return ((PyObject *)g);
+ return ((PyObject *)g);
}
static PyObject *gcipher_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
GC_INIT(GCCIPHER_CC(ty), k, sz),
f_freeme));
end:
- return (0);
+ return (0);
}
PyObject *gccipher_pywrap(gccipher *cc)
goto end;
return (ghash_pywrap((PyObject *)ty, GH_INIT(GCHASH_CH(ty)), f_freeme));
end:
- return (0);
+ return (0);
}
PyObject *gchash_pywrap(gchash *ch)
g = PyObject_NEW(ghash_pyobj, (PyTypeObject *)cobj);
g->h = h;
g->f = f;
- return ((PyObject *)g);
+ return ((PyObject *)g);
}
static void ghash_pydealloc(PyObject *me)
GM_KEY(GCMAC_CM(ty), k, sz),
f_freeme));
end:
- return (0);
+ return (0);
}
static PyObject *gmhash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
PyType_Ready(&g->ty.ht_type);
g->m = m;
g->f = f;
- return ((PyObject *)g);
+ return ((PyObject *)g);
}
static void gmac_pydealloc(PyObject *me)
#define PRP_ENTRY(PRE, pre) &pre##_prpinfo,
PRPS(PRP_ENTRY)
0
-};
+};
typedef struct gcprp_pyobj {
PyHeapTypeObject ty;
Py_INCREF(me);
return (me);
end:
- return (0);
+ return (0);
}
static void gprp_pydealloc(PyObject *me)
for j in pmodes:
print '#include <catacomb/%s-%s.h>' % (i, j)
for i in streamciphers:
- print '#include <catacomb/%s.h>' % i
+ print '#include <catacomb/%s.h>' % i
print
for i in hashes:
print '#include <catacomb/%s.h>' % i
print '#define PRPS(_) \\'
for i in prps:
print ' _(%s, %s) \\' % (i.upper(), i)
-print ' /* end */'
+print ' /* end */'
print
print '#define RNGF_INT 1u'
print '#define RNGS(_) \\'
for i in (cross(prps, ['ofb', 'counter'])):
print (' _("%(prim)s-%(mode)s", %(prim)s_keysz, ' +
- '%(prim)s_%(mode)srand, 0) \\') % \
- {'prim': i[0], 'mode': i[1]}
+ '%(prim)s_%(mode)srand, 0) \\') % \
+ {'prim': i[0], 'mode': i[1]}
for i in (cross(hashes, 'mgf')):
print (' _("%(prim)s-%(mode)s", %(prim)s_%(mode)skeysz, ' +
- '%(prim)s_%(mode)srand, 0) \\') % \
- {'prim': i[0], 'mode': i[1]}
-print ' _("rc4", rc4_keysz, rc4_rand, 0) \\'
-print ' _("seal", seal_keysz, seal_rand, RNGF_INT) \\'
-print ' /* end */'
+ '%(prim)s_%(mode)srand, 0) \\') % \
+ {'prim': i[0], 'mode': i[1]}
+print ' _("rc4", rc4_keysz, rc4_rand, 0) \\'
+print ' _("seal", seal_keysz, seal_rand, RNGF_INT) \\'
+print ' /* end */'
print
* (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.
end:
return (0);
}
-
+
static PyObject *rbmeth_getecptraw(PyObject *me, PyObject *arg)
{
PyTypeObject *cobj = ecpt_pytype;
* (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.
* (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.
#define INSERT(name, ob) do { \
PyObject *_o = (PyObject *)(ob); \
- Py_INCREF(_o); \
+ Py_INCREF(_o); \
PyModule_AddObject(mod, name, _o); \
} while (0)
METH (items, "D.items() -> LIST") \
METH (iterkeys, "D.iterkeys() -> ITER") \
METH (itervalues, "D.itervalues() -> ITER") \
- METH (iteritems, "D.iteritems() -> ITER") \
+ METH (iteritems, "D.iteritems() -> ITER") \
KWMETH(get, "D.get(KEY, [default = None]) -> VALUE") \
#define GMAP_DOMETHODS(METH, KWMETH) \
field *f;
mp *x;
} fe_pyobj;
-
+
extern PyTypeObject *field_pytype;
extern PyTypeObject *primefield_pytype;
extern PyTypeObject *niceprimefield_pytype;
ec_info ei;
PyObject *cobj;
} ecinfo_pyobj;
-
+
extern PyTypeObject *ecinfo_pytype;
#define ECINFO_PYCHECK(o) PyObject_TypeCheck((o), ecinfo_pytype)
#define ECINFO_EI(o) (&((ecinfo_pyobj *)(o))->ei)
extern int convgmac(PyObject *, void *);
/*----- Key generation ----------------------------------------------------*/
-
+
typedef struct pfilt_pyobj {
PyObject_HEAD
pfilt f;
* (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.
# 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.
if i[0] != '_':
d[i] = b[i];
for i in ['MP', 'GF', 'Field',
- 'ECPt', 'ECPtCurve', 'ECCurve', 'ECInfo',
- 'DHInfo', 'BinDHInfo', 'RSAPriv', 'BBSPriv',
- 'PrimeFilter', 'RabinMiller',
- 'Group', 'GE',
- 'KeyData']:
+ 'ECPt', 'ECPtCurve', 'ECCurve', 'ECInfo',
+ 'DHInfo', 'BinDHInfo', 'RSAPriv', 'BBSPriv',
+ 'PrimeFilter', 'RabinMiller',
+ 'Group', 'GE',
+ 'KeyData']:
c = d[i]
pre = '_' + i + '_'
plen = len(pre)
for j in b:
if j[:plen] == pre:
- setattr(c, j[plen:], classmethod(b[j]))
+ setattr(c, j[plen:], classmethod(b[j]))
for i in [gcciphers, gchashes, gcmacs, gcprps]:
for c in i.itervalues():
d[c.name.replace('-', '_')] = c
class _tmp:
def __repr__(me):
return 'ECInfo(curve = %r, G = %r, r = %s, h = %s)' % \
- (me.curve, me.G, me.r, me.h)
+ (me.curve, me.G, me.r, me.h)
def group(me):
return ECGroup(me)
_augment(ECInfo, _tmp)
class _tmp:
def __repr__(me):
return 'KeySZRange(%d, %d, %d, %d)' % \
- (me.default, me.min, me.max, me.mod)
+ (me.default, me.min, me.max, me.mod)
def check(me, sz): return me.min <= sz <= me.max and sz % me.mod == 0
def best(me, sz):
if sz < me.min: raise ValueError, 'key too small'
class _tmp:
def __repr__(me):
return '%s(p = %s, r = %s, g = %s)' % \
- (type(me).__name__, me.p, me.r, me.g)
+ (type(me).__name__, me.p, me.r, me.g)
_augment(FGInfo, _tmp)
class _tmp:
return _base._pss_encode(msg, nbits, me.mgf, me.hash, me.saltsz, me.rng)
def decode(me, msg, sig, nbits):
return _base._pss_decode(msg, sig, nbits,
- me.mgf, me.hash, me.saltsz, me.rng)
+ me.mgf, me.hash, me.saltsz, me.rng)
class _tmp:
def encrypt(me, msg, enc):
x = enc.decode(msg, me.pubop(sig), me.n.nbits)
return x is None or x == msg
except ValueError:
- return False
+ return False
_augment(RSAPub, _tmp)
class _tmp:
def sgprime(start, step = 2, name = 'p', event = pgen_nullev, nsteps = 0):
start = MP(start)
return pgen(start, name, SimulStepper(step = step), SimulTester(), event,
- nsteps, RabinMiller.iters(start.nbits))
+ nsteps, RabinMiller.iters(start.nbits))
def findprimitive(mod, hh = [], exp = None, name = 'g', event = pgen_nullev):
return pgen(0, name, PrimitiveStepper(), PrimitiveTester(mod, hh, exp),
- event, 0, 1)
+ event, 0, 1)
def kcdsaprime(pbits, qbits, rng = rand,
- event = pgen_nullev, name = 'p', nsteps = 0):
+ event = pgen_nullev, name = 'p', nsteps = 0):
hbits = pbits - qbits
h = pgen(rng.mp(hbits, 1), name + ' [h]',
- PrimeGenStepper(2), PrimeGenTester(),
- event, nsteps, RabinMiller.iters(hbits))
+ PrimeGenStepper(2), PrimeGenTester(),
+ event, nsteps, RabinMiller.iters(hbits))
q = pgen(rng.mp(qbits, 1), name, SimulStepper(2 * h, 1, 2),
- SimulTester(2 * h, 1), event, nsteps, RabinMiller.iters(qbits))
+ SimulTester(2 * h, 1), event, nsteps, RabinMiller.iters(qbits))
p = 2 * q * h + 1
return p, q, h
iv = y[:me.c.__class__.blksz]
if me.c.__class__.blksz: me.c.setiv(iv)
return me.c.decrypt(y[me.c.__class__.blksz:])
-
+
class PPK (Crypto):
def __init__(me, pp, c, h, m, salt = None):
if not salt: salt = _C.rand.block(h.hashsz)
tag = '%s\0%s' % (pp, salt)
Crypto.__init__(me, c, h, m,
- h().hash('cipher:' + tag).done(),
- h().hash('mac:' + tag).done())
+ h().hash('cipher:' + tag).done(),
+ h().hash('mac:' + tag).done())
me.salt = salt
class Buffer (object):
k = me.k
while True:
if k is None:
- raise StopIteration
+ raise StopIteration
if k[0] == '$':
- break
+ break
k = me.pw.db.nextkey(k)
me.k = me.pw.db.nextkey(k)
return me.pw.unpack(me.pw.db[k])[0]
tag = me.db['tag']
_C.ppcancel(tag)
ppk = PPK(_C.ppread(tag, _C.PMODE_VERIFY),
- me.k.c.__class__, me.k.h, me.k.m.__class__)
+ me.k.c.__class__, me.k.h, me.k.m.__class__)
me.db['key'] = ppk.encrypt(_wrapstr(me.ck) + _wrapstr(me.mk))
me.db['salt'] = ppk.salt
def pack(me, key, value):
* (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.
static PyObject *ecget_a(PyObject *me, void *hunoz)
{ return (fe_pywrap(ECCURVE_FOBJ(me), MP_COPY(ECCURVE_C(me)->a))); }
-static PyObject *ecget_b(PyObject *me, void *hunoz)
+static PyObject *ecget_b(PyObject *me, void *hunoz)
{ return (fe_pywrap(ECCURVE_FOBJ(me), MP_COPY(ECCURVE_C(me)->b))); }
static PyObject *ecget_field(PyObject *me, void *hunoz)
GET (inf, "E.inf -> point at infinity of this curve")
#undef GETSETNAME
{ 0 }
-};
+};
static PyMethodDef eccurve_pymethods[] = {
#define METHNAME(name) ecmeth_##name
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
- METH (_ECPt_frombuf, "frombuf(E, STR) -> (P, REST)")
- METH (_ECPtCurve_fromraw, "fromraw(E, STR) -> (P, REST)")
- METH (_ECPt_parse, "parse(E, STR) -> (P, REST)")
- METH (_ECCurve_parse, "parse(STR) -> (E, REST)")
- METH (_ECInfo_parse, "parse(STR) -> (I, REST)")
- METH (_ECInfo__curven, "_curven(N) -> I")
+ METH (_ECPt_frombuf, "frombuf(E, STR) -> (P, REST)")
+ METH (_ECPtCurve_fromraw, "fromraw(E, STR) -> (P, REST)")
+ METH (_ECPt_parse, "parse(E, STR) -> (P, REST)")
+ METH (_ECCurve_parse, "parse(STR) -> (E, REST)")
+ METH (_ECInfo_parse, "parse(STR) -> (I, REST)")
+ METH (_ECInfo__curven, "_curven(N) -> I")
#undef METHNAME
{ 0 }
};
* (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.
static PyGetSetDef primefield_pygetset[] = {
#define GETSETNAME(op, name) pf##op##_##name
- GET (p, "F.p -> prime field characteristic")
+ GET (p, "F.p -> prime field characteristic")
#undef GETSETNAME
};
static PyGetSetDef binfield_pygetset[] = {
#define GETSETNAME(op, name) bf##op##_##name
- GET (m, "F.m -> field polynomial degree")
+ GET (m, "F.m -> field polynomial degree")
#undef GETSETNAME
{ 0 }
};
static PyGetSetDef binpolyfield_pygetset[] = {
#define GETSETNAME(op, name) pf##op##_##name
- GET (p, "F.p -> field polynomial")
+ GET (p, "F.p -> field polynomial")
#undef GETSETNAME
{ 0 }
};
static PyGetSetDef binnormfield_pygetset[] = {
#define GETSETNAME(op, name) pf##op##_##name
- GET (p, "F.p -> field polynomial")
+ GET (p, "F.p -> field polynomial")
#undef GETSETNAME
#define GETSETNAME(op, name) bnf##op##_##name
- GET (beta, "F.beta -> conversion factor")
+ GET (beta, "F.beta -> conversion factor")
#undef GETSETNAME
{ 0 }
};
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
- METH (_Field_parse, "parse(STR) -> F, REST")
+ METH (_Field_parse, "parse(STR) -> F, REST")
#undef METHNAME
{ 0 }
};
* (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.
Py_DECREF(c);
}
*ne = i;
- return (d);
+ return (d);
}
static PyObject *meth__groupn(PyObject *me, PyObject *arg,
if (parse(&qd, &gp)) SYNERR(qd.e);
rc = fginfo_pywrap(&gp, ty);
end:
- return (rc);
+ return (rc);
}
static PyObject *meth__DHInfo_parse(PyObject *me, PyObject *arg)
gb.p = gc->r.p;
gb.q = gc->g.r;
g = group_binary(&gb);
- MP_DROP(gb.g);
+ MP_DROP(gb.g);
} else if (strcmp(G_NAME(g), "ec") == 0) {
gctx_ec *gc = (gctx_ec *)g;
ec_info ei;
METH (_BinDHInfo__groupn, 0)
KWMETH(_DHInfo_generate, "\
generate(PBITS, [qbits = 0, event = pgen_nullev,\n\
- rng = rand, nsteps = 0]) -> D")
+ rng = rand, nsteps = 0]) -> D")
KWMETH(_DHInfo_genlimlee, "\
genlimlee(PBITS, QBITS, [event = pgen_nullev, ievent = pgen_nullev,\n\
- rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])")
+ rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])")
KWMETH(_DHInfo_gendsa, "\
gendsa(PBITS, QBITS, SEED, [event = pgen_nullev, nsteps = 0])\n\
-> (D, SEED, COUNT)")
* (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 PyObject *kdmeth_matchp(PyObject *me, PyObject *arg)
{
key_filter f;
-
+
if (!PyArg_ParseTuple(arg, "O&:matchp", convfilter, &f))
return (0);
return (getbool(KEY_MATCH(KEYDATA_KD(me), &f)));
int err;
PyObject *rc = 0;
key_data *kd;
-
+
if (!PyArg_ParseTuple(arg, "s:plock", &tag))
goto end;
if ((err = key_plock(&kd, KEYDATA_KD(me), tag)) != 0)
int n;
PyObject *rc = 0;
key_data *kd;
-
+
if (!PyArg_ParseTuple(arg, "s#:lock", &p, &n))
goto end;
key_lock(&kd, KEYDATA_KD(me), p, n);
goto end;
if ((kd = key_decode(p, n)) == 0)
KEYERR(KERR_MALFORMED);
- rc = keydata_pywrap(kd);
+ rc = keydata_pywrap(kd);
end:
return (rc);
}
int err;
PyObject *rc = 0;
key_data *kd;
-
+
if (!PyArg_ParseTuple(arg, "s:punlock", &tag))
goto end;
if ((err = key_punlock(&kd, KEYDATA_KD(me), tag)) != 0)
int err;
PyObject *rc = 0;
key_data *kd;
-
+
if (!PyArg_ParseTuple(arg, "s#:unlock", &p, &n))
goto end;
if ((err = key_unlock(&kd, KEYDATA_KD(me), p, n)) != 0)
static PyObject *kmeth_delete(PyObject *me, PyObject *arg)
{
int err;
-
+
if (!PyArg_ParseTuple(arg, ":delete")) goto end;
if ((err = key_delete(KEY_KF(me), KEY_K(me))) != 0) KEYERR(err);
RETURN_ME;
static PyObject *kmeth_expire(PyObject *me, PyObject *arg)
{
int err;
-
+
if (!PyArg_ParseTuple(arg, ":expire")) goto end;
if ((err = key_expire(KEY_KF(me), KEY_K(me))) != 0) KEYERR(err);
RETURN_ME;
{
long t;
int err;
-
+
if (!PyArg_ParseTuple(arg, "l:used", &t)) goto end;
if ((err = key_used(KEY_KF(me), KEY_K(me), t)) != 0) KEYERR(err);
RETURN_ME;
}
end:
return (rc);
-}
+}
static PyObject *kfmeth_newkey(PyObject *me, PyObject *arg, PyObject *kw)
{
* (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.
return (PyFloat_FromDouble(f));
}
-#define COERCE(pre, PRE) \
+#define COERCE(pre, PRE) \
static int pre##_pycoerce(PyObject **x, PyObject **y) \
{ \
mp *z; \
}
BITOP(mp, setbit, 2c);
BITOP(mp, clearbit, 2c);
-BITOP(gf, setbit, );
+BITOP(gf, setbit, );
BITOP(gf, clearbit, );
#undef BITOP
static PyObject *mm_mexpr(PyObject *me, void *v, int n)
{ return mp_pywrap(mpmont_mexpr(MPMONT_PY(me), MP_NEW, v, n)); }
-
+
static void mp_mexp_drop(void *p)
{
mp_expfactor *f = p;
static PyObject *mm_mexp(PyObject *me, void *v, int n)
{ return mp_pywrap(mpmont_mexp(MPMONT_PY(me), MP_NEW, v, n)); }
-
+
static PyObject *mmmeth_mexp(PyObject *me, PyObject *arg)
{
return mexp_common(me, arg, sizeof(mp_expfactor),
static PyObject *mb_mexp(PyObject *me, void *v, int n)
{ return mp_pywrap(mpbarrett_mexp(MPBARRETT_PY(me), MP_NEW, v, n)); }
-
+
static PyObject *mbmeth_mexp(PyObject *me, PyObject *arg)
{
return mexp_common(me, arg, sizeof(mp_expfactor),
METH (gcdx,
"X.gcdx(Y) -> (gcd(X, Y), U, V) with X U + Y V = gcd(X, Y)")
METH (modinv, "X.modinv(Y) -> multiplicative inverse of Y mod X")
- METH (irreduciblep, "X.irreduciblep() -> true/false")
+ METH (irreduciblep, "X.irreduciblep() -> true/false")
#undef METHNAME
#define METHNAME(func) mpmeth_##func
KWMETH(tostring, "X.tostring(radix = 10) -> STR")
static PyMethodDef methods[] = {
#define METHNAME(func) meth_##func
- KWMETH(_MP_fromstring, "\
+ KWMETH(_MP_fromstring, "\
fromstring(STR, radix = 0) -> (X, REST)\n\
\n\
Parse STR as a large integer, according to radix. If radix is zero,\n\
read a prefix from STR to decide radix: allow `0' for octal, `0x' for hex\n\
or `R_' for other radix R.")
- KWMETH(_GF_fromstring, "\
+ KWMETH(_GF_fromstring, "\
fromstring(STR, radix = 0) -> (X, REST)\n\
\n\
Parse STR as a binary polynomial, according to radix. If radix is zero,\n\
* (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 void pixie_pydealloc(PyObject *me)
{
close(PIXIE_FD(me));
- FREEOBJ(me);
+ FREEOBJ(me);
}
static PyObject *pixmeth_read(PyObject *me, PyObject *arg, PyObject *kw)
* (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.
o = PyObject_New(pfilt_pyobj, pfilt_pytype);
o->f = *f;
o->st = pfilt_step(f, 0);
- return ((PyObject *)o);
+ return ((PyObject *)o);
}
static PyObject *pfilt_pymake(PyTypeObject *ty, PyObject *xobj)
goto end;
else if (l < PGEN_ABORT || l > PGEN_PASS)
VALERR("return code out of range");
- else
+ else
st = l;
end:
if (pyev) {
static PyGetSetDef pgstep_pygetset[] = {
#define GETSETNAME(op, name) ps##op##_##name
- GET (step, "S.step -> step size for the stepper")
+ GET (step, "S.step -> step size for the stepper")
#undef GETSETNAME
{ 0 }
};
static PyGetSetDef pgjump_pygetset[] = {
#define GETSETNAME(op, name) pj##op##_##name
- GET (jump, "S.jump -> jump size for the stepper")
+ GET (jump, "S.jump -> jump size for the stepper")
#undef GETSETNAME
{ 0 }
};
end:
mp_drop(r); mp_drop(x);
droppgev(&step); droppgev(&test); droppgev(&evt);
- return (rc);
+ return (rc);
}
static PyObject *meth_strongprime_setup(PyObject *me,
nsteps = 0, ntests = RabinMiller.iters(START.nbits)]) -> P")
KWMETH(strongprime_setup, "\
strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
- rng = rand, nsteps = 0]) -> (START, JUMP)")
+ rng = rand, nsteps = 0]) -> (START, JUMP)")
KWMETH(strongprime, "\
strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
- rng = rand, nsteps = 0]) -> P")
+ rng = rand, nsteps = 0]) -> P")
KWMETH(limlee, "\
limlee(PBITS, QBITS, [name = 'p', event = pgen_nullev,\n\
ievent = pgen_nullev, rng = rand, nsteps = 0]) -> (P, [Q, ...])")
* (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 }
};
k = db.nextkey(k)
commands = { 'create': [cmd_create,
- '[-c CIPHER] [-h HASH] [-m MAC] [PP-TAG]'],
- 'find' : [cmd_find, 'LABEL'],
- 'store' : [cmd_store, 'LABEL [VALUE]'],
- 'list' : [cmd_list, '[GLOB-PATTERN]'],
- 'changepp' : [cmd_changepp, ''],
- 'copy' : [cmd_copy, 'DEST-FILE [GLOB-PATTERN]'],
- 'to-pixie' : [cmd_topixie, '[TAG [PIXIE-TAG]]'],
- 'delete' : [cmd_del, 'TAG'],
- 'dump' : [cmd_dump, '']}
+ '[-c CIPHER] [-h HASH] [-m MAC] [PP-TAG]'],
+ 'find' : [cmd_find, 'LABEL'],
+ 'store' : [cmd_store, 'LABEL [VALUE]'],
+ 'list' : [cmd_list, '[GLOB-PATTERN]'],
+ 'changepp' : [cmd_changepp, ''],
+ 'copy' : [cmd_copy, 'DEST-FILE [GLOB-PATTERN]'],
+ 'to-pixie' : [cmd_topixie, '[TAG [PIXIE-TAG]]'],
+ 'delete' : [cmd_del, 'TAG'],
+ 'dump' : [cmd_dump, '']}
def version():
print '%s 1.0.0' % prog
def help():
version()
print
- usage(stdout)
+ usage(stdout)
print '''
Maintains passwords or other short secrets securely.
try:
opts, argv = getopt(argv[1:],
- 'hvuf:',
- ['help', 'version', 'usage', 'file='])
+ 'hvuf:',
+ ['help', 'version', 'usage', 'file='])
except GetoptError:
usage(stderr)
exit(1)
* (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.
static PyGetSetDef truerand_pygetset[] = {
#define GETSETNAME(op, name) tr##op##_##name
- GET (goodbits, "R.goodbits -> good bits of entropy remaining")
+ GET (goodbits, "R.goodbits -> good bits of entropy remaining")
#undef GETSETNAME
{ 0 }
};
if (keysz(n, info->keysz) != n) VALERR("bad key length");
return (grand_dopywrap(ty, info->func(k, n), f_freeme));
end:
- return (0);
+ return (0);
}
static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
((gcirand_func *)info->func)(k, n, i),
f_freeme));
end:
- return (0);
+ return (0);
}
static PyObject *gccrand_pywrap(const gccrand_info *info)
rc->bp.n = MP_COPY(bp.n);
end:
mp_drop(bp.p); mp_drop(bp.q); mp_drop(bp.n); mp_drop(x);
- return ((PyObject *)rc);
+ return ((PyObject *)rc);
}
static void bbspriv_pydealloc(PyObject *me)
static PyGetSetDef bbspriv_pygetset[] = {
#define GETSETNAME(op, name) bp##op##_##name
- GET (n, "R.n -> Blum modulus")
- GET (p, "R.p -> one of the factors of the modulus")
- GET (q, "R.q -> one of the factors of the modulus")
+ GET (n, "R.n -> Blum modulus")
+ GET (p, "R.p -> one of the factors of the modulus")
+ GET (q, "R.q -> one of the factors of the modulus")
#undef GETSETNAME
{ 0 }
};
fnew = fout + '.new'
if kid == 0:
try:
- out = file(fnew, 'w')
- dup2(out.fileno(), stdout.fileno())
- out.close()
- execl(sys.executable, sys.executable, fin)
+ out = file(fnew, 'w')
+ dup2(out.fileno(), stdout.fileno())
+ out.close()
+ execl(sys.executable, sys.executable, fin)
except:
- stderr.write('error running %s -> %s: %s\n' %
- (fin, fout, sys.exc_info()[1]))
- _exit(127)
+ stderr.write('error running %s -> %s: %s\n' %
+ (fin, fout, sys.exc_info()[1]))
+ _exit(127)
_, rc = waitpid(kid, 0)
if rc:
raise SubprocessFailure, (fin, rc)
rename(fnew, fout)
cat = Extension('catacomb._base',
- ['catacomb.c', 'bytestring.c', 'buffer.c',
- 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c',
- 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c',
- 'share.c', 'key.c', 'util.c'],
- ##extra_compile_args = ['-O0'],
- include_dirs = uniquify(incdirs),
- library_dirs = uniquify(libdirs),
- libraries = uniquify(libs))
+ ['catacomb.c', 'bytestring.c', 'buffer.c',
+ 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c',
+ 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c',
+ 'share.c', 'key.c', 'util.c'],
+ ##extra_compile_args = ['-O0'],
+ include_dirs = uniquify(incdirs),
+ library_dirs = uniquify(libdirs),
+ libraries = uniquify(libs))
setup(name = 'catacomb-python',
version = '1.0.0',
* (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.
* (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 PyObject *itemiter_pynext(PyObject *me)
{
PyObject *k = 0, *v = 0, *rc = 0;
-
+
if ((k = PyIter_Next(ITER_I(me))) != 0 &&
(v = PyObject_GetItem(ITER_MAP(me), k)) != 0)
rc = Py_BuildValue("(OO)", k, v);
static PyObject *valiter_pynext(PyObject *me)
{
PyObject *k = 0, *rc = 0;
-
+
if ((k = PyIter_Next(ITER_I(me))) != 0)
rc = PyObject_GetItem(ITER_MAP(me), k);
Py_XDECREF(k);
PyMapping_HasKey, /* @sq_contains@ */
0, /* @sq_inplace_concat@ */
0 /* @sq_inplace_repeat@ */
-};
+};
int gmap_pysize(PyObject *me)
{
(l = PyList_New(0)) == 0 ||
(i = PyObject_GetIter(me)) == 0)
goto done;
- while ((k = PyIter_Next(i)) != 0) {
+ while ((k = PyIter_Next(i)) != 0) {
if ((v = PyObject_GetItem(me, k)) == 0 ||
PyList_Append(l, v))
err = -1;