From f9828846d55a4b691686abeb51c3c6613a54b693 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Thu, 14 Dec 2006 03:29:56 -0700
Subject: [PATCH] allmydata.Crypto: fix all internal imports

---
 Crypto/Demo/chaum.py               |  6 +++---
 Crypto/Demo/enc.py                 |  2 +-
 Crypto/Demo/secimp/secimp.py       |  2 +-
 Crypto/Demo/secimp/sign.py         |  2 +-
 Crypto/Demo/secimp/testkey.py      | 10 +++++-----
 Crypto/Protocol/AllOrNothing.py    |  6 +++---
 Crypto/Protocol/Chaffing.py        |  6 +++---
 Crypto/PublicKey/DSA.py            | 10 +++++-----
 Crypto/PublicKey/ElGamal.py        |  4 ++--
 Crypto/PublicKey/RSA.py            |  6 +++---
 Crypto/PublicKey/pubkey.py         |  2 +-
 Crypto/PublicKey/qNEW.py           |  6 +++---
 Crypto/PublicKey/test/rsa_speed.py |  6 +++---
 Crypto/Util/bench.py               |  4 ++--
 Crypto/Util/number.py              |  2 +-
 Crypto/Util/randpool.py            |  8 ++++----
 Crypto/Util/test.py                |  4 ++--
 Crypto/Util/test/prime_speed.py    |  2 +-
 Crypto/bench.py                    |  2 +-
 Crypto/test.py                     |  2 +-
 Crypto/test/test_chaffing.py       |  2 +-
 Crypto/test/test_hashes.py         |  2 +-
 Crypto/test/test_number.py         |  2 +-
 Crypto/test/test_publickey.py      |  6 +++---
 Crypto/test/test_randpool.py       |  4 ++--
 Crypto/test/test_rfc1751.py        |  2 +-
 Crypto/test/testdata.py            |  2 +-
 27 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/Crypto/Demo/chaum.py b/Crypto/Demo/chaum.py
index a2d3ec22..119a1ed9 100644
--- a/Crypto/Demo/chaum.py
+++ b/Crypto/Demo/chaum.py
@@ -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
diff --git a/Crypto/Demo/enc.py b/Crypto/Demo/enc.py
index 1d6924c9..0a7228e7 100644
--- a/Crypto/Demo/enc.py
+++ b/Crypto/Demo/enc.py
@@ -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
diff --git a/Crypto/Demo/secimp/secimp.py b/Crypto/Demo/secimp/secimp.py
index ad3ebc9c..451aa7e3 100644
--- a/Crypto/Demo/secimp/secimp.py
+++ b/Crypto/Demo/secimp/secimp.py
@@ -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
diff --git a/Crypto/Demo/secimp/sign.py b/Crypto/Demo/secimp/sign.py
index f9891599..afc90166 100644
--- a/Crypto/Demo/secimp/sign.py
+++ b/Crypto/Demo/secimp/sign.py
@@ -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
 
diff --git a/Crypto/Demo/secimp/testkey.py b/Crypto/Demo/secimp/testkey.py
index e8fef6c7..456b33ff 100644
--- a/Crypto/Demo/secimp/testkey.py
+++ b/Crypto/Demo/secimp/testkey.py
@@ -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)) + ","
diff --git a/Crypto/Protocol/AllOrNothing.py b/Crypto/Protocol/AllOrNothing.py
index 6f3505d2..5fc600d9 100644
--- a/Crypto/Protocol/AllOrNothing.py
+++ b/Crypto/Protocol/AllOrNothing.py
@@ -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=========='
diff --git a/Crypto/Protocol/Chaffing.py b/Crypto/Protocol/Chaffing.py
index fdfb82d0..36215f55 100644
--- a/Crypto/Protocol/Chaffing.py
+++ b/Crypto/Protocol/Chaffing.py
@@ -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]
diff --git a/Crypto/PublicKey/DSA.py b/Crypto/PublicKey/DSA.py
index 7947b6f5..685842ea 100644
--- a/Crypto/PublicKey/DSA.py
+++ b/Crypto/PublicKey/DSA.py
@@ -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
 
diff --git a/Crypto/PublicKey/ElGamal.py b/Crypto/PublicKey/ElGamal.py
index 026881c9..c919744b 100644
--- a/Crypto/PublicKey/ElGamal.py
+++ b/Crypto/PublicKey/ElGamal.py
@@ -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
diff --git a/Crypto/PublicKey/RSA.py b/Crypto/PublicKey/RSA.py
index e0e877ec..e43242f6 100644
--- a/Crypto/PublicKey/RSA.py
+++ b/Crypto/PublicKey/RSA.py
@@ -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
 
diff --git a/Crypto/PublicKey/pubkey.py b/Crypto/PublicKey/pubkey.py
index 5c75c3e3..5597fb7a 100644
--- a/Crypto/PublicKey/pubkey.py
+++ b/Crypto/PublicKey/pubkey.py
@@ -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:
diff --git a/Crypto/PublicKey/qNEW.py b/Crypto/PublicKey/qNEW.py
index 65f8ae36..d8e98f18 100644
--- a/Crypto/PublicKey/qNEW.py
+++ b/Crypto/PublicKey/qNEW.py
@@ -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
diff --git a/Crypto/PublicKey/test/rsa_speed.py b/Crypto/PublicKey/test/rsa_speed.py
index e2b07d66..00a13e82 100644
--- a/Crypto/PublicKey/test/rsa_speed.py
+++ b/Crypto/PublicKey/test/rsa_speed.py
@@ -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()
diff --git a/Crypto/Util/bench.py b/Crypto/Util/bench.py
index ae181b5f..a1682939 100644
--- a/Crypto/Util/bench.py
+++ b/Crypto/Util/bench.py
@@ -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)
 
diff --git a/Crypto/Util/number.py b/Crypto/Util/number.py
index 9d50563e..7a5de7de 100644
--- a/Crypto/Util/number.py
+++ b/Crypto/Util/number.py
@@ -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
 
diff --git a/Crypto/Util/randpool.py b/Crypto/Util/randpool.py
index 467501c5..fb15ed69 100644
--- a/Crypto/Util/randpool.py
+++ b/Crypto/Util/randpool.py
@@ -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")
 
diff --git a/Crypto/Util/test.py b/Crypto/Util/test.py
index 020fb146..b4a3c143 100644
--- a/Crypto/Util/test.py
+++ b/Crypto/Util/test.py
@@ -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
diff --git a/Crypto/Util/test/prime_speed.py b/Crypto/Util/test/prime_speed.py
index 320c132d..672bd970 100644
--- a/Crypto/Util/test/prime_speed.py
+++ b/Crypto/Util/test/prime_speed.py
@@ -1,6 +1,6 @@
 
 import time
-from Crypto.Util import number
+from allmydata.Crypto.Util import number
 
 # Test of prime-generation speed
 
diff --git a/Crypto/bench.py b/Crypto/bench.py
index 5f52431e..65cad69a 100644
--- a/Crypto/bench.py
+++ b/Crypto/bench.py
@@ -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
diff --git a/Crypto/test.py b/Crypto/test.py
index 97a4748a..ff59b067 100644
--- a/Crypto/test.py
+++ b/Crypto/test.py
@@ -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
diff --git a/Crypto/test/test_chaffing.py b/Crypto/test/test_chaffing.py
index a9d02965..512b53bc 100644
--- a/Crypto/test/test_chaffing.py
+++ b/Crypto/test/test_chaffing.py
@@ -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" ]
 
diff --git a/Crypto/test/test_hashes.py b/Crypto/test/test_hashes.py
index 91630797..8e9e074e 100644
--- a/Crypto/test/test_hashes.py
+++ b/Crypto/test/test_hashes.py
@@ -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",
diff --git a/Crypto/test/test_number.py b/Crypto/test/test_number.py
index 776d33e4..39a87fce 100644
--- a/Crypto/test/test_number.py
+++ b/Crypto/test/test_number.py
@@ -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" ]
 
diff --git a/Crypto/test/test_publickey.py b/Crypto/test/test_publickey.py
index 83fdea75..d03fa91f 100644
--- a/Crypto/test/test_publickey.py
+++ b/Crypto/test/test_publickey.py
@@ -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"]
diff --git a/Crypto/test/test_randpool.py b/Crypto/test/test_randpool.py
index f1cb6a55..800af9ca 100644
--- a/Crypto/test/test_randpool.py
+++ b/Crypto/test/test_randpool.py
@@ -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" ]
 
diff --git a/Crypto/test/test_rfc1751.py b/Crypto/test/test_rfc1751.py
index c86fb4c8..60ec4427 100644
--- a/Crypto/test/test_rfc1751.py
+++ b/Crypto/test/test_rfc1751.py
@@ -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" ]
 
diff --git a/Crypto/test/testdata.py b/Crypto/test/testdata.py
index 3c21b8e8..d6efdf28 100644
--- a/Crypto/test/testdata.py
+++ b/Crypto/test/testdata.py
@@ -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'
 
-- 
2.45.2