""" Example of Chaumian blinding """
import time, pprint, os, sha
-from Crypto.PublicKey import *
-from Crypto.Util.randpool import RandomPool
-from Crypto.Util import number
+from allmydata.Crypto.PublicKey import *
+from allmydata.Crypto.Util.randpool import RandomPool
+from allmydata.Crypto.Util import number
import cPickle as pickle
# Globals
forgotten pass phrase !
"""
import exceptions,os,string,time,sys
-from CryptoWorld import Ciphers,Hashes,Utils
+from allmydata.CryptoWorld import Ciphers,Hashes,Utils
from CommandLine import Application,SwitchOption,ArgumentOption
# Globals
# require a huge key and would double the size of the
# *.pys file.
import marshal
- from Crypto.Hash import MD5
+ from allmydata.Crypto.Hash import MD5
fp.close() # Close the original *.pyc file
from testkey import * # Get the key for verification
signature=marshal.load(secfile) # Read signature
# the listed directories.
from testkey import *
-from Crypto.Hash import MD5
+from allmydata.Crypto.Hash import MD5
import os, glob, sys
import marshal, compileall
import sys
-import Crypto.PublicKey.DSA
+import allmydata.Crypto.PublicKey.DSA
-key = Crypto.PublicKey.DSA.construct((
+key = allmydata.Crypto.PublicKey.DSA.construct((
# y
0x43E9162E224CBD1B66D7C27EB7E795392310B5E7AC6E0B1F60021F5E03F90E851CB7F76603FAE73907154371AE04EDBF0D9D557DF03488F34C18324B8DFEF5D2L,
# g
if __name__ == '__main__':
# Running this script directly will generate a new key and print it out
- from Crypto.PublicKey import DSA
- from Crypto.Util.randpool import KeyboardRandomPool
+ from allmydata.Crypto.PublicKey import DSA
+ from allmydata.Crypto.Util.randpool import KeyboardRandomPool
pool = KeyboardRandomPool(numbytes = 64)
pool.randomize()
print >>sys.stderr, 'Usage: '+sys.argv[0]+' [keylen]'
sys.exit(1)
key = DSA.generate(keylen, pool.get_bytes, sys.stdout.write)
- print "key = Crypto.PublicKey.DSA.construct(("
+ print "key = allmydata.Crypto.PublicKey.DSA.construct(("
for field in key.keydata:
print " #", field
print " " + hex(getattr(key, field)) + ","
import operator
import string
-from Crypto.Util.number import bytes_to_long, long_to_bytes
+from allmydata.Crypto.Util.number import bytes_to_long, long_to_bytes
# TBD: Not a very secure algorithm. Eventually, I'd like to use JHy's
# kernelrand module
import time
- from Crypto.Util import randpool
+ from allmydata.Crypto.Util import randpool
# TBD: key_size * 2 to work around possible bug in RandomPool?
pool = randpool.RandomPool(key_size * 2)
while key_size > pool.entropy:
aslong = 1
# ugly hack to force __import__ to give us the end-path module
- module = __import__('Crypto.Cipher.'+ciphermodule, None, None, ['new'])
+ module = __import__('allmydata.Crypto.Cipher.'+ciphermodule, None, None, ['new'])
a = AllOrNothing(module)
print 'Original text:\n=========='
__revision__ = "$Id: Chaffing.py,v 1.7 2003/02/28 15:23:21 akuchling Exp $"
-from Crypto.Util.number import bytes_to_long
+from allmydata.Crypto.Util.number import bytes_to_long
class Chaff:
"""Class implementing the chaff adding algorithm.
def _randnum(self, size):
# TBD: Not a very secure algorithm.
# TBD: size * 2 to work around possible bug in RandomPool
- from Crypto.Util import randpool
+ from allmydata.Crypto.Util import randpool
import time
pool = randpool.RandomPool(size * 2)
while size > pool.entropy:
# now get MACs for all the text blocks. The key is obvious...
print 'Calculating MACs...'
- from Crypto.Hash import HMAC, SHA
+ from allmydata.Crypto.Hash import HMAC, SHA
key = 'Jefferson'
macs = [HMAC.new(key, block, digestmod=SHA).digest()
for block in blocks]
__revision__ = "$Id: DSA.py,v 1.16 2004/05/06 12:52:54 akuchling Exp $"
-from Crypto.PublicKey.pubkey import *
-from Crypto.Util import number
-from Crypto.Util.number import bytes_to_long, long_to_bytes
-from Crypto.Hash import SHA
+from allmydata.Crypto.PublicKey.pubkey import *
+from allmydata.Crypto.Util import number
+from allmydata.Crypto.Util.number import bytes_to_long, long_to_bytes
+from allmydata.Crypto.Hash import SHA
try:
- from Crypto.PublicKey import _fastmath
+ from allmydata.Crypto.PublicKey import _fastmath
except ImportError:
_fastmath = None
__revision__ = "$Id: ElGamal.py,v 1.9 2003/04/04 19:44:26 akuchling Exp $"
-from Crypto.PublicKey.pubkey import *
-from Crypto.Util import number
+from allmydata.Crypto.PublicKey.pubkey import *
+from allmydata.Crypto.Util import number
class error (Exception):
pass
__revision__ = "$Id: RSA.py,v 1.20 2004/05/06 12:52:54 akuchling Exp $"
-from Crypto.PublicKey import pubkey
-from Crypto.Util import number
+from allmydata.Crypto.PublicKey import pubkey
+from allmydata.Crypto.Util import number
try:
- from Crypto.PublicKey import _fastmath
+ from allmydata.Crypto.PublicKey import _fastmath
except ImportError:
_fastmath = None
__revision__ = "$Id: pubkey.py,v 1.11 2003/04/03 20:36:14 akuchling Exp $"
import types, warnings
-from Crypto.Util.number import *
+from allmydata.Crypto.Util.number import *
# Basic public key class
class pubkey:
__revision__ = "$Id: qNEW.py,v 1.8 2003/04/04 15:13:35 akuchling Exp $"
-from Crypto.PublicKey import pubkey
-from Crypto.Util.number import *
-from Crypto.Hash import SHA
+from allmydata.Crypto.PublicKey import pubkey
+from allmydata.Crypto.Util.number import *
+from allmydata.Crypto.Hash import SHA
class error (Exception):
pass
# Contributed by Joris Bontje.
import time, pprint
-from Crypto.PublicKey import *
-from Crypto.Util.randpool import RandomPool
-from Crypto.Util import number
+from allmydata.Crypto.PublicKey import *
+from allmydata.Crypto.Util.randpool import RandomPool
+from allmydata.Crypto.Util import number
pool = RandomPool()
pool.stir()
from pyutil.randutil import insecurerandstr
from pyutil import benchutil
-from Crypto.Cipher import AES
+from allmydata.Crypto.Cipher import AES
MODE_CTR = AES.MODE_CTR # MODE_CTR is same value for all ciphers in pycrypto 2.0.1
if decrypted != self.text:
raise "FAILURE! decrypted does match original plaintext, self.text[:64]: %r, decrypted[:64]: %r" % (self.text[:64], decrypted[:64],)
-from Crypto.Cipher import *
+from allmydata.Crypto.Cipher import *
def bench_aes_ctr():
c = CipherRunner(AES, AES.MODE_CTR)
bignum = long
try:
- from Crypto.PublicKey import _fastmath
+ from allmydata.Crypto.PublicKey import _fastmath
except ImportError:
_fastmath = None
__revision__ = "$Id: randpool.py,v 1.14 2004/05/06 12:56:54 akuchling Exp $"
import time, array, types, warnings, os.path
-from Crypto.Util.number import long_to_bytes
+from allmydata.Crypto.Util.number import long_to_bytes
try:
- import Crypto.Util.winrandom as winrandom
+ import allmydata.Crypto.Util.winrandom as winrandom
except:
winrandom = None
def __init__(self, numbytes = 160, cipher=None, hash=None):
if hash is None:
- from Crypto.Hash import SHA as hash
+ from allmydata.Crypto.Hash import SHA as hash
# The cipher argument is vestigial; it was removed from
# version 1.1 so RandomPool would work even in the limited
if isinstance(hash, types.StringType):
# ugly hack to force __import__ to give us the end-path module
- hash = __import__('Crypto.Hash.'+hash,
+ hash = __import__('allmydata.Crypto.Hash.'+hash,
None, None, ['new'])
warnings.warn("'hash' parameter should now be a hashing module")
import string
import testdata
-from Crypto.Cipher import *
-from Crypto.Util.number import long_to_bytes
+from allmydata.Crypto.Cipher import *
+from allmydata.Crypto.Util.number import long_to_bytes
def die(string):
import sys
import time
-from Crypto.Util import number
+from allmydata.Crypto.Util import number
# Test of prime-generation speed
s = os.path.join(os.getcwd(), 'test')
sys.path.insert(0, s)
-from Crypto.Util import bench
+from allmydata.Crypto.Util import bench
args = sys.argv[1:]
quiet = "--quiet" in args
s = os.path.join(os.getcwd(), 'test')
sys.path.insert(0, s)
-from Crypto.Util import test
+from allmydata.Crypto.Util import test
args = sys.argv[1:]
quiet = "--quiet" in args
__revision__ = "$Id: test_chaffing.py,v 1.2 2003/02/28 15:23:59 akuchling Exp $"
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.Protocol import Chaffing
+from allmydata.Crypto.Protocol import Chaffing
tested_modules = [ "Crypto.Protocol.Chaffing" ]
import time, string, binascii
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.Hash import *
+from allmydata.Crypto.Hash import *
import testdata
tested_modules = [ "Crypto.Hash.MD2", "Crypto.Hash.MD4", "Crypto.Hash.MD5",
__revision__ = "$Id: test_number.py,v 1.4 2003/04/04 18:21:35 akuchling Exp $"
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.Util import number
+from allmydata.Crypto.Util import number
tested_modules = [ "Crypto.Util.number" ]
import sys, cPickle
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.PublicKey import *
-from Crypto.Util.randpool import RandomPool
-from Crypto.Util import number
+from allmydata.Crypto.PublicKey import *
+from allmydata.Crypto.Util.randpool import RandomPool
+from allmydata.Crypto.Util import number
tested_modules = [ "Crypto.PublicKey.RSA", "Crypto.PublicKey.DSA",
"Crypto.PublicKey.ElGamal", "Crypto.PublicKey.qNEW"]
__revision__ = "$Id: test_randpool.py,v 1.3 2003/02/28 15:24:01 akuchling Exp $"
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.Hash import SHA
-from Crypto.Util import randpool
+from allmydata.Crypto.Hash import SHA
+from allmydata.Crypto.Util import randpool
tested_modules = [ "Crypto.Util.randpool" ]
import binascii
from sancho.unittest import TestScenario, parse_args, run_scenarios
-from Crypto.Util import RFC1751
+from allmydata.Crypto.Util import RFC1751
tested_modules = [ "Crypto.Util.RFC1751" ]
]
# Test data for AES modes, from NIST SP800-38A
-from Crypto.Cipher import AES
+from allmydata.Crypto.Cipher import AES
counterstart='\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'