# 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.
# 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.
# 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.
# 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',
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']:
for i in [gcciphers, gchashes, gcmacs, gcprps]:
for c in i.itervalues():
d[c.name.replace('-', '_')] = c
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)' % \
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)
class _tmp:
def __repr__(me):
return 'KeySZRange(%d, %d, %d, %d)' % \
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'
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'
- (type(me).__name__, me.p, me.r, me.g)
+ (type(me).__name__, me.p, me.r, me.g)
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,
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)
x = enc.decode(msg, me.pubop(sig), me.n.nbits)
return x is None or x == msg
except ValueError:
x = enc.decode(msg, me.pubop(sig), me.n.nbits)
return x is None or x == msg
except ValueError:
def sgprime(start, step = 2, name = 'p', event = pgen_nullev, nsteps = 0):
start = MP(start)
return pgen(start, name, SimulStepper(step = step), SimulTester(), event,
def sgprime(start, step = 2, name = 'p', event = pgen_nullev, nsteps = 0):
start = MP(start)
return pgen(start, name, SimulStepper(step = step), SimulTester(), event,
def findprimitive(mod, hh = [], exp = None, name = 'g', event = pgen_nullev):
return pgen(0, name, PrimitiveStepper(), PrimitiveTester(mod, hh, exp),
def findprimitive(mod, hh = [], exp = None, name = 'g', event = pgen_nullev):
return pgen(0, name, PrimitiveStepper(), PrimitiveTester(mod, hh, exp),
def kcdsaprime(pbits, qbits, rng = rand,
def kcdsaprime(pbits, qbits, rng = rand,
hbits = pbits - qbits
h = pgen(rng.mp(hbits, 1), name + ' [h]',
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),
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))