pyTomCrypt.py (v0.20)
                     ---------------------
    
    A ctypes Python wrapper for LibTomCrypt v1.17.  See http://libtom.org/
    
    Implements:
      - public key algorithms:  RSA, DSA, ECDSA, ECDH
      - hash algorithms:
          md2, md4, md5, rmd128, rmd160, rmd256, rmd320, 
          sha1, sha224, sha256, sha384, sha512, tiger, whirlpool
      - symmetric ciphers:
          aes, rijndael, twofish, blowfish, des, rc2, des3, cast5, 
          kasumi, anubis, kseed, khazad, noekeon, rc5, rc6, xtea,
          skipjack
      - modes: ecb, cbc, ctr, cfb, ofb
      - MACs:  HMAC, OMAC, PMAC, Pelican, XCBC, F9
      - PRNGs:  fortuna, rc4, sprng, yarrow, sober128
      - libtomcrypt  1.17
      - libtommath   0.41 (default)
      - tomsfastmath 0.12 (optional)
    
    Not [yet] supported:
      - symmetric cipher: safer
      - modes: lrw, f8
      - hash: chc
      - EC curves other than Tom's base set
      - DSA encrypt/decrypt
      - ASN.1/DER routines
      - EAX, OCB, CCM, GCM
    
    Examples of use: see contents of demos and test dirs
    
    
    Copyright (c) 2005-2011 by Larry Bugbee, Kent, WA
    All Rights Reserved.
    
    pyTomCrypt IS EXPERIMENTAL SOFTWARE FOR EDUCATIONAL
    PURPOSES ONLY.  IT IS MADE AVAILABLE "AS-IS" WITHOUT 
    WARRANTY OR GUARANTEE OF ANY KIND.  ITS USE SIGNIFIES 
    FULL ACCEPTANCE OF ALL RISK, UNDER ALL CIRCUMSTANCES, NO 
    EXCEPTIONS.
    
    To make your learning and experimentation less cumbersome, 
    pyTomCrypt is free for any use.      
    
    pyTomCrypt-v0.20.zip
    
    Enjoy,
    
    Larry Bugbee
    bugbee@seanet.com
    June 4, 2007
    rev July 2011
        
    
    ----------------------------------------------------------------
      
    ToDo:
      - support for EC curves other than Tom's base set
      - ASN.1/DER routines
      - a minimalist build for NSA's Suite B
      - provide a mechanism to allow the packaging of LTC, LTM, TFM 
        and application code as a single Python application without 
        having to install the libs into /usr/lib.  ...including auto 
        detect of platform to support native code for multiple 
        platforms.  (I have a version of hotSalsa.py, an app that 
        builds on Salsa20, that does this.)
    
    Changes for v0.20 (August 18, 2007):
      - added support for ELF by adding SONAME to makefile.plus 
        (suggested by Noah and the Fedora crew)
      - changed default math lib back to LTM (libtommath)
      
    Changes for v0.19 (June 4, 2007):
      - added support for Tom's FastMath lib - to switch between LTM
        and TFM, change the value of USE_MATH_LIB in pyTomCrypt.py
      
    Changes for v0.18:
      - support libtomcrypt v1.17 by upgrading tomcrypt_plus.c to
        reflect new "LTC_" name changes
      
    ----------------------------------------------------------------
    
    
                           Installation
                           ------------
    
    Prerequisites (compiled and installed):
      - Python 2.5, or Python 2.4.x with ctypes added
      - LibTomCrypt  1.17
      - LibTomMath   0.41
      - TomsFastMath 0.12
    
    
    Configuration
    -------------                    suggested location:
    
      your Python program
             |
        pyTomCrypt.py                in Python's site-packages
             |   \
             | libtomcrypt_plus.so   in /usr/local/lib
             |   /
        libtomcrypt.so               in /usr/local/lib
             |
        libtommath.so                in /usr/local/lib
    
    
    LibTomCrypt, LibTomMath (LTM), and TomsFastMath (TFM)
    -----------------------------------------------------
      Follow Tom's instructions to create shared libraries just
      as if you were going to use them in a C program.  Do NOT 
      make them Python extensions; it won't work.
      
      See http://libtom.org/ for his build instructions.  (I'm
      running OSX and Ubuntu and found it necessary to tweak 
      Tom's makefiles some, so if you get stuck, I can make mine 
      available.)
      
    
    LibTomCrypt_plus
    ----------------
      LibTomCrypt_plus is a very small C module to provide some 
      constants and struct sizes not exposed by LibTomCrypt.  
      Perhaps a future version will include these small functions, 
      but until then...
      
        make -f makefile.plus
        sudo make -f makefile.plus install
    
      Be sure to build libtomcrypt_plus.so as a shared library, 
      NOT a Python extension.  
    
    
    pyTomCrypt
    ----------
    
        sudo python setup.py install
    
      To switch between LTM and TFM, change the value of 
      USE_MATH_LIB in pyTomCrypt.py
    
    
    Installed and tested on:
      - G4 miniMac, MacOSX 10.4.9, gcc 4.0, Python 2.4
      - G4 miniMac, Ubuntu 7.04,   gcc 4.1, Python 2.5
      - AMD Athlon, Mandriva 2006, gcc 3.4, Python 2.4
    
    
    A few general comments about ctypes
    -----------------------------------
      ctypes will look in various locations for shared libraries 
      but where can vary by platform.  Libraries in /usr/lib are 
      pretty much guaranteed to be found, but that may not be the 
      best place for your compiled libraries.  Personally I prefer
      /usr/local/lib.  Regardless of where, you may need to set 
      and export a load library path appropriate to your platform.
        LD_LIBRARY_PATH     Linux
        DYLD_LIBRARY_PATH   Darwin
        SHLIB_PATH          HP-UX
        LD_LIBRARY_PATH_32  32-bit Solaris
        LD_LIBRARY_PATH_64  64-bit Solaris
    
      Recently, some libraries did not load and the complaint was 
      unresolved labels.  Subject to additional testing, it appears 
      ctypes does not work well in dynamic linking environments,  
      that is, ctypes prefers libraries that are fully linked.  
      This may require the removal of extern when the library does 
      indeed include an implementation, and this may also require 
      using the -l option to specify additional libraries that 
      should be included in the link.  Disabling options such as 
      -undefined suppress may be helpful in finding unresolved 
      labels.
    
    ----------------------------------------------------------------
    ----------------------------------------------------------------
    ----------------------------------------------------------------