mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 10:46:24 +00:00
allmydata.Crypto: fix all internal imports
This commit is contained in:
parent
8a3af8827a
commit
f9828846d5
@ -3,9 +3,9 @@
|
||||
""" 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
|
||||
|
@ -11,7 +11,7 @@
|
||||
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
|
||||
|
@ -57,7 +57,7 @@ def secimport(name, globals=None, locals=None, fromlist=None):
|
||||
# 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
|
||||
|
@ -4,7 +4,7 @@
|
||||
# the listed directories.
|
||||
|
||||
from testkey import *
|
||||
from Crypto.Hash import MD5
|
||||
from allmydata.Crypto.Hash import MD5
|
||||
import os, glob, sys
|
||||
import marshal, compileall
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
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
|
||||
@ -17,8 +17,8 @@ key = Crypto.PublicKey.DSA.construct((
|
||||
|
||||
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()
|
||||
@ -31,7 +31,7 @@ if __name__ == '__main__':
|
||||
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)) + ","
|
||||
|
@ -21,7 +21,7 @@ __revision__ = "$Id: AllOrNothing.py,v 1.8 2003/02/28 15:23:20 akuchling Exp $"
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ class AllOrNothing:
|
||||
# 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:
|
||||
@ -270,7 +270,7 @@ Where:
|
||||
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=========='
|
||||
|
@ -44,7 +44,7 @@ http://theory.lcs.mit.edu/~rivest/chaffing.txt
|
||||
|
||||
__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.
|
||||
@ -146,7 +146,7 @@ class Chaff:
|
||||
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:
|
||||
@ -181,7 +181,7 @@ likely to effect their Safety and Happiness.
|
||||
|
||||
# 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]
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
__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
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
__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
|
||||
|
@ -12,11 +12,11 @@
|
||||
|
||||
__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
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
__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:
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
__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
|
||||
|
@ -4,9 +4,9 @@
|
||||
# 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()
|
||||
|
@ -4,7 +4,7 @@ from pyutil.assertutil import _assert, precondition, postcondition
|
||||
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
|
||||
|
||||
@ -73,7 +73,7 @@ class CipherRunner:
|
||||
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)
|
||||
|
||||
|
@ -14,7 +14,7 @@ __revision__ = "$Id: number.py,v 1.13 2003/04/04 18:21:07 akuchling Exp $"
|
||||
|
||||
bignum = long
|
||||
try:
|
||||
from Crypto.PublicKey import _fastmath
|
||||
from allmydata.Crypto.PublicKey import _fastmath
|
||||
except ImportError:
|
||||
_fastmath = None
|
||||
|
||||
|
@ -13,9 +13,9 @@
|
||||
__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
|
||||
|
||||
@ -54,7 +54,7 @@ class RandomPool:
|
||||
|
||||
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
|
||||
@ -64,7 +64,7 @@ class RandomPool:
|
||||
|
||||
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")
|
||||
|
||||
|
@ -17,8 +17,8 @@ import random
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
import time
|
||||
from Crypto.Util import number
|
||||
from allmydata.Crypto.Util import number
|
||||
|
||||
# Test of prime-generation speed
|
||||
|
||||
|
@ -17,7 +17,7 @@ sys.path.insert(0, s)
|
||||
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
|
||||
|
@ -17,7 +17,7 @@ sys.path.insert(0, s)
|
||||
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
|
||||
|
@ -5,7 +5,7 @@
|
||||
__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" ]
|
||||
|
||||
|
@ -7,7 +7,7 @@ __revision__ = "$Id: test_hashes.py,v 1.4 2004/08/13 22:23:12 akuchling Exp $"
|
||||
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",
|
||||
|
@ -5,7 +5,7 @@
|
||||
__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" ]
|
||||
|
||||
|
@ -6,9 +6,9 @@ __revision__ = "$Id: test_publickey.py,v 1.7 2003/04/04 19:38:28 akuchling Exp $
|
||||
|
||||
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"]
|
||||
|
@ -5,8 +5,8 @@
|
||||
__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" ]
|
||||
|
||||
|
@ -6,7 +6,7 @@ __revision__ = "$Id: test_rfc1751.py,v 1.3 2003/02/28 15:24:01 akuchling Exp $"
|
||||
|
||||
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" ]
|
||||
|
||||
|
@ -447,7 +447,7 @@ aes = [# 128-bit key
|
||||
]
|
||||
|
||||
# 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'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user