<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yobi.be/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tiftof</id>
	<title>YobiWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yobi.be/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tiftof"/>
	<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Special:Contributions/Tiftof"/>
	<updated>2026-05-23T22:27:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5306</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5306"/>
		<updated>2008-11-10T09:21:20Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|One-way Functions&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||    Py      ||  C            &lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||  Py (SHA1 &amp;amp; SHA2 family)|| C (SHA-1 &amp;amp; 256)&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||     Py        ||   Py         &lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          &lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||   Py            ||               &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
** new Hash functions: extended SHA family, Whirpool, RadioGatùn, PBKDF2&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Hash subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Hash package (new implementations and imports from pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash/python_*.py&lt;br /&gt;
|&lt;br /&gt;
* wrappers for the pure python (py*.py) implementations of hash functions&lt;br /&gt;
* provide &amp;quot;new()&amp;quot; function and some doctests&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash/py*.py&lt;br /&gt;
|&lt;br /&gt;
*pure python implementations of hash functions&lt;br /&gt;
*pyradiogatun.py is own code, the rest is gathered from other sources&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[http://www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5305</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5305"/>
		<updated>2008-11-10T09:11:24Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Differences with pycrypto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|One-way Functions&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||    Py      ||  C            &lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||  Py (SHA1 &amp;amp; SHA2 family)|| C (SHA-1 &amp;amp; 256)&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||     Py        ||   Py         &lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          &lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||   Py            ||               &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
** new Hash functions: extended SHA family, Whirpool, RadioGatùn, PBKDF2&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[http://www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5304</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5304"/>
		<updated>2008-11-10T09:11:00Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* One-way Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
One-way Functions&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||    Py      ||  C            &lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||  Py (SHA1 &amp;amp; SHA2 family)|| C (SHA-1 &amp;amp; 256)&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||     Py        ||   Py         &lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          &lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||   Py            ||               &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
** new Hash functions: extended SHA family, Whirpool, RadioGatùn, PBKDF2&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[http://www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5303</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5303"/>
		<updated>2008-11-10T09:10:31Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Differences with pycrypto */ added Hash functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||    Py      ||  C            &lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||  Py (SHA1 &amp;amp; SHA2 family)|| C (SHA-1 &amp;amp; 256)&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||     Py        ||   Py         &lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||   Py            ||               &lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          &lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||   Py            ||               &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
** new Hash functions: extended SHA family, Whirpool, RadioGatùn, PBKDF2&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[http://www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5259</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5259"/>
		<updated>2008-10-29T19:58:09Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Stream Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[http://www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5258</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5258"/>
		<updated>2008-10-29T16:04:03Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Stream Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**Snow 3G&lt;br /&gt;
***www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
***&amp;quot;The main difference in SNOW 3G is the addition of a second S-box giving higher resistance against possible future advances in algebraic cryptanalysis&amp;quot;[www.ecrypt.eu.org/documents/D.SPA.21-1.1.pdf]&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5257</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5257"/>
		<updated>2008-10-29T15:29:21Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Stream Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**www.gsmworld.com/using/algorithms/docs/snow_3g_spec.pdf&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5256</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5256"/>
		<updated>2008-10-28T19:28:28Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Stream Ciphers ==&lt;br /&gt;
*SNOW2 / SNOW3G&lt;br /&gt;
**http://www.it.lth.se/cryptology/snow/&lt;br /&gt;
**LFSR, FSM, S-Box&lt;br /&gt;
*Grain&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/grainpf.html&lt;br /&gt;
**LFSR, NFSR, output function&lt;br /&gt;
*Trivium&lt;br /&gt;
**http://www.ecrypt.eu.org/stream/triviumpf.html&lt;br /&gt;
*LFSR&lt;br /&gt;
*(self)Shrinking Generator&lt;br /&gt;
*ARC4&lt;br /&gt;
**http://en.wikipedia.org/wiki/RC4&lt;br /&gt;
*XOR&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Python&amp;diff=5229</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Python&amp;diff=5229"/>
		<updated>2008-10-25T12:52:56Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: added section &amp;quot;Installing another Python version&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Misc links==&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
== Installing another Python version ==&lt;br /&gt;
When installing a python version not available as a package for your linux distribution:&lt;br /&gt;
 $ ./configure&lt;br /&gt;
 $ make&lt;br /&gt;
 # make altinstall&lt;br /&gt;
this newly installed python version will then be available in your path as pythonX.X (with X.X being the python version)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
When you want to be able to use &#039;&#039;&#039;setuptools&#039;&#039;&#039;, you also need zlib. zlib will be compiled with python if the zlib-dev package is available on your system. On debian/ubuntu:&lt;br /&gt;
 # apt-get install zlib1g-dev&lt;br /&gt;
and then install python. Python setup will find zlib by itself.&amp;lt;br&amp;gt;Installing setuptools:&lt;br /&gt;
*[http://pypi.python.org/pypi/setuptools download] the appropriate egg&lt;br /&gt;
*install it by running it as a shell script&lt;br /&gt;
 # sh setuptools-x.x-pyx.x.egg&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Python can be installed with every module available on your systems python install by first doing:&lt;br /&gt;
 # apt-get build-dep python2.5&lt;br /&gt;
&lt;br /&gt;
== Setup Script ==&lt;br /&gt;
=== distutils vs setuptools ===&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
=== distutils ===&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
=== setuptools ===&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
==Installing development Python packages==&lt;br /&gt;
&amp;lt;br&amp;gt;During development, it&#039;s painful to install the package every time you&#039;re doing sth on it.&lt;br /&gt;
&amp;lt;br&amp;gt;There are various ways to import a module actually&lt;br /&gt;
===Basic import from a local directory===&lt;br /&gt;
In your code, e.g. mycode.py:&lt;br /&gt;
 from Module1 import Function1&lt;br /&gt;
Usage: pointing to the path containing the module&lt;br /&gt;
 PYTHONPATH=/path/to/src/directory/above/Module1 python mycode.py&lt;br /&gt;
===Import from a local directory, using egg_info===&lt;br /&gt;
This is using python-pkg-resources&lt;br /&gt;
&lt;br /&gt;
Installing (locally):&lt;br /&gt;
 python setup.py egg_info&lt;br /&gt;
&lt;br /&gt;
In your code, e.g. mycode.py:&lt;br /&gt;
 from pkg_resources import require&lt;br /&gt;
 require(&amp;quot;Module1&amp;gt;=1.0&amp;quot;)&lt;br /&gt;
 from Module1 import Function1&lt;br /&gt;
&lt;br /&gt;
Usage: pointing to the path containing the egg_info&lt;br /&gt;
 PYTHONPATH=/path/to/src/directory/containing/egg_info python mycode.py&lt;br /&gt;
&lt;br /&gt;
Cleaning:&lt;br /&gt;
 rm -rf /path/to/src/directory/containing/egg_info/Module1.egg-info&lt;br /&gt;
===Install a development version===&lt;br /&gt;
Actually symlinking to the working directory&lt;br /&gt;
&amp;lt;br&amp;gt;This is using python-pkg-resources&lt;br /&gt;
&lt;br /&gt;
Installing (symlink):&lt;br /&gt;
 sudo python setup.py develop&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 python mycode.py&lt;br /&gt;
&lt;br /&gt;
Cleaning:&lt;br /&gt;
 sudo python setup.py develop --uninstall&lt;br /&gt;
 rm -rf /path/to/src/directory/containing/egg_info/Module1.egg-info&lt;br /&gt;
===Create and installing an egg===&lt;br /&gt;
This is using python-pkg-resources&lt;br /&gt;
&lt;br /&gt;
Installing:&lt;br /&gt;
 python setup.py bdist_egg&lt;br /&gt;
 sudo easy_install dist/Module1-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 python mycode.py&lt;br /&gt;
&lt;br /&gt;
Cleaning:&lt;br /&gt;
 sudo rm /usr/lib/python2.5/site-packages/Module1-1.0-py2.5.egg&lt;br /&gt;
===Create and using locally an egg===&lt;br /&gt;
This is using python-pkg-resources&lt;br /&gt;
&lt;br /&gt;
Creating:&lt;br /&gt;
 python setup.py bdist_egg&lt;br /&gt;
&lt;br /&gt;
In your code, e.g. mycode.py:&lt;br /&gt;
 from pkg_resources import require&lt;br /&gt;
 require(&amp;quot;Module1&amp;gt;=1.0&amp;quot;)&lt;br /&gt;
 from Module1 import Function1&lt;br /&gt;
&lt;br /&gt;
Usage: pointing to the path containing the egg file&lt;br /&gt;
 PYTHONPATH=/path/to/your/dist/ python mycode.py&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5227</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5227"/>
		<updated>2008-10-23T20:15:06Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc1321.txt&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**[http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf FIPS 180-2]&lt;br /&gt;
**SHA1: http://www.rfc-editor.org/rfc/rfc3174.txt&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**[http://paginas.terra.com.br/informatica/paulobarreto/WhirlpoolPage.html Homepage]&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**http://homes.esat.kuleuven.be/~bosselae/ripemd160.html&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5226</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5226"/>
		<updated>2008-10-23T15:55:40Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
**standard + testvectors: [http://www.ietf.org/rfc/rfc3962.txt RFC 3962]&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5180</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5180"/>
		<updated>2008-10-16T15:24:03Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
***uses same API as standard python hashing modules&lt;br /&gt;
***MIT License&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5179</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5179"/>
		<updated>2008-10-16T15:20:09Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA-256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
**SHA-224, 256, 384, and 512 at http://reikon.us/sha2/&lt;br /&gt;
***less readable than pypy implementation (pypy is using same structure for md5 and sha1)&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5178</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5178"/>
		<updated>2008-10-16T13:32:53Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python&amp;lt;br&amp;gt;-&amp;gt; same implementation used in pycrypto: no need to copy it again in cryptoplus?&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5177</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5177"/>
		<updated>2008-10-16T09:55:57Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Author &amp;amp; Download ===&lt;br /&gt;
This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git here]&lt;br /&gt;
&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (Python License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (Python License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available here: [http://www.bjrn.se/code/whirlpoolpy.txt python truecrypt implementation]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**RipeMD-160 available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
**modify to add RipeMD-128?&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python -&amp;gt; same implementation used in pycrypto&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== [[Python]] ===&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5171</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5171"/>
		<updated>2008-10-16T00:00:10Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: deleted comments from during development&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a development done by Christophe Oosterlynck under my supervision during his thesis work &amp;amp; internship at NXP.&lt;br /&gt;
&lt;br /&gt;
The code is available [http://repo.or.cz/w/python-cryptoplus.git?a=blob;f=src/CryptoPlus/Cipher/pypresent.py;hb=HEAD here]&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
* decrypting a block&lt;br /&gt;
* supports amount of rounds different from the standard amount of 32&lt;br /&gt;
** tested with 32, 64, 128 and 65534 rounds&lt;br /&gt;
** PRESENT reference implementation supports amount of rounds up to 65534&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5158</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5158"/>
		<updated>2008-10-15T16:21:35Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (MIT License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (MIT License)&lt;br /&gt;
***can be modified for other SHA&#039;s&lt;br /&gt;
***uses standard python hash api&lt;br /&gt;
**SHA256 implementation: https://vcs.slash-me.net/snippets/sha256/sha256.py&lt;br /&gt;
***short code but less readable than the one from pypy&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available at [python truecrypt implementation http://www.bjrn.se/code/whirlpoolpy.txt]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python -&amp;gt; same implementation used in pycrypto&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5157</id>
		<title>Sage Cross Reference Table of Wishes and Availability</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5157"/>
		<updated>2008-10-15T16:19:22Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* One-way Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
==Table==&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
* C: wrapped C code&lt;br /&gt;
* Py: pure python code&lt;br /&gt;
* Sage: sage code&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!Sage&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|optional packages&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|other python packages&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot;|python code&amp;lt;br&amp;gt;available&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
!PyCrypto&lt;br /&gt;
!PyOpenSSL&lt;br /&gt;
!M2Crypto&lt;br /&gt;
!TLS Lite&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Block Ciphers===&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Block cipher algorithms====&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/][http://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||               ||  C     ||     C      ||           ||          ||[http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/blowfish.py] [http://www.michaelgilfix.com/files/blowfish.py] [http://ivoras.sharanet.org/projects/blowfish.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      ||            ||     C     ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||               ||  C      ||            ||     C     || Py       ||[http://psionicist.online.fr/code/] [http://jclement.ca/software/pyrijndael/][http://bitconjurer.org/rijndael.py tlslite implementation]&lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Modes of operation====&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||               ||  C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||               ||  C      ||            ||    C      || Py       ||&lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||               ||  C      ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/pytruecrypt/]&lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Paddings====&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Stream Ciphers===&lt;br /&gt;
|-&lt;br /&gt;
|   RC4              ||               ||   C     ||            ||    C      || Py          ||[http://www.amk.ca/python/writing/crypto-curiosa.html]&lt;br /&gt;
|-&lt;br /&gt;
|   A5/1 A5/2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SNOW2 SNOW3G     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HC-128           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RABBIT           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Salsa 20/12      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SOSEMANUK        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  F-FCSR            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Grain             ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  MICKEY            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Trivium           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  LFSR              ||   Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Shrinking generator||  Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Self-Shrinking generator||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||   Py(C)          ||  C            ||            ||     C     ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||   Py(C)          || C (SHA-1 &amp;amp; 256)||            ||    C (only SHA1)  ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy(SHA1)][https://vcs.slash-me.net/snippets/sha256/sha256.py SHA256]&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||               ||               ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||               || Py          ||            || C (ripemd-160) ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   MDC-2               ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Davies-Meyer        ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Matyas-Meyer-Oseas  ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Miyaguchi-Preneel   ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          ||            ||   C***    || Py          ||&lt;br /&gt;
|-&lt;br /&gt;
|   NMAC                ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   KDF family          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||               ||               ||            ||    C***  ||          ||[http://www.dlitz.net/software/python-pbkdf2/]&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
===Public-key cryptography===&lt;br /&gt;
|-&lt;br /&gt;
|   Misc                ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====ECC====&lt;br /&gt;
|-&lt;br /&gt;
|  all coordinate sys.     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|cf [http://www.hyperelliptic.org/EFD/ EFD] ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Other====&lt;br /&gt;
|-&lt;br /&gt;
|  RSA                        ||               ||    C**     ||            ||    C (PKCS1)      || Py          ||[http://pypi.python.org/pypi/asym/0.1.0] [http://www.stuvel.eu/rsa]&lt;br /&gt;
|-&lt;br /&gt;
|  DSA                        ||               ||   C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  ElGamal                    ||               ||    C     ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  DH                         ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  XTR                        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Paillier                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  NTRUE                      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Pseudo-random generators===&lt;br /&gt;
|-&lt;br /&gt;
|    cf NIST                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|    Mersenne Twister          ||   Py          ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Cryptanalysis tools===&lt;br /&gt;
|- &lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Entropy finder: [http://deadhacker.com/2007/05/13/finding-entropy-in-binary-files/] and [http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html] then [http://blog.dkbza.org/2007/07/scanning-data-for-entropy-anomalies-ii.html]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
/**Check if PKCS#1 v1.5/v2.1 and if CTR&amp;lt;br&amp;gt;&lt;br /&gt;
/***See EVP.py&amp;lt;br&amp;gt;&lt;br /&gt;
book*: C-code available in Oreilly&#039;s OpenSSL book&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5156</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5156"/>
		<updated>2008-10-15T16:02:55Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Current Situation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy] (MIT License)&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy] (MIT License)&lt;br /&gt;
***can it be modified for other SHA&#039;s?&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available at [python truecrypt implementation http://www.bjrn.se/code/whirlpoolpy.txt]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python -&amp;gt; same implementation used in pycrypto&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5154</id>
		<title>Sage Cross Reference Table of Wishes and Availability</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5154"/>
		<updated>2008-10-15T14:45:58Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* One-way Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
==Table==&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
* C: wrapped C code&lt;br /&gt;
* Py: pure python code&lt;br /&gt;
* Sage: sage code&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!Sage&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|optional packages&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|other python packages&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot;|python code&amp;lt;br&amp;gt;available&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
!PyCrypto&lt;br /&gt;
!PyOpenSSL&lt;br /&gt;
!M2Crypto&lt;br /&gt;
!TLS Lite&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Block Ciphers===&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Block cipher algorithms====&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/][http://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||               ||  C     ||     C      ||           ||          ||[http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/blowfish.py] [http://www.michaelgilfix.com/files/blowfish.py] [http://ivoras.sharanet.org/projects/blowfish.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      ||            ||     C     ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||               ||  C      ||            ||     C     || Py       ||[http://psionicist.online.fr/code/] [http://jclement.ca/software/pyrijndael/][http://bitconjurer.org/rijndael.py tlslite implementation]&lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Modes of operation====&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||               ||  C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||               ||  C      ||            ||    C      || Py       ||&lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||               ||  C      ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/pytruecrypt/]&lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Paddings====&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Stream Ciphers===&lt;br /&gt;
|-&lt;br /&gt;
|   RC4              ||               ||   C     ||            ||    C      || Py          ||[http://www.amk.ca/python/writing/crypto-curiosa.html]&lt;br /&gt;
|-&lt;br /&gt;
|   A5/1 A5/2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SNOW2 SNOW3G     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HC-128           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RABBIT           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Salsa 20/12      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SOSEMANUK        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  F-FCSR            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Grain             ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  MICKEY            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Trivium           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  LFSR              ||   Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Shrinking generator||  Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Self-Shrinking generator||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||   Py(C)          ||  C            ||            ||     C     ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||   Py(C)          || C (SHA-1 &amp;amp; 256)||            ||    C (only SHA1)  ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||               ||               ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||               || Py          ||            || C (ripemd-160) ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   MDC-2               ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Davies-Meyer        ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Matyas-Meyer-Oseas  ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Miyaguchi-Preneel   ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          ||            ||   C***    || Py          ||&lt;br /&gt;
|-&lt;br /&gt;
|   NMAC                ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   KDF family          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||               ||               ||            ||    C***  ||          ||[http://www.dlitz.net/software/python-pbkdf2/]&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
===Public-key cryptography===&lt;br /&gt;
|-&lt;br /&gt;
|   Misc                ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====ECC====&lt;br /&gt;
|-&lt;br /&gt;
|  all coordinate sys.     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|cf [http://www.hyperelliptic.org/EFD/ EFD] ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Other====&lt;br /&gt;
|-&lt;br /&gt;
|  RSA                        ||               ||    C**     ||            ||    C (PKCS1)      || Py          ||[http://pypi.python.org/pypi/asym/0.1.0] [http://www.stuvel.eu/rsa]&lt;br /&gt;
|-&lt;br /&gt;
|  DSA                        ||               ||   C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  ElGamal                    ||               ||    C     ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  DH                         ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  XTR                        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Paillier                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  NTRUE                      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Pseudo-random generators===&lt;br /&gt;
|-&lt;br /&gt;
|    cf NIST                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|    Mersenne Twister          ||   Py          ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Cryptanalysis tools===&lt;br /&gt;
|- &lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Entropy finder: [http://deadhacker.com/2007/05/13/finding-entropy-in-binary-files/] and [http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html] then [http://blog.dkbza.org/2007/07/scanning-data-for-entropy-anomalies-ii.html]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
/**Check if PKCS#1 v1.5/v2.1 and if CTR&amp;lt;br&amp;gt;&lt;br /&gt;
/***See EVP.py&amp;lt;br&amp;gt;&lt;br /&gt;
book*: C-code available in Oreilly&#039;s OpenSSL book&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5153</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5153"/>
		<updated>2008-10-15T14:45:40Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Hash Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
=== Current Situation ===&lt;br /&gt;
*MD5&lt;br /&gt;
**good implementation in [http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy]&lt;br /&gt;
*SHA family&lt;br /&gt;
**SHA-1 available in [http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy]&lt;br /&gt;
***can it be modified for other SHA&#039;s?&lt;br /&gt;
*Whirlpool&lt;br /&gt;
**available at [python truecrypt implementation http://www.bjrn.se/code/whirlpoolpy.txt]&lt;br /&gt;
*RipeMD&lt;br /&gt;
**available as pure python implementation in current pycrypto development&amp;lt;br&amp;gt;=&amp;gt;RipeMD and python_RipeMD will point to the same pycrypto ripemd implementation&lt;br /&gt;
*RadioGatun&lt;br /&gt;
**http://radiogatun.noekeon.org/&lt;br /&gt;
***reference C-code&lt;br /&gt;
***testvectors&lt;br /&gt;
*HMAC&lt;br /&gt;
**available in python and pypy as pure python -&amp;gt; same implementation used in pycrypto&lt;br /&gt;
*PBKDF2&lt;br /&gt;
**implementation from new pycrypto developer: http://www.dlitz.net/software/python-pbkdf2/&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5152</id>
		<title>Sage Cross Reference Table of Wishes and Availability</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5152"/>
		<updated>2008-10-15T14:35:32Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* One-way Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
==Table==&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
* C: wrapped C code&lt;br /&gt;
* Py: pure python code&lt;br /&gt;
* Sage: sage code&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!Sage&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|optional packages&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|other python packages&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot;|python code&amp;lt;br&amp;gt;available&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
!PyCrypto&lt;br /&gt;
!PyOpenSSL&lt;br /&gt;
!M2Crypto&lt;br /&gt;
!TLS Lite&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Block Ciphers===&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Block cipher algorithms====&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/][http://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||               ||  C     ||     C      ||           ||          ||[http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/blowfish.py] [http://www.michaelgilfix.com/files/blowfish.py] [http://ivoras.sharanet.org/projects/blowfish.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      ||            ||     C     ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||               ||  C      ||            ||     C     || Py       ||[http://psionicist.online.fr/code/] [http://jclement.ca/software/pyrijndael/][http://bitconjurer.org/rijndael.py tlslite implementation]&lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Modes of operation====&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||               ||  C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||               ||  C      ||            ||    C      || Py       ||&lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||               ||  C      ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/pytruecrypt/]&lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Paddings====&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Stream Ciphers===&lt;br /&gt;
|-&lt;br /&gt;
|   RC4              ||               ||   C     ||            ||    C      || Py          ||[http://www.amk.ca/python/writing/crypto-curiosa.html]&lt;br /&gt;
|-&lt;br /&gt;
|   A5/1 A5/2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SNOW2 SNOW3G     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HC-128           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RABBIT           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Salsa 20/12      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SOSEMANUK        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  F-FCSR            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Grain             ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  MICKEY            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Trivium           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  LFSR              ||   Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Shrinking generator||  Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Self-Shrinking generator||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||   Py          ||  C            ||            ||     C     ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||   Py          || C (SHA-1 &amp;amp; 256)||            ||    C (only SHA1)  ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||               ||               ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||               || Py          ||            || C (ripemd-160) ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   MDC-2               ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Davies-Meyer        ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Matyas-Meyer-Oseas  ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Miyaguchi-Preneel   ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||   Py          ||            ||   C***    || Py          ||&lt;br /&gt;
|-&lt;br /&gt;
|   NMAC                ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   KDF family          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||               ||               ||            ||    C***  ||          ||[http://code.google.com/p/uliweb/source/browse/trunk/lib/beaker/crypto/pbkdf2.py?r=119]&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
===Public-key cryptography===&lt;br /&gt;
|-&lt;br /&gt;
|   Misc                ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====ECC====&lt;br /&gt;
|-&lt;br /&gt;
|  all coordinate sys.     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|cf [http://www.hyperelliptic.org/EFD/ EFD] ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Other====&lt;br /&gt;
|-&lt;br /&gt;
|  RSA                        ||               ||    C**     ||            ||    C (PKCS1)      || Py          ||[http://pypi.python.org/pypi/asym/0.1.0] [http://www.stuvel.eu/rsa]&lt;br /&gt;
|-&lt;br /&gt;
|  DSA                        ||               ||   C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  ElGamal                    ||               ||    C     ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  DH                         ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  XTR                        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Paillier                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  NTRUE                      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Pseudo-random generators===&lt;br /&gt;
|-&lt;br /&gt;
|    cf NIST                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|    Mersenne Twister          ||   Py          ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Cryptanalysis tools===&lt;br /&gt;
|- &lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Entropy finder: [http://deadhacker.com/2007/05/13/finding-entropy-in-binary-files/] and [http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html] then [http://blog.dkbza.org/2007/07/scanning-data-for-entropy-anomalies-ii.html]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
/**Check if PKCS#1 v1.5/v2.1 and if CTR&amp;lt;br&amp;gt;&lt;br /&gt;
/***See EVP.py&amp;lt;br&amp;gt;&lt;br /&gt;
book*: C-code available in Oreilly&#039;s OpenSSL book&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5151</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5151"/>
		<updated>2008-10-15T13:52:18Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: restructered: various info splitted in &amp;quot;cipher module&amp;quot; and &amp;quot;various info&amp;quot; &amp;amp; &amp;quot;hash module&amp;quot; section added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
==Cipher module==&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;br /&gt;
&lt;br /&gt;
== Hash Module ==&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5150</id>
		<title>Sage Cross Reference Table of Wishes and Availability</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5150"/>
		<updated>2008-10-15T13:40:40Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* One-way Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
==Table==&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
* C: wrapped C code&lt;br /&gt;
* Py: pure python code&lt;br /&gt;
* Sage: sage code&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!Sage&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|optional packages&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|other python packages&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot;|python code&amp;lt;br&amp;gt;available&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
!PyCrypto&lt;br /&gt;
!PyOpenSSL&lt;br /&gt;
!M2Crypto&lt;br /&gt;
!TLS Lite&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Block Ciphers===&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Block cipher algorithms====&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/][http://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||               ||  C     ||     C      ||           ||          ||[http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/blowfish.py] [http://www.michaelgilfix.com/files/blowfish.py] [http://ivoras.sharanet.org/projects/blowfish.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      ||            ||     C     ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||               ||  C      ||            ||     C     || Py       ||[http://psionicist.online.fr/code/] [http://jclement.ca/software/pyrijndael/][http://bitconjurer.org/rijndael.py tlslite implementation]&lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Modes of operation====&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||               ||  C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||               ||  C      ||            ||    C      || Py       ||&lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||               ||  C      ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/pytruecrypt/]&lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Paddings====&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Stream Ciphers===&lt;br /&gt;
|-&lt;br /&gt;
|   RC4              ||               ||   C     ||            ||    C      || Py          ||[http://www.amk.ca/python/writing/crypto-curiosa.html]&lt;br /&gt;
|-&lt;br /&gt;
|   A5/1 A5/2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SNOW2 SNOW3G     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HC-128           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RABBIT           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Salsa 20/12      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SOSEMANUK        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  F-FCSR            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Grain             ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  MICKEY            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Trivium           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  LFSR              ||   Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Shrinking generator||  Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Self-Shrinking generator||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||   Py          ||  C            ||            ||     C     ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||   Py          || C (SHA-1 &amp;amp; 256)||            ||    C (only SHA1)  ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py pypy]&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||               ||               ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||               || Py          ||            || C (ripemd-160) ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   MDC-2               ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Davies-Meyer        ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Matyas-Meyer-Oseas  ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Miyaguchi-Preneel   ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||               ||            ||   C***    || Py          ||&lt;br /&gt;
|-&lt;br /&gt;
|   NMAC                ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   KDF family          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||               ||               ||            ||    C***  ||          ||[http://code.google.com/p/uliweb/source/browse/trunk/lib/beaker/crypto/pbkdf2.py?r=119]&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
===Public-key cryptography===&lt;br /&gt;
|-&lt;br /&gt;
|   Misc                ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====ECC====&lt;br /&gt;
|-&lt;br /&gt;
|  all coordinate sys.     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|cf [http://www.hyperelliptic.org/EFD/ EFD] ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Other====&lt;br /&gt;
|-&lt;br /&gt;
|  RSA                        ||               ||    C**     ||            ||    C (PKCS1)      || Py          ||[http://pypi.python.org/pypi/asym/0.1.0] [http://www.stuvel.eu/rsa]&lt;br /&gt;
|-&lt;br /&gt;
|  DSA                        ||               ||   C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  ElGamal                    ||               ||    C     ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  DH                         ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  XTR                        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Paillier                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  NTRUE                      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Pseudo-random generators===&lt;br /&gt;
|-&lt;br /&gt;
|    cf NIST                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|    Mersenne Twister          ||   Py          ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Cryptanalysis tools===&lt;br /&gt;
|- &lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Entropy finder: [http://deadhacker.com/2007/05/13/finding-entropy-in-binary-files/] and [http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html] then [http://blog.dkbza.org/2007/07/scanning-data-for-entropy-anomalies-ii.html]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
/**Check if PKCS#1 v1.5/v2.1 and if CTR&amp;lt;br&amp;gt;&lt;br /&gt;
/***See EVP.py&amp;lt;br&amp;gt;&lt;br /&gt;
book*: C-code available in Oreilly&#039;s OpenSSL book&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5149</id>
		<title>Sage Cross Reference Table of Wishes and Availability</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Sage_Cross_Reference_Table_of_Wishes_and_Availability&amp;diff=5149"/>
		<updated>2008-10-15T13:39:14Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: added headings to the cross reference table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
==Table==&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
* C: wrapped C code&lt;br /&gt;
* Py: pure python code&lt;br /&gt;
* Sage: sage code&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!Sage&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|optional packages&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;|other python packages&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot;|python code&amp;lt;br&amp;gt;available&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
!&lt;br /&gt;
!PyCrypto&lt;br /&gt;
!PyOpenSSL&lt;br /&gt;
!M2Crypto&lt;br /&gt;
!TLS Lite&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Block Ciphers===&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Block cipher algorithms====&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/][http://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||               ||  C     ||     C      ||           ||          ||[http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/blowfish.py] [http://www.michaelgilfix.com/files/blowfish.py] [http://ivoras.sharanet.org/projects/blowfish.html]&lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      ||            ||     C     ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||               ||  C      ||            ||     C     ||          ||[http://twhiteman.netfirms.com/des.html]&lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||               ||  C      ||            ||     C     || Py       ||[http://psionicist.online.fr/code/] [http://jclement.ca/software/pyrijndael/][http://bitconjurer.org/rijndael.py tlslite implementation]&lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Modes of operation====&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         ||            ||    book*  ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||               ||  C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||               ||  C      ||            ||    C      || Py       ||&lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||               ||  C      ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||               ||         ||            ||           ||          ||[http://psionicist.online.fr/code/pytruecrypt/]&lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Paddings====&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Stream Ciphers===&lt;br /&gt;
|-&lt;br /&gt;
|   RC4              ||               ||   C     ||            ||    C      || Py          ||[http://www.amk.ca/python/writing/crypto-curiosa.html]&lt;br /&gt;
|-&lt;br /&gt;
|   A5/1 A5/2        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SNOW2 SNOW3G     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HC-128           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RABBIT           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Salsa 20/12      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   SOSEMANUK        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  F-FCSR            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Grain             ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  MICKEY            ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Trivium           ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  LFSR              ||   Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Shrinking generator||  Sage        ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Self-Shrinking generator||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===One-way Functions===&lt;br /&gt;
|-&lt;br /&gt;
|   MD5                 ||   Py          ||  C            ||            ||     C     ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/md5.py]&lt;br /&gt;
|-&lt;br /&gt;
|   SHA Family          ||   Py          || C (SHA-1 &amp;amp; 256)||            ||    C (only SHA1)  ||          ||[http://codespeak.net/svn/pypy/dist/pypy/lib/sha.py]&lt;br /&gt;
|-&lt;br /&gt;
|   Whirlpool           ||               ||               ||            ||           ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   RipeMD              ||               || C          ||            || C (ripemd-160) ||          ||[http://psionicist.online.fr/code/]&lt;br /&gt;
|-&lt;br /&gt;
|   MDC-2               ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   RadioGatun          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Davies-Meyer        ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Matyas-Meyer-Oseas  ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   Miyaguchi-Preneel   ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   HMAC                ||   Py          ||               ||            ||   C***    || Py          ||&lt;br /&gt;
|-&lt;br /&gt;
|   NMAC                ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   KDF family          ||               ||               ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|   PBKDF2              ||               ||               ||            ||    C***  ||          ||[http://code.google.com/p/uliweb/source/browse/trunk/lib/beaker/crypto/pbkdf2.py?r=119]&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Public-key cryptography===&lt;br /&gt;
|-&lt;br /&gt;
|   Misc                ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====ECC====&lt;br /&gt;
|-&lt;br /&gt;
|  all coordinate sys.     ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|cf [http://www.hyperelliptic.org/EFD/ EFD] ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
====Other====&lt;br /&gt;
|-&lt;br /&gt;
|  RSA                        ||               ||    C**     ||            ||    C (PKCS1)      || Py          ||[http://pypi.python.org/pypi/asym/0.1.0] [http://www.stuvel.eu/rsa]&lt;br /&gt;
|-&lt;br /&gt;
|  DSA                        ||               ||   C      ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  ElGamal                    ||               ||    C     ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  DH                         ||               ||         ||            ||    C      ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  XTR                        ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  Paillier                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|  NTRUE                      ||               ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Pseudo-random generators===&lt;br /&gt;
|-&lt;br /&gt;
|    cf NIST                   ||               ||         ||            ||           ||          ||&lt;br /&gt;
|-&lt;br /&gt;
|    Mersenne Twister          ||   Py          ||         ||            ||           ||          ||&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|&lt;br /&gt;
===Cryptanalysis tools===&lt;br /&gt;
|- &lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Entropy finder: [http://deadhacker.com/2007/05/13/finding-entropy-in-binary-files/] and [http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html] then [http://blog.dkbza.org/2007/07/scanning-data-for-entropy-anomalies-ii.html]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
/**Check if PKCS#1 v1.5/v2.1 and if CTR&amp;lt;br&amp;gt;&lt;br /&gt;
/***See EVP.py&amp;lt;br&amp;gt;&lt;br /&gt;
book*: C-code available in Oreilly&#039;s OpenSSL book&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5147</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5147"/>
		<updated>2008-10-14T20:20:33Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */ removed &amp;quot;verified&amp;quot; testvector status as in all doctest the source of testvectors is mentioned now&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5146</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5146"/>
		<updated>2008-10-14T20:01:55Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* TODO */  cleaned up todo list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5145</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5145"/>
		<updated>2008-10-14T19:49:45Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Tests available */  Not needed anymore -&amp;gt; available in the source structure table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5144</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5144"/>
		<updated>2008-10-14T19:48:34Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package:&lt;br /&gt;
*always: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
*if pycrypto &amp;gt; 2.0.1: &amp;quot;SelfTest&amp;quot;, &amp;quot;Random&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Random subpackage (only used if pycrypto version &amp;gt; 2.0.1)&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Random: _UserFriendlyRNG, atfork, random&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/Fortuna.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.Fortuna.*&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/OSRNG.py&lt;br /&gt;
|&lt;br /&gt;
*imports Crypto.Random.OSRNG.*&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751, python_compat&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/number.py&amp;lt;br&amp;gt;src/Util/randpool.py&amp;lt;br&amp;gt;src/Util/RFC1751.py&lt;br /&gt;
|&lt;br /&gt;
*wrappers for the respective Crypto.Util modules&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/python_compat.py&lt;br /&gt;
|&lt;br /&gt;
*wrapper for Crypto.Util.python_compat if pycrypto &amp;gt; 2.0.1&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*doctest for every padding function&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Git&amp;diff=5130</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Git&amp;diff=5130"/>
		<updated>2008-10-13T17:21:11Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Git_(software) Git on Wikipedia]&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/user-manual.html Git User Manual]&lt;br /&gt;
* [http://git.or.cz/course/svn.html Git - SVN Crash Course] Explaining Git by using SVN equivalences&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html man gittutorial]&lt;br /&gt;
* [http://www-cs-students.stanford.edu/~blynn/gitmagic/ Git Magic] tips compilation &lt;br /&gt;
* [http://sysmonblog.co.uk/misc/git_by_example/ Git by example]&lt;br /&gt;
* [http://utsl.gen.nz/talks/git-svn/intro.html An introduction to git-svn for Subversion/SVK users and deserters]&lt;br /&gt;
* [http://git.or.cz/gitwiki/InterfacesFrontendsAndTools Interfaces, frontends &amp;amp; tools]&lt;br /&gt;
* [http://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg Git Cheat Sheet (svg)]&lt;br /&gt;
* [http://jan-krueger.net/development/git-cheat-sheet-extended-edition Git cheat sheet, extended edition] which I prefer&lt;br /&gt;
&lt;br /&gt;
==Install==&lt;br /&gt;
 sudo apt-get install git-svn git-doc git-gui tig&lt;br /&gt;
Writing to global ~/.gitconfig file:&lt;br /&gt;
 git config --global user.name &amp;quot;Your Name Comes Here&amp;quot;&lt;br /&gt;
 git config --global user.email you@yourdomain.example.com&lt;br /&gt;
 git config --global color.diff auto&lt;br /&gt;
 git config --global color.status auto&lt;br /&gt;
 git config --global color.branch auto&lt;br /&gt;
Creating a .git in the current (project) directory:&lt;br /&gt;
 git init&lt;br /&gt;
==Working on a project==&lt;br /&gt;
===Initial project===&lt;br /&gt;
Add manually files/directories e.g. with&lt;br /&gt;
 git init&lt;br /&gt;
 git add .&lt;br /&gt;
 git commit&lt;br /&gt;
&lt;br /&gt;
===Copying existing project===&lt;br /&gt;
Clone an existing Git repository into a to-be-created target directory:&lt;br /&gt;
 git clone /path/to/other/repository target&lt;br /&gt;
Remote repositories can also be accessed with paths like&lt;br /&gt;
 ssh://login@host/path/to/repository&lt;br /&gt;
 git://git.software.org/trunk&lt;br /&gt;
 http://git.software.org/trunk&lt;br /&gt;
Later to update the local repository according to the remote repository:&lt;br /&gt;
 git pull&lt;br /&gt;
Symmetrically the remote repository owner could also get the changes we&#039;ve done locally if she does:&lt;br /&gt;
 git pull /path/to/our/target&lt;br /&gt;
Or we could send them ourselves if we&#039;ve write access on the remote:&lt;br /&gt;
 git push&lt;br /&gt;
BTW the remote can create a shortcut to us to not have to provide our full path everytime&lt;br /&gt;
 git remote add ourshortcut /path/to/our/target&lt;br /&gt;
And now use directly&lt;br /&gt;
 git remote show ourshortcut&lt;br /&gt;
 git pull ourshortcut&lt;br /&gt;
Note that git pull ourshortcut ==&lt;br /&gt;
 git fetch ourshortcut&lt;br /&gt;
 git merge ourshortcut/master&lt;br /&gt;
===Using a Subversion server===&lt;br /&gt;
Using [http://www.kernel.org/pub/software/scm/git/docs/git-svn.html git-svn]:&lt;br /&gt;
&lt;br /&gt;
Getting the full project:&lt;br /&gt;
 # git clone =&amp;gt;&lt;br /&gt;
 git-svn clone http://subversion.server.com/project -T trunk -b branches -t tags&lt;br /&gt;
 (git-gc to compress if it took a big room)&lt;br /&gt;
Updating the local repository according to the subversion server:&lt;br /&gt;
 # git pull =&amp;gt;&lt;br /&gt;
 git-svn rebase&lt;br /&gt;
Some tips from [http://tech.hickorywind.org/articles/2008/06/10/larry-vs-the-git-rebase-merge-conflict here]:&lt;br /&gt;
* While doing a rebase, if anything bad happens, you end up on a &amp;quot;(no-branch)&amp;quot; branch.&lt;br /&gt;
* When doing a &amp;quot;git status&amp;quot;, you&#039;ll see a &amp;quot;.dotest&amp;quot; file in your working directory. Just ignore it.&lt;br /&gt;
* If you want to bail, do a &amp;quot;git rebase --abort&amp;quot;. (Note there is no &amp;quot;git svn rebase --abort&amp;quot;.)&lt;br /&gt;
* Fix the merge conflict file manually, then do a &amp;quot;git add [file]&amp;quot;.&lt;br /&gt;
* Next do a &amp;quot;git rebase --continue&amp;quot;. (Note there&#039;s no &amp;quot;svn&amp;quot; version of this either.)&lt;br /&gt;
* If it complains about &amp;quot;did you forget to call &#039;git add&#039;?&amp;quot;, then evidently your edit turned the conflict into a no-op change. Do a &amp;quot;git rebase --skip&amp;quot; to skip it. (Very weird, but true.)&lt;br /&gt;
* Rinse and repeat until the lather is gone, your scalp silky smooth, and the rebase is complete. At any time you can &amp;quot;git rebase --abort&amp;quot; to bail.&lt;br /&gt;
&lt;br /&gt;
Sending the local changes to the subversion server:&lt;br /&gt;
 # git push =&amp;gt;&lt;br /&gt;
 git-svn dcommit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By error I did&lt;br /&gt;
 git commit --amend&lt;br /&gt;
on a synchronized git repository, so I lost remotes/trunk in the gitk view but the remote branch is still visible with git branch -r, strange...&lt;br /&gt;
 $ git-svn rebase&lt;br /&gt;
 First, rewinding head to replay your work on top of it...&lt;br /&gt;
 Nothing to do.&lt;br /&gt;
solved the problem&lt;br /&gt;
&lt;br /&gt;
One day you&#039;ll be bored of SVN and want to get rid of it completely :-)&lt;br /&gt;
&lt;br /&gt;
Create a new git repository remotely somewhere else (see above), which will become the origin we didn&#039;t have.&lt;br /&gt;
&lt;br /&gt;
 git remote add origin ssh://myuser@repo.or.cz/srv/git/myproject.git&lt;br /&gt;
 git pull origin master&lt;br /&gt;
 git push&lt;br /&gt;
Now it&#039;s better to make sure git-svn cannot interfere with it anymore:&lt;br /&gt;
&amp;lt;br&amp;gt;Fetch the project in a new place&lt;br /&gt;
 git clone ssh://myuser@repo.or.cz/srv/git/myproject.git&lt;br /&gt;
 git pull&lt;br /&gt;
And drop your old git-svn working directory&lt;br /&gt;
&lt;br /&gt;
=== Using repo.or.cz ===&lt;br /&gt;
http://repo.or.cz/ can be used to make a publicly available git repo.&lt;br /&gt;
# Create a new user: http://repo.or.cz/m/reguser.cgi When creating a user you need a public ssh key to authenticate yourself.&lt;br /&gt;
# Create a new repo: http://repo.or.cz/m/regproj.cgi&lt;br /&gt;
#* two different modes are available for a new repo:&lt;br /&gt;
#** mirror mode: the new repo will mirror an existing repo by checking it every hour for changes&lt;br /&gt;
#** push mode: users you give permission to can push to the repo&lt;br /&gt;
#* all the info asked when you register your repo can be changed afterwards on the project admin page&lt;br /&gt;
#**http://repo.or.cz/m/editproj.cgi?name=&amp;lt;project name&amp;gt;&lt;br /&gt;
# Add yourself and other users you want to give &amp;quot;push&amp;quot; access to the admin page&lt;br /&gt;
# Git repo is accesible via&lt;br /&gt;
#* git+ssh://&amp;lt;user&amp;gt;@repo.or.cz/srv/git/&amp;lt;project name&amp;gt;.git&lt;br /&gt;
&lt;br /&gt;
==Basic usage==&lt;br /&gt;
===Edition===&lt;br /&gt;
Schedule a file for committing&lt;br /&gt;
 git add &amp;lt;file&amp;gt;&lt;br /&gt;
Committing&lt;br /&gt;
 git commit&lt;br /&gt;
Note that a modified file must be explicitly added every time, unless you use&lt;br /&gt;
 git commit -a&lt;br /&gt;
Or&lt;br /&gt;
 git commit &amp;lt;file&amp;gt;&lt;br /&gt;
File renaming is implicit, so you don&#039;t have to take care, just rename your files if you want (really??), but there is also the explicit commands&lt;br /&gt;
 git mv &amp;lt;file&amp;gt;&lt;br /&gt;
 git rm &amp;lt;file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Diff/patch===&lt;br /&gt;
Diff between working files &amp;amp; to-be-committed index&lt;br /&gt;
 git diff&lt;br /&gt;
Diff between to-be-committed index &amp;amp; repository&lt;br /&gt;
 git diff --cached&lt;br /&gt;
Diff between working files &amp;amp; repository&lt;br /&gt;
 git diff HEAD&lt;br /&gt;
With specific revision or path&lt;br /&gt;
 git diff &amp;lt;rev&amp;gt; &amp;lt;path&amp;gt;&lt;br /&gt;
E.g with one but last commit&lt;br /&gt;
 git diff HEAD~1&lt;br /&gt;
This provides usage patches, including metadata, can be applied with&lt;br /&gt;
 git apply&lt;br /&gt;
&lt;br /&gt;
===Status &amp;amp; revert===&lt;br /&gt;
Status of local working files&lt;br /&gt;
 git status&lt;br /&gt;
To restore (revert) a file from the last revision&lt;br /&gt;
 git checkout &amp;lt;path&amp;gt;&lt;br /&gt;
Revert all changes (!)&lt;br /&gt;
 git checkout -f&lt;br /&gt;
You can amend your latest commit (re-edit the metadata as well as update the tree) using this (it is only safe to amend the commit messages that have not been seen by anyone else, aka, you&#039;ve not pushed, nobody else has pulled from you).&lt;br /&gt;
 git commit --amend&lt;br /&gt;
Or toss your latest commit away completely using &lt;br /&gt;
 git reset HEAD^&lt;br /&gt;
This will not change the working tree.&lt;br /&gt;
&lt;br /&gt;
To unstage a change to-be-committed (e.g. git add *)&lt;br /&gt;
 git reset HEAD &amp;lt;file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===History===&lt;br /&gt;
 git log&lt;br /&gt;
With nice stats:&lt;br /&gt;
 git log --stat --summary&lt;br /&gt;
See from which revision came the lines of a file&lt;br /&gt;
 git blame &amp;lt;file&amp;gt;&lt;br /&gt;
Or search for commits affecting a specific line&lt;br /&gt;
 git log -S&amp;quot;string&amp;quot;&lt;br /&gt;
You can see the contents of a file&lt;br /&gt;
 git show rev:path/to/file&lt;br /&gt;
The listing of a directory&lt;br /&gt;
 git show rev:path/to/directory&lt;br /&gt;
Or a commit with:&lt;br /&gt;
 git show rev&lt;br /&gt;
&lt;br /&gt;
===Tags &amp;amp; branches===&lt;br /&gt;
Create a tag:&lt;br /&gt;
 git tag -a &amp;lt;name&amp;gt;&lt;br /&gt;
List tags and show the tag message:&lt;br /&gt;
 git tag -l&lt;br /&gt;
 git show &amp;lt;tag&amp;gt;&lt;br /&gt;
Create a branch:&lt;br /&gt;
 git branch &amp;lt;branch&amp;gt; [&amp;lt;rev&amp;gt;]&lt;br /&gt;
Switch to the branch&lt;br /&gt;
 git checkout &amp;lt;branch&amp;gt;&lt;br /&gt;
List branches (current is flagged by a *)&lt;br /&gt;
 git branch&lt;br /&gt;
To move your tree to some older revision, use:&lt;br /&gt;
 git checkout &amp;lt;rev&amp;gt;&lt;br /&gt;
 git checkout &amp;lt;prevbranch&amp;gt;&lt;br /&gt;
Default branch is &amp;quot;master&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Merge===&lt;br /&gt;
Assuming you are in the trunk and want to merge a given branch here:&lt;br /&gt;
 git merge branch&lt;br /&gt;
If the merge went nice automatically, a commit is done automatically too, to avoid it:&lt;br /&gt;
 git merge --no-commit branch&lt;br /&gt;
Aside from merging, sometimes you want to just pick one commit from a different branch. To apply the changes in revision rev and commit them to the current branch use:&lt;br /&gt;
 git cherry-pick rev&lt;br /&gt;
===Rebase===&lt;br /&gt;
Not yet clear what&#039;s the diff with merge...&lt;br /&gt;
&lt;br /&gt;
* Find all your (committed) changes, since you branched&lt;br /&gt;
* Reset your branch, so that it&#039;s an exact copy of the current master&lt;br /&gt;
* Re-apply all your changes again&lt;br /&gt;
 git checkout branch_name&lt;br /&gt;
 git rebase master&lt;br /&gt;
If conflicts occur, and sooner or later they will,&lt;br /&gt;
 # manually edit the conflicting files&lt;br /&gt;
 git add file(s)&lt;br /&gt;
 git rebase --continue&lt;br /&gt;
See also &amp;quot;git-mergetool&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Rework commit history===&lt;br /&gt;
&lt;br /&gt;
You want:&lt;br /&gt;
* Two different commits to be combined into a single commit&lt;br /&gt;
* Remove a commit entirely from the history&lt;br /&gt;
* Change the commit message&lt;br /&gt;
* Change the order that commits appear in the history&lt;br /&gt;
* Split one big commit into multiple smaller commits&lt;br /&gt;
&lt;br /&gt;
 git rebase --interactive COMMIT_ID&lt;br /&gt;
&lt;br /&gt;
COMMIT_ID should be the one BEFORE you want to fiddle with.&lt;br /&gt;
&lt;br /&gt;
To learn about splitting a single commit up into multiple commits:&lt;br /&gt;
 man git-rebase&lt;br /&gt;
 # see &amp;quot;SPLITTING COMMITS&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
===Ignoring some files===&lt;br /&gt;
 cat &amp;gt; .gitignore &amp;lt;&amp;lt;EOF&lt;br /&gt;
 *.pyc&lt;br /&gt;
 *~&lt;br /&gt;
 EOF&lt;br /&gt;
 git add .gitignore&lt;br /&gt;
Now you can also delete all files neither tracked nor ignored with:&lt;br /&gt;
 git clean&lt;br /&gt;
&lt;br /&gt;
==Misc==&lt;br /&gt;
* Revisions are SHA-1 hashes, not incremental numbers.&amp;lt;br&amp;gt;You can refer to the latest revision by HEAD, its parent as HEAD^ and its parent as HEAD^^ = HEAD~2&amp;lt;br&amp;gt;You can also just type the first digits of the hash (if it&#039;s enough to get a unique ID)&amp;lt;br&amp;gt;man git-rev-parse for more details&lt;br /&gt;
* The Git commands are in the form git command. You can interchangeably use the git-command form as well.&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#setting-up-a-public-repository Setting up a public repository] where you&#039;ll push your stuff&lt;br /&gt;
** git --bare init --shared ??&lt;br /&gt;
* Though not required, it&#039;s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description.&lt;br /&gt;
&lt;br /&gt;
==etckeeper==&lt;br /&gt;
Description: store /etc in git, mercurial, or bzr&lt;br /&gt;
&amp;lt;br&amp;gt;The etckeeper program is a tool to let /etc be stored in a git, mercurial, or bzr repository. It hooks into APT to automatically commit changes made to /etc during package upgrades. It tracks file metadata that version control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. &amp;lt;br&amp;gt;It&#039;s quite modular and configurable, while also being simple to use if you understand the basics of working with version control.&lt;br /&gt;
 apt-get install etckeeper&lt;br /&gt;
Read this!!!&lt;br /&gt;
 zless /usr/share/doc/etckeeper/README.gz&lt;br /&gt;
&lt;br /&gt;
Crash course:&lt;br /&gt;
 etckeeper init&lt;br /&gt;
 cd /etc&lt;br /&gt;
 git commit -m &amp;quot;initial checkin&amp;quot;&lt;br /&gt;
 git gc&lt;br /&gt;
For the rest, read /usr/share/doc/etckeeper/README.gz&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Git&amp;diff=5126</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Git&amp;diff=5126"/>
		<updated>2008-10-13T16:59:40Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Basic usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Git_(software) Git on Wikipedia]&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/user-manual.html Git User Manual]&lt;br /&gt;
* [http://git.or.cz/course/svn.html Git - SVN Crash Course] Explaining Git by using SVN equivalences&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html man gittutorial]&lt;br /&gt;
* [http://www-cs-students.stanford.edu/~blynn/gitmagic/ Git Magic] tips compilation &lt;br /&gt;
* [http://sysmonblog.co.uk/misc/git_by_example/ Git by example]&lt;br /&gt;
* [http://utsl.gen.nz/talks/git-svn/intro.html An introduction to git-svn for Subversion/SVK users and deserters]&lt;br /&gt;
* [http://git.or.cz/gitwiki/InterfacesFrontendsAndTools Interfaces, frontends &amp;amp; tools]&lt;br /&gt;
* [http://ktown.kde.org/~zrusin/git/git-cheat-sheet.svg Git Cheat Sheet (svg)]&lt;br /&gt;
* [http://jan-krueger.net/development/git-cheat-sheet-extended-edition Git cheat sheet, extended edition] which I prefer&lt;br /&gt;
&lt;br /&gt;
==Install==&lt;br /&gt;
 sudo apt-get install git-svn git-doc git-gui tig&lt;br /&gt;
Writing to global ~/.gitconfig file:&lt;br /&gt;
 git config --global user.name &amp;quot;Your Name Comes Here&amp;quot;&lt;br /&gt;
 git config --global user.email you@yourdomain.example.com&lt;br /&gt;
 git config --global color.diff auto&lt;br /&gt;
 git config --global color.status auto&lt;br /&gt;
 git config --global color.branch auto&lt;br /&gt;
Creating a .git in the current (project) directory:&lt;br /&gt;
 git init&lt;br /&gt;
==Working on a project==&lt;br /&gt;
===Initial project===&lt;br /&gt;
Add manually files/directories e.g. with&lt;br /&gt;
 git init&lt;br /&gt;
 git add .&lt;br /&gt;
 git commit&lt;br /&gt;
&lt;br /&gt;
===Copying existing project===&lt;br /&gt;
Clone an existing Git repository into a to-be-created target directory:&lt;br /&gt;
 git clone /path/to/other/repository target&lt;br /&gt;
Remote repositories can also be accessed with paths like&lt;br /&gt;
 ssh://login@host/path/to/repository&lt;br /&gt;
 git://git.software.org/trunk&lt;br /&gt;
 http://git.software.org/trunk&lt;br /&gt;
Later to update the local repository according to the remote repository:&lt;br /&gt;
 git pull&lt;br /&gt;
Symmetrically the remote repository owner could also get the changes we&#039;ve done locally if she does:&lt;br /&gt;
 git pull /path/to/our/target&lt;br /&gt;
Or we could send them ourselves if we&#039;ve write access on the remote:&lt;br /&gt;
 git push&lt;br /&gt;
BTW the remote can create a shortcut to us to not have to provide our full path everytime&lt;br /&gt;
 git remote add ourshortcut /path/to/our/target&lt;br /&gt;
And now use directly&lt;br /&gt;
 git remote show ourshortcut&lt;br /&gt;
 git pull ourshortcut&lt;br /&gt;
Note that git pull ourshortcut ==&lt;br /&gt;
 git fetch ourshortcut&lt;br /&gt;
 git merge ourshortcut/master&lt;br /&gt;
===Using a Subversion server===&lt;br /&gt;
Using [http://www.kernel.org/pub/software/scm/git/docs/git-svn.html git-svn]:&lt;br /&gt;
&lt;br /&gt;
Getting the full project:&lt;br /&gt;
 # git clone =&amp;gt;&lt;br /&gt;
 git-svn clone http://subversion.server.com/project -T trunk -b branches -t tags&lt;br /&gt;
 (git-gc to compress if it took a big room)&lt;br /&gt;
Updating the local repository according to the subversion server:&lt;br /&gt;
 # git pull =&amp;gt;&lt;br /&gt;
 git-svn rebase&lt;br /&gt;
Some tips from [http://tech.hickorywind.org/articles/2008/06/10/larry-vs-the-git-rebase-merge-conflict here]:&lt;br /&gt;
* While doing a rebase, if anything bad happens, you end up on a &amp;quot;(no-branch)&amp;quot; branch.&lt;br /&gt;
* When doing a &amp;quot;git status&amp;quot;, you&#039;ll see a &amp;quot;.dotest&amp;quot; file in your working directory. Just ignore it.&lt;br /&gt;
* If you want to bail, do a &amp;quot;git rebase --abort&amp;quot;. (Note there is no &amp;quot;git svn rebase --abort&amp;quot;.)&lt;br /&gt;
* Fix the merge conflict file manually, then do a &amp;quot;git add [file]&amp;quot;.&lt;br /&gt;
* Next do a &amp;quot;git rebase --continue&amp;quot;. (Note there&#039;s no &amp;quot;svn&amp;quot; version of this either.)&lt;br /&gt;
* If it complains about &amp;quot;did you forget to call &#039;git add&#039;?&amp;quot;, then evidently your edit turned the conflict into a no-op change. Do a &amp;quot;git rebase --skip&amp;quot; to skip it. (Very weird, but true.)&lt;br /&gt;
* Rinse and repeat until the lather is gone, your scalp silky smooth, and the rebase is complete. At any time you can &amp;quot;git rebase --abort&amp;quot; to bail.&lt;br /&gt;
&lt;br /&gt;
Sending the local changes to the subversion server:&lt;br /&gt;
 # git push =&amp;gt;&lt;br /&gt;
 git-svn dcommit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By error I did&lt;br /&gt;
 git commit --amend&lt;br /&gt;
on a synchronized git repository, so I lost remotes/trunk in the gitk view but the remote branch is still visible with git branch -r, strange...&lt;br /&gt;
 $ git-svn rebase&lt;br /&gt;
 First, rewinding head to replay your work on top of it...&lt;br /&gt;
 Nothing to do.&lt;br /&gt;
solved the problem&lt;br /&gt;
&lt;br /&gt;
One day you&#039;ll be bored of SVN and want to get rid of it completely :-)&lt;br /&gt;
&lt;br /&gt;
Create a new git repository remotely somewhere else (see above).&lt;br /&gt;
&lt;br /&gt;
 git remote add origin ssh://myuser@repo.or.cz/srv/git/myproject.git&lt;br /&gt;
 git push&lt;br /&gt;
Now it&#039;s better to make sure git-svn cannot interfere with it anymore:&lt;br /&gt;
&amp;lt;br&amp;gt;Fetch the project in a new place&lt;br /&gt;
 git clone ssh://myuser@repo.or.cz/srv/git/myproject.git&lt;br /&gt;
 git pull&lt;br /&gt;
And drop your old git-svn working directory&lt;br /&gt;
&lt;br /&gt;
==Basic usage==&lt;br /&gt;
===Edition===&lt;br /&gt;
Schedule a file for committing&lt;br /&gt;
 git add &amp;lt;file&amp;gt;&lt;br /&gt;
Committing&lt;br /&gt;
 git commit&lt;br /&gt;
Note that a modified file must be explicitly added every time, unless you use&lt;br /&gt;
 git commit -a&lt;br /&gt;
Or&lt;br /&gt;
 git commit &amp;lt;file&amp;gt;&lt;br /&gt;
File renaming is implicit, so you don&#039;t have to take care, just rename your files if you want (really??), but there is also the explicit commands&lt;br /&gt;
 git mv &amp;lt;file&amp;gt;&lt;br /&gt;
 git rm &amp;lt;file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Diff/patch===&lt;br /&gt;
Diff between working files &amp;amp; to-be-committed index&lt;br /&gt;
 git diff&lt;br /&gt;
Diff between to-be-committed index &amp;amp; repository&lt;br /&gt;
 git diff --cached&lt;br /&gt;
Diff between working files &amp;amp; repository&lt;br /&gt;
 git diff HEAD&lt;br /&gt;
With specific revision or path&lt;br /&gt;
 git diff &amp;lt;rev&amp;gt; &amp;lt;path&amp;gt;&lt;br /&gt;
E.g with one but last commit&lt;br /&gt;
 git diff HEAD~1&lt;br /&gt;
This provides usage patches, including metadata, can be applied with&lt;br /&gt;
 git apply&lt;br /&gt;
&lt;br /&gt;
===Status &amp;amp; revert===&lt;br /&gt;
Status of local working files&lt;br /&gt;
 git status&lt;br /&gt;
To restore (revert) a file from the last revision&lt;br /&gt;
 git checkout &amp;lt;path&amp;gt;&lt;br /&gt;
Revert all changes (!)&lt;br /&gt;
 git checkout -f&lt;br /&gt;
You can amend your latest commit (re-edit the metadata as well as update the tree) using this (it is only safe to amend the commit messages that have not been seen by anyone else, aka, you&#039;ve not pushed, nobody else has pulled from you).&lt;br /&gt;
 git commit --amend&lt;br /&gt;
Or toss your latest commit away completely using &lt;br /&gt;
 git reset HEAD^&lt;br /&gt;
This will not change the working tree.&lt;br /&gt;
&lt;br /&gt;
To unstage a change to-be-committed (e.g. git add *)&lt;br /&gt;
 git reset HEAD &amp;lt;file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===History===&lt;br /&gt;
 git log&lt;br /&gt;
With nice stats:&lt;br /&gt;
 git log --stat --summary&lt;br /&gt;
See from which revision came the lines of a file&lt;br /&gt;
 git blame &amp;lt;file&amp;gt;&lt;br /&gt;
Or search for commits affecting a specific line&lt;br /&gt;
 git log -S&amp;quot;string&amp;quot;&lt;br /&gt;
You can see the contents of a file&lt;br /&gt;
 git show rev:path/to/file&lt;br /&gt;
The listing of a directory&lt;br /&gt;
 git show rev:path/to/directory&lt;br /&gt;
Or a commit with:&lt;br /&gt;
 git show rev&lt;br /&gt;
&lt;br /&gt;
===Tags &amp;amp; branches===&lt;br /&gt;
Create a tag:&lt;br /&gt;
 git tag -a &amp;lt;name&amp;gt;&lt;br /&gt;
List tags and show the tag message:&lt;br /&gt;
 git tag -l&lt;br /&gt;
 git show &amp;lt;tag&amp;gt;&lt;br /&gt;
Create a branch:&lt;br /&gt;
 git branch &amp;lt;branch&amp;gt; [&amp;lt;rev&amp;gt;]&lt;br /&gt;
Switch to the branch&lt;br /&gt;
 git checkout &amp;lt;branch&amp;gt;&lt;br /&gt;
List branches (current is flagged by a *)&lt;br /&gt;
 git branch&lt;br /&gt;
To move your tree to some older revision, use:&lt;br /&gt;
 git checkout &amp;lt;rev&amp;gt;&lt;br /&gt;
 git checkout &amp;lt;prevbranch&amp;gt;&lt;br /&gt;
Default branch is &amp;quot;master&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Merge===&lt;br /&gt;
Assuming you are in the trunk and want to merge a given branch here:&lt;br /&gt;
 git merge branch&lt;br /&gt;
If the merge went nice automatically, a commit is done automatically too, to avoid it:&lt;br /&gt;
 git merge --no-commit branch&lt;br /&gt;
Aside from merging, sometimes you want to just pick one commit from a different branch. To apply the changes in revision rev and commit them to the current branch use:&lt;br /&gt;
 git cherry-pick rev&lt;br /&gt;
===Rebase===&lt;br /&gt;
Not yet clear what&#039;s the diff with merge...&lt;br /&gt;
&lt;br /&gt;
* Find all your (committed) changes, since you branched&lt;br /&gt;
* Reset your branch, so that it&#039;s an exact copy of the current master&lt;br /&gt;
* Re-apply all your changes again&lt;br /&gt;
 git checkout branch_name&lt;br /&gt;
 git rebase master&lt;br /&gt;
If conflicts occur, and sooner or later they will,&lt;br /&gt;
 # manually edit the conflicting files&lt;br /&gt;
 git add file(s)&lt;br /&gt;
 git rebase --continue&lt;br /&gt;
See also &amp;quot;git-mergetool&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== working with a remote repository ===&lt;br /&gt;
adding the default upstream repository&lt;br /&gt;
 git remote add origin &amp;lt;url&amp;gt;&lt;br /&gt;
fetching updates from the remote branch (origin)&lt;br /&gt;
 git fetch&lt;br /&gt;
merging origin with local working branch (master)&lt;br /&gt;
 git merge origin master&lt;br /&gt;
OR: fetch and merge in one go&lt;br /&gt;
 git pull&lt;br /&gt;
pushin changes to the default upstream repository (origin)&lt;br /&gt;
 git push&lt;br /&gt;
&lt;br /&gt;
===Rework commit history===&lt;br /&gt;
&lt;br /&gt;
You want:&lt;br /&gt;
* Two different commits to be combined into a single commit&lt;br /&gt;
* Remove a commit entirely from the history&lt;br /&gt;
* Change the commit message&lt;br /&gt;
* Change the order that commits appear in the history&lt;br /&gt;
* Split one big commit into multiple smaller commits&lt;br /&gt;
&lt;br /&gt;
 git rebase --interactive COMMIT_ID&lt;br /&gt;
&lt;br /&gt;
COMMIT_ID should be the one BEFORE you want to fiddle with.&lt;br /&gt;
&lt;br /&gt;
To learn about splitting a single commit up into multiple commits:&lt;br /&gt;
 man git-rebase&lt;br /&gt;
 # see &amp;quot;SPLITTING COMMITS&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
===Ignoring some files===&lt;br /&gt;
 cat &amp;gt; .gitignore &amp;lt;&amp;lt;EOF&lt;br /&gt;
 *.pyc&lt;br /&gt;
 *~&lt;br /&gt;
 EOF&lt;br /&gt;
 git add .gitignore&lt;br /&gt;
Now you can also delete all files neither tracked nor ignored with:&lt;br /&gt;
 git clean&lt;br /&gt;
&lt;br /&gt;
==Misc==&lt;br /&gt;
* Revisions are SHA-1 hashes, not incremental numbers.&amp;lt;br&amp;gt;You can refer to the latest revision by HEAD, its parent as HEAD^ and its parent as HEAD^^ = HEAD~2&amp;lt;br&amp;gt;You can also just type the first digits of the hash (if it&#039;s enough to get a unique ID)&amp;lt;br&amp;gt;man git-rev-parse for more details&lt;br /&gt;
* The Git commands are in the form git command. You can interchangeably use the git-command form as well.&lt;br /&gt;
* [http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#setting-up-a-public-repository Setting up a public repository] where you&#039;ll push your stuff&lt;br /&gt;
** git --bare init --shared ??&lt;br /&gt;
* Though not required, it&#039;s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description.&lt;br /&gt;
&lt;br /&gt;
==etckeeper==&lt;br /&gt;
Description: store /etc in git, mercurial, or bzr&lt;br /&gt;
&amp;lt;br&amp;gt;The etckeeper program is a tool to let /etc be stored in a git, mercurial, or bzr repository. It hooks into APT to automatically commit changes made to /etc during package upgrades. It tracks file metadata that version control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. &amp;lt;br&amp;gt;It&#039;s quite modular and configurable, while also being simple to use if you understand the basics of working with version control.&lt;br /&gt;
 apt-get install etckeeper&lt;br /&gt;
Read this!!!&lt;br /&gt;
 zless /usr/share/doc/etckeeper/README.gz&lt;br /&gt;
&lt;br /&gt;
Crash course:&lt;br /&gt;
 etckeeper init&lt;br /&gt;
 cd /etc&lt;br /&gt;
 git commit -m &amp;quot;initial checkin&amp;quot;&lt;br /&gt;
 git gc&lt;br /&gt;
For the rest, read /usr/share/doc/etckeeper/README.gz&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5122</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5122"/>
		<updated>2008-10-13T14:59:04Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Licenses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
http://opensource.org/&lt;br /&gt;
=== Used by others ===&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
=== Used in CryptoPlus ===&lt;br /&gt;
*pypresent.py&lt;br /&gt;
** MIT license&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5115</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5115"/>
		<updated>2008-10-09T21:07:55Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key), Twofish (128/192/256bits keys)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5114</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5114"/>
		<updated>2008-10-09T12:06:17Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Chaining Modes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
***&amp;quot;It should be mentioned explicitly in the description that when enciphering many blocks, successive T values can and should be computed from prior ones via multiplication by alpha (providing that i remains fixed). This optimization, which is one of the best features of XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5113</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5113"/>
		<updated>2008-10-09T12:05:42Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Chaining Modes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
** Comments: [http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/comments/XTS/XTS_comments-Liskov_Minematsu.pdf]&lt;br /&gt;
*&amp;quot;It should be mentioned explicitly in the description that when enciphering&lt;br /&gt;
many blocks, successive T values can and should be computed&lt;br /&gt;
from prior ones via multiplication by alpha (providing that i remains&lt;br /&gt;
fixed). This optimization, which is one of the best features of&lt;br /&gt;
XEX, should be explicitly recommended in the standard.&amp;quot;&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5111</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5111"/>
		<updated>2008-10-09T09:48:41Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
*RC5&lt;br /&gt;
**http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC5&lt;br /&gt;
**http://people.csail.mit.edu/rivest/Rivest-rc5.pdf&lt;br /&gt;
**ftp://ftp.nordu.net/rfc/rfc2040.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5110</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5110"/>
		<updated>2008-10-07T19:39:15Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* distutils */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
** &amp;quot;egg way&amp;quot;:&amp;lt;br&amp;gt;$ python setup.py bdist_egg&amp;lt;br&amp;gt;$ sudo easy_install dist/CryptoPlus-1.0-py2.5.egg&lt;br /&gt;
&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5107</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5107"/>
		<updated>2008-10-06T14:45:18Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES, PRESENT (80 and 128 bit key)&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5106</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5106"/>
		<updated>2008-10-06T12:12:22Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* source structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_PRESENT.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pypresent.py&lt;br /&gt;
* doctests for ECB and with varying amount of rounds (verified with reference C implementation)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pypresent.py&lt;br /&gt;
|&lt;br /&gt;
* own implementation&lt;br /&gt;
* based on documentation here: http://www.crypto.ruhr-uni-bochum.de/en_publications.html&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5105</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5105"/>
		<updated>2008-10-06T12:09:19Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Differences with pycrypto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||       Py        ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: number2string, roundUp, string2number, xorstring&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementation | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5104</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5104"/>
		<updated>2008-10-06T11:39:28Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
** to have the same results as the reference C implementation, salting the roundkeys should only XOR 5 bits with roundkey when using 128bits key (line 95 in code) but should XOR with no 5bits limit when using 80bits key (line 76 in code). But the standard describes that it should be limited to 5 bits for both key generators...&lt;br /&gt;
* encrypting a block&lt;br /&gt;
* decrypting a block&lt;br /&gt;
* should support rounds up to 65534 (tested with 32, 64, 128 and 65534 rounds)&lt;br /&gt;
** decryption testvectors have errors: the sbox on decryption behaves like the inverse of the p-box... every S-Box value is incorrect in the testvectors.&amp;lt;br&amp;gt;Example:&lt;br /&gt;
 Round 1&lt;br /&gt;
 Subkey: 6dab31744f41d700&lt;br /&gt;
 Text after...&lt;br /&gt;
 ...Key-Xor: 38d2f04c34635345 &lt;br /&gt;
 .....P-Box: 45ef82118f2845a3 &lt;br /&gt;
 .....S-Box: 38d2f04c34635345&lt;br /&gt;
{{#fileanchor: pypresent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# fully based on standard specifications: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf&lt;br /&gt;
# test vectors: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip&lt;br /&gt;
&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
        def __init__(self,key,rounds=32):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Generating roundkeys&lt;br /&gt;
&lt;br /&gt;
                When a Present class initialized, the roundkeys will be generated.&lt;br /&gt;
                You can supply the key as a 128bit or 80bit rawstring.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                self.rounds = rounds&lt;br /&gt;
                self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
                if len(self.key) == 80/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys80(self.key,self.rounds)&lt;br /&gt;
                elif len(self.key) == 128/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys128(self.key,self.rounds)&lt;br /&gt;
                else:&lt;br /&gt;
                        pass&lt;br /&gt;
&lt;br /&gt;
        def encrypt(self,block):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Encrypting 1 block (8 bytes)&lt;br /&gt;
&lt;br /&gt;
                Supply the plaintext block as a raw string and the raw&lt;br /&gt;
                ciphertext will be returned.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,self.rounds):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
                        state = sBoxLayer(state)&lt;br /&gt;
                        state = pLayer(state)&lt;br /&gt;
                cipher = addRoundKey(state,self.roundkeys[self.rounds-1])&lt;br /&gt;
                return cipher.decode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
        def decrypt(self,block):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Decrypting 1 block (8 bytes)&lt;br /&gt;
&lt;br /&gt;
                Supply the ciphertext block as a raw string and the raw&lt;br /&gt;
                plaintext will be returned.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,self.rounds):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[self.rounds-i])&lt;br /&gt;
                        state = pLayer_dec(state)&lt;br /&gt;
                        state = sBoxLayer_dec(state)&lt;br /&gt;
                decipher = addRoundKey(state,self.roundkeys[0])&lt;br /&gt;
                return decipher.decode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
        def get_block_size(self):&lt;br /&gt;
                return 8&lt;br /&gt;
&lt;br /&gt;
#        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f&lt;br /&gt;
SBox = [&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;]&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
        4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
        8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
        12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key,rounds):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Generate the roundkeys for a 80 bit key&lt;br /&gt;
&lt;br /&gt;
        Give a 80bit hex string as input and get a list of roundkeys in return&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,rounds+1): # (K0 ... K32)&lt;br /&gt;
                # rawKey[0:63]&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                #rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                #rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
                key = SBox[int(key[0],16)]+key[1:20]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 15)&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15)&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % key).zfill(80/4)&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key,rounds):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Generate the roundkeys for a 128 bit key&lt;br /&gt;
&lt;br /&gt;
        Give a 128bit hex string as input and get a list of roundkeys in return&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,rounds+1): # (K0 ... K32)&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                key = SBox[int(key[0],16)]+SBox[int(key[1],16)]+key[2:]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 62)&lt;br /&gt;
                temp = temp ^ (i%32)&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62)&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % key).zfill(128/4)&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
        return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;SBox function for encryption&lt;br /&gt;
&lt;br /&gt;
        Takes a hex string as input and will output a hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += SBox[int(state[i],16)]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer_dec(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Inverse SBox function for decryption&lt;br /&gt;
&lt;br /&gt;
        Takes a hex string as input and will output a hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += hex( SBox.index(state[i]) )[2:]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Permutation layer for encryption&lt;br /&gt;
&lt;br /&gt;
        Takes a 64bit hex string as input and will output a 64bit hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox.index(i)]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def pLayer_dec(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Permutation layer for decryption&lt;br /&gt;
&lt;br /&gt;
        Takes a 64bit hex string as input and will output a 64bit hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox[i]]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Convert an integer to a bin string (1 char represents 1 bit)&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        #http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
        s=&#039;&#039;&lt;br /&gt;
        t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
        for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
                s+=t[c]&lt;br /&gt;
        return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pypresent.py}} pypresent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5092</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5092"/>
		<updated>2008-10-05T11:45:39Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: code update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
* decrypting a block&lt;br /&gt;
* should support rounds up to 65534 (tested with 32 and 64 rounds only)&lt;br /&gt;
** decryption testvectors have errors: the sbox on decryption behaves like the inverse of the p-box... every S-Box value is incorrect in the testvectors.&amp;lt;br&amp;gt;Example:&lt;br /&gt;
 Round 1&lt;br /&gt;
 Subkey: 6dab31744f41d700&lt;br /&gt;
 Text after...&lt;br /&gt;
 ...Key-Xor: 38d2f04c34635345 &lt;br /&gt;
 .....P-Box: 45ef82118f2845a3 &lt;br /&gt;
 .....S-Box: 38d2f04c34635345&lt;br /&gt;
{{#fileanchor: pypresent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# fully based on standard specifications: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf&lt;br /&gt;
# test vectors: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip&lt;br /&gt;
&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
        def __init__(self,key,rounds=32):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Generating roundkeys&lt;br /&gt;
                &lt;br /&gt;
                When a Present class initialized, the roundkeys will be generated.&lt;br /&gt;
                You can supply the key as a 128bit or 80bit rawstring.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                self.rounds = rounds&lt;br /&gt;
                self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
                if len(self.key) == 80/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys80(self.key,self.rounds)&lt;br /&gt;
                elif len(self.key) == 128/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys128(self.key,self.rounds)&lt;br /&gt;
                else:&lt;br /&gt;
                        pass&lt;br /&gt;
&lt;br /&gt;
        def encrypt(self,block):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Encrypting 1 block (8 bytes)&lt;br /&gt;
                &lt;br /&gt;
                Supply the plaintext block as a raw string and the raw&lt;br /&gt;
                ciphertext will be returned.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,self.rounds):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
                        state = sBoxLayer(state)&lt;br /&gt;
                        state = pLayer(state)&lt;br /&gt;
                cipher = addRoundKey(state,self.roundkeys[self.rounds-1])&lt;br /&gt;
                return cipher.decode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
        def decrypt(self,block):&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;Decrypting 1 block (8 bytes)&lt;br /&gt;
                &lt;br /&gt;
                Supply the ciphertext block as a raw string and the raw&lt;br /&gt;
                plaintext will be returned.&lt;br /&gt;
                &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,self.rounds):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[self.rounds-i])&lt;br /&gt;
                        state = pLayer_dec(state)&lt;br /&gt;
                        state = sBoxLayer_dec(state)&lt;br /&gt;
                decipher = addRoundKey(state,self.roundkeys[0])&lt;br /&gt;
                return decipher.decode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
        def get_block_size(self):&lt;br /&gt;
                return 16&lt;br /&gt;
&lt;br /&gt;
#        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f&lt;br /&gt;
SBox = [&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;]&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
        4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
        8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
        12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key,rounds):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Generate the roundkeys for a 80 bit key&lt;br /&gt;
        &lt;br /&gt;
        Give a 80bit hex string as input and get a list of roundkeys in return&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,rounds+1): # (K0 ... K32)&lt;br /&gt;
                print i&lt;br /&gt;
                # rawKey[0:63]&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                #rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                #rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
                key = SBox[int(key[0],16)]+key[1:20]&lt;br /&gt;
                #print &amp;quot;sbox&amp;quot;&lt;br /&gt;
                #print key&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 15)&lt;br /&gt;
                temp = (temp ^ i )&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15)&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % key).zfill(80/4)&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key,rounds):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Generate the roundkeys for a 128 bit key&lt;br /&gt;
        &lt;br /&gt;
        Give a 80bit hex string as input and get a list of roundkeys in return&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,rounds+1): # (K0 ... K32)&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                key = SBox[int(key[0],16)]+SBox[int(key[1],16)]+key[2:]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 62) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62) + ( (int(key,16) &amp;gt;&amp;gt; 67) &amp;lt;&amp;lt;67 )&lt;br /&gt;
                key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
        return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;SBox function for encryption&lt;br /&gt;
        &lt;br /&gt;
        Takes a hex string as input and will output a hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += SBox[int(state[i],16)]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer_dec(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Inverse SBox function for decryption&lt;br /&gt;
        &lt;br /&gt;
        Takes a hex string as input and will output a hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += hex( SBox.index(state[i]) )[2:]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Permutation layer for encryption&lt;br /&gt;
        &lt;br /&gt;
        Takes a 64bit hex string as input and will output a 64bit hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox.index(i)]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def pLayer_dec(state):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Permutation layer for decryption&lt;br /&gt;
        &lt;br /&gt;
        Takes a 64bit hex string as input and will output a 64bit hex string&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox[i]]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Convert an integer to a bin string (1 char represents 1 bit)&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        #http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
        s=&#039;&#039;&lt;br /&gt;
        t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
        for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
                s+=t[c]&lt;br /&gt;
        return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pypresent.py}} pypresent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5085</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5085"/>
		<updated>2008-10-04T10:16:30Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
* decrypting a block&lt;br /&gt;
** decryption testvectors have errors: the sbox on decryption behaves like the inverse of the p-box... every S-Box value is incorrect in the testvectors.&amp;lt;br&amp;gt;Example:&lt;br /&gt;
 Round 1&lt;br /&gt;
 Subkey: 6dab31744f41d700&lt;br /&gt;
 Text after...&lt;br /&gt;
 ...Key-Xor: 38d2f04c34635345 &lt;br /&gt;
 .....P-Box: 45ef82118f2845a3 &lt;br /&gt;
 .....S-Box: 38d2f04c34635345&lt;br /&gt;
{{#fileanchor: pypresent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# fully based on standard specifications: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf&lt;br /&gt;
# test vectors: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip&lt;br /&gt;
&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
        def __init__(self,key):&lt;br /&gt;
                self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
                if len(self.key) == 80/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys80(self.key)&lt;br /&gt;
                elif len(self.key) == 128/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys128(self.key)&lt;br /&gt;
                else:&lt;br /&gt;
                        pass&lt;br /&gt;
&lt;br /&gt;
        def encrypt(self,block):&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,32):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
                        state = sBoxLayer(state)&lt;br /&gt;
                        state = pLayer(state)&lt;br /&gt;
                cipher = addRoundKey(state,self.roundkeys[31])&lt;br /&gt;
                return cipher&lt;br /&gt;
&lt;br /&gt;
                &lt;br /&gt;
        def decrypt(self,block):&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,32):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[32-i])&lt;br /&gt;
                        state = pLayer_dec(state)&lt;br /&gt;
                        state = sBoxLayer_dec(state)&lt;br /&gt;
                decipher = addRoundKey(state,self.roundkeys[0])&lt;br /&gt;
                return decipher&lt;br /&gt;
&lt;br /&gt;
        def get_block_size(self):&lt;br /&gt;
                return 16&lt;br /&gt;
&lt;br /&gt;
#        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f&lt;br /&gt;
SBox = [&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;]&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
        4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
        8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
        12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key):&lt;br /&gt;
        # input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
                # rawKey[0:63]&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                #rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                #rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
                key = S(key[0])+key[1:20]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 15) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15) + ( (int(key,16) &amp;gt;&amp;gt; 20) &amp;lt;&amp;lt;20 )&lt;br /&gt;
                key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key):&lt;br /&gt;
        # input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                key = S(key[0])+S(key[1])+key[2:]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 62) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62) + ( (int(key,16) &amp;gt;&amp;gt; 67) &amp;lt;&amp;lt;67 )&lt;br /&gt;
                key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
        return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += SBox[int(state[i],16)]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer_dec(state):&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += hex( SBox.index(state[i]) )[2:]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox.index(i)]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def pLayer_dec(state):&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox[i]]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
        #int to bin&lt;br /&gt;
        #http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
        s=&#039;&#039;&lt;br /&gt;
        t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
        for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
                s+=t[c]&lt;br /&gt;
        return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pypresent.py}} pypresent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5084</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5084"/>
		<updated>2008-10-04T10:12:01Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
{{#fileanchor: pypresent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# fully based on standard specifications: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf&lt;br /&gt;
# test vectors: http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip&lt;br /&gt;
&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
        def __init__(self,key):&lt;br /&gt;
                self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
                if len(self.key) == 80/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys80(self.key)&lt;br /&gt;
                elif len(self.key) == 128/4:&lt;br /&gt;
                        self.roundkeys = generateRoundkeys128(self.key)&lt;br /&gt;
                else:&lt;br /&gt;
                        pass&lt;br /&gt;
&lt;br /&gt;
        def encrypt(self,block):&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,32):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
                        state = sBoxLayer(state)&lt;br /&gt;
                        state = pLayer(state)&lt;br /&gt;
                cipher = addRoundKey(state,self.roundkeys[31])&lt;br /&gt;
                return cipher&lt;br /&gt;
&lt;br /&gt;
                &lt;br /&gt;
        def decrypt(self,block):&lt;br /&gt;
                state = block.encode(&#039;hex&#039;)&lt;br /&gt;
                for i in range (1,32):&lt;br /&gt;
                        state = addRoundKey(state,self.roundkeys[32-i])&lt;br /&gt;
                        state = pLayer_dec(state)&lt;br /&gt;
                        state = sBoxLayer_dec(state)&lt;br /&gt;
                decipher = addRoundKey(state,self.roundkeys[0])&lt;br /&gt;
                return decipher&lt;br /&gt;
&lt;br /&gt;
        def get_block_size(self):&lt;br /&gt;
                return 16&lt;br /&gt;
&lt;br /&gt;
#        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f&lt;br /&gt;
SBox = [&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;]&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
        4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
        8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
        12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key):&lt;br /&gt;
        # input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
                # rawKey[0:63]&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                #rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                #rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
                key = S(key[0])+key[1:20]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 15) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15) + ( (int(key,16) &amp;gt;&amp;gt; 20) &amp;lt;&amp;lt;20 )&lt;br /&gt;
                key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key):&lt;br /&gt;
        # input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
        roundkeys = []&lt;br /&gt;
        for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
                roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
                #1. Shift&lt;br /&gt;
                key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
                #2. SBox&lt;br /&gt;
                key = S(key[0])+S(key[1])+key[2:]&lt;br /&gt;
                #3. Salt&lt;br /&gt;
                #rawKey[15:19] ^ i&lt;br /&gt;
                temp = (int(key,16) &amp;gt;&amp;gt; 62) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
                temp = temp ^ i&lt;br /&gt;
                key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62) + ( (int(key,16) &amp;gt;&amp;gt; 67) &amp;lt;&amp;lt;67 )&lt;br /&gt;
                key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
        return roundkeys&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
        return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += SBox[int(state[i],16)]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer_dec(state):&lt;br /&gt;
        output =&#039;&#039;&lt;br /&gt;
        for i in range(len(state)):&lt;br /&gt;
                output += hex( SBox.index(state[i]) )[2:]&lt;br /&gt;
        return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox.index(i)]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def pLayer_dec(state):&lt;br /&gt;
        output = &#039;&#039;&lt;br /&gt;
        state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
        for i in range(64):&lt;br /&gt;
                output += state_bin[PBox[i]]&lt;br /&gt;
        return (&amp;quot;%x&amp;quot; % int(output[::-1],2)).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
        #int to bin&lt;br /&gt;
        #http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
        s=&#039;&#039;&lt;br /&gt;
        t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
        for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
                s+=t[c]&lt;br /&gt;
        return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pypresent.py}} pypresent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5083</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5083"/>
		<updated>2008-10-04T08:50:18Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
{{#fileanchor: pypresent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
	def __init__(self,key):&lt;br /&gt;
		self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
		if len(self.key) == 80/4:&lt;br /&gt;
			self.roundkeys = generateRoundkeys80(self.key)&lt;br /&gt;
		elif len(self.key) == 128/4:&lt;br /&gt;
			self.roundkeys = generateRoundkeys128(self.key)&lt;br /&gt;
		else:&lt;br /&gt;
			pass&lt;br /&gt;
&lt;br /&gt;
	def encrypt(self,block):&lt;br /&gt;
		state = block.encode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
		for i in range (1,32):&lt;br /&gt;
			state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
			#print &amp;quot;roundkey&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
			state = sBoxLayer(state)&lt;br /&gt;
			#print &amp;quot;sbox&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
			state = pLayer(state)&lt;br /&gt;
			#print &amp;quot;pLayer&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
		cipher = addRoundKey(state,self.roundkeys[31])&lt;br /&gt;
&lt;br /&gt;
		return cipher&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
	def decrypt(self,block):&lt;br /&gt;
		pass&lt;br /&gt;
&lt;br /&gt;
	def get_block_size(self):&lt;br /&gt;
		return 16&lt;br /&gt;
&lt;br /&gt;
SBox = (&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;)&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
	4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
	8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
	12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key):&lt;br /&gt;
	# input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
	roundkeys = []&lt;br /&gt;
	for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
		# rawKey[0:63]&lt;br /&gt;
		roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
		#1. Shift&lt;br /&gt;
		#rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
		key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
		#print &amp;quot;shift&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
		#2. SBox&lt;br /&gt;
		#rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
		key = S(key[0])+key[1:20]&lt;br /&gt;
		#print &amp;quot;sbox&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
		#3. Salt&lt;br /&gt;
		#rawKey[15:19] ^ i&lt;br /&gt;
		temp = (int(key,16) &amp;gt;&amp;gt; 15) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
		temp = temp ^ i&lt;br /&gt;
		key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15) + ( (int(key,16) &amp;gt;&amp;gt; 20) &amp;lt;&amp;lt;20 )&lt;br /&gt;
		key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
		#print &amp;quot;salt&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
	return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key):&lt;br /&gt;
	# input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
	roundkeys = []&lt;br /&gt;
	for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
		roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
		#1. Shift&lt;br /&gt;
		key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
		print &amp;quot;shift&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
		#2. SBox&lt;br /&gt;
		key = S(key[0])+S(key[1])+key[2:]&lt;br /&gt;
		print &amp;quot;sbox&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
		#3. Salt&lt;br /&gt;
		#rawKey[15:19] ^ i&lt;br /&gt;
		temp = (int(key,16) &amp;gt;&amp;gt; 62) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
		temp = temp ^ i&lt;br /&gt;
		key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62) + ( (int(key,16) &amp;gt;&amp;gt; 67) &amp;lt;&amp;lt;67 )&lt;br /&gt;
		key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
		print &amp;quot;salt&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
	return roundkeys&lt;br /&gt;
&lt;br /&gt;
def S(toS):&lt;br /&gt;
	#apply 4bit Sbox to a hexstring&lt;br /&gt;
	final =&#039;&#039;&lt;br /&gt;
	for i in range (0,len(toS)):&lt;br /&gt;
		final += SBox[int(toS[i],16)]&lt;br /&gt;
	#return convertToBitstring(final,len(toS)*8)[::-1]&lt;br /&gt;
	return final&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
	return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
	output =&#039;&#039;&lt;br /&gt;
	for i in range(len(state)):&lt;br /&gt;
		output += S(state[i])&lt;br /&gt;
	return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
	output = &#039;&#039;&lt;br /&gt;
	state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
	for i in range(64):&lt;br /&gt;
		output += state_bin[PBox.index(i)]&lt;br /&gt;
	return &amp;quot;%x&amp;quot; % int(output[::-1],2)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
	#int to bin&lt;br /&gt;
	#http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
	s=&#039;&#039;&lt;br /&gt;
	t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
	for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
		s+=t[c]&lt;br /&gt;
	return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pypresent.py}} pypresent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5077</id>
		<title>Present python implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=Present_python_implementation&amp;diff=5077"/>
		<updated>2008-10-02T18:51:41Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: New page: what should be working (only tested with 1 or 2 test vectors yet): * calculating round keys * encrypting a block {{#fileanchor: pyserpent.py}} &amp;lt;source lang=python&amp;gt; class Present:  	def __i...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;what should be working (only tested with 1 or 2 test vectors yet):&lt;br /&gt;
* calculating round keys&lt;br /&gt;
* encrypting a block&lt;br /&gt;
{{#fileanchor: pyserpent.py}}&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
class Present:&lt;br /&gt;
&lt;br /&gt;
	def __init__(self,key):&lt;br /&gt;
		self.key = key.encode(&#039;hex&#039;)&lt;br /&gt;
		if len(self.key) == 80/4:&lt;br /&gt;
			self.roundkeys = generateRoundkeys80(self.key)&lt;br /&gt;
		elif len(self.key) == 128/4:&lt;br /&gt;
			self.roundkeys = generateRoundkeys128(self.key)&lt;br /&gt;
		else:&lt;br /&gt;
			pass&lt;br /&gt;
&lt;br /&gt;
	def encrypt(self,block):&lt;br /&gt;
		state = block.encode(&#039;hex&#039;)&lt;br /&gt;
&lt;br /&gt;
		for i in range (1,32):&lt;br /&gt;
			state = addRoundKey(state,self.roundkeys[i-1])&lt;br /&gt;
			#print &amp;quot;roundkey&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
			state = sBoxLayer(state)&lt;br /&gt;
			#print &amp;quot;sbox&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
			state = pLayer(state)&lt;br /&gt;
			#print &amp;quot;pLayer&amp;quot;&lt;br /&gt;
			#print state&lt;br /&gt;
		cipher = addRoundKey(state,self.roundkeys[31])&lt;br /&gt;
&lt;br /&gt;
		return cipher&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
	def decrypt(self,block):&lt;br /&gt;
		pass&lt;br /&gt;
&lt;br /&gt;
	def get_block_size(self):&lt;br /&gt;
		return 16&lt;br /&gt;
&lt;br /&gt;
SBox = (&#039;c&#039;,&#039;5&#039;,&#039;6&#039;,&#039;b&#039;,&#039;9&#039;,&#039;0&#039;,&#039;a&#039;,&#039;d&#039;,&#039;3&#039;,&#039;e&#039;,&#039;f&#039;,&#039;8&#039;,&#039;4&#039;,&#039;7&#039;,&#039;1&#039;,&#039;2&#039;)&lt;br /&gt;
PBox = [0,16,32,48,1,17,33,49,2,18,34,50,3,19,35,51,&lt;br /&gt;
	4,20,36,52,5,21,37,53,6,22,38,54,7,23,39,55,&lt;br /&gt;
	8,24,40,56,9,25,41,57,10,26,42,58,11,27,43,59,&lt;br /&gt;
	12,28,44,60,13,29,45,61,14,30,46,62,15,31,47,63]&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys80(key):&lt;br /&gt;
	# input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
	roundkeys = []&lt;br /&gt;
	for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
		# rawKey[0:63]&lt;br /&gt;
		roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;16 )).zfill(64/4))&lt;br /&gt;
		#1. Shift&lt;br /&gt;
		#rawKey[19:(len(rawKey)-1)]+rawKey[0:18]&lt;br /&gt;
		key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,19)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 19))).zfill(80/4)&lt;br /&gt;
		#print &amp;quot;shift&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
		#2. SBox&lt;br /&gt;
		#rawKey[76:79] = S(rawKey[76:79])&lt;br /&gt;
		key = S(key[0])+key[1:20]&lt;br /&gt;
		#print &amp;quot;sbox&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
		#3. Salt&lt;br /&gt;
		#rawKey[15:19] ^ i&lt;br /&gt;
		temp = (int(key,16) &amp;gt;&amp;gt; 15) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
		temp = temp ^ i&lt;br /&gt;
		key = ( int(key,16) &amp;amp; (pow(2,15)-1) ) + (temp &amp;lt;&amp;lt; 15) + ( (int(key,16) &amp;gt;&amp;gt; 20) &amp;lt;&amp;lt;20 )&lt;br /&gt;
		key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
		#print &amp;quot;salt&amp;quot;&lt;br /&gt;
		#print key&lt;br /&gt;
	return roundkeys&lt;br /&gt;
&lt;br /&gt;
def generateRoundkeys128(key):&lt;br /&gt;
	# input: hex string ex. &#039;ffff&#039;&lt;br /&gt;
	roundkeys = []&lt;br /&gt;
	for i in range(1,33): # (K0 ... K32)&lt;br /&gt;
		roundkeys.append((&amp;quot;%x&amp;quot; % (int(key,16) &amp;gt;&amp;gt;64)).zfill(64/4))&lt;br /&gt;
		#1. Shift&lt;br /&gt;
		key = (&amp;quot;%x&amp;quot; % ( ((int(key,16) &amp;amp; (pow(2,67)-1)) &amp;lt;&amp;lt; 61) + (int(key,16) &amp;gt;&amp;gt; 67))).zfill(128/4)&lt;br /&gt;
		print &amp;quot;shift&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
		#2. SBox&lt;br /&gt;
		key = S(key[0])+S(key[1])+key[2:]&lt;br /&gt;
		print &amp;quot;sbox&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
		#3. Salt&lt;br /&gt;
		#rawKey[15:19] ^ i&lt;br /&gt;
		temp = (int(key,16) &amp;gt;&amp;gt; 62) &amp;amp; (pow(2,5)-1) # rawKey[15:19]&lt;br /&gt;
		temp = temp ^ i&lt;br /&gt;
		key = ( int(key,16) &amp;amp; (pow(2,62)-1) ) + (temp &amp;lt;&amp;lt; 62) + ( (int(key,16) &amp;gt;&amp;gt; 67) &amp;lt;&amp;lt;67 )&lt;br /&gt;
		key = &amp;quot;%x&amp;quot; % key&lt;br /&gt;
		print &amp;quot;salt&amp;quot;&lt;br /&gt;
		print key&lt;br /&gt;
	return roundkeys&lt;br /&gt;
&lt;br /&gt;
def S(toS):&lt;br /&gt;
	#apply 4bit Sbox to a hexstring&lt;br /&gt;
	final =&#039;&#039;&lt;br /&gt;
	for i in range (0,len(toS)):&lt;br /&gt;
		final += SBox[int(toS[i],16)]&lt;br /&gt;
	#return convertToBitstring(final,len(toS)*8)[::-1]&lt;br /&gt;
	return final&lt;br /&gt;
&lt;br /&gt;
def addRoundKey(state,roundkey):&lt;br /&gt;
	return ( &amp;quot;%x&amp;quot; % ( int(state,16) ^ int(roundkey,16) ) ).zfill(16)&lt;br /&gt;
&lt;br /&gt;
def sBoxLayer(state):&lt;br /&gt;
	output =&#039;&#039;&lt;br /&gt;
	for i in range(len(state)):&lt;br /&gt;
		output += S(state[i])&lt;br /&gt;
	return output&lt;br /&gt;
&lt;br /&gt;
def pLayer(state):&lt;br /&gt;
	output = &#039;&#039;&lt;br /&gt;
	state_bin = bin(int(state,16)).zfill(64)[::-1][0:64]&lt;br /&gt;
	for i in range(64):&lt;br /&gt;
		output += state_bin[PBox.index(i)]&lt;br /&gt;
	return &amp;quot;%x&amp;quot; % int(output[::-1],2)&lt;br /&gt;
&lt;br /&gt;
def bin(a):&lt;br /&gt;
	#int to bin&lt;br /&gt;
	#http://wiki.python.org/moin/BitManipulation&lt;br /&gt;
	s=&#039;&#039;&lt;br /&gt;
	t={&#039;0&#039;:&#039;000&#039;,&#039;1&#039;:&#039;001&#039;,&#039;2&#039;:&#039;010&#039;,&#039;3&#039;:&#039;011&#039;,&#039;4&#039;:&#039;100&#039;,&#039;5&#039;:&#039;101&#039;,&#039;6&#039;:&#039;110&#039;,&#039;7&#039;:&#039;111&#039;}&lt;br /&gt;
	for c in oct(a).rstrip(&#039;L&#039;)[1:]:&lt;br /&gt;
		s+=t[c]&lt;br /&gt;
	return s&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Download code: [{{#filelink: pyserpent.py}} pyserpent.py]&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5076</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5076"/>
		<updated>2008-10-02T18:50:22Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||                 ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: gf2n, padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/gf2n.py&lt;br /&gt;
|&lt;br /&gt;
*found here: http://www.bjrn.se/code/pytruecrypt/gf2npy.txt (python truecrypt)&lt;br /&gt;
*used for XTS chain mode&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: gf2pow128powof2, number2string, roundUp, string2number, xorstring, xorstring16&lt;br /&gt;
*gf2pow128powof2, xorstring16 are originally from the python truecrypt XTS implementation&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
**[[Present python implementatin | own implementation]]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5075</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5075"/>
		<updated>2008-10-02T18:46:37Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* Ciphers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||                 ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: gf2n, padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/gf2n.py&lt;br /&gt;
|&lt;br /&gt;
*found here: http://www.bjrn.se/code/pytruecrypt/gf2npy.txt (python truecrypt)&lt;br /&gt;
*used for XTS chain mode&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: gf2pow128powof2, number2string, roundUp, string2number, xorstring, xorstring16&lt;br /&gt;
*gf2pow128powof2, xorstring16 are originally from the python truecrypt XTS implementation&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*[[Present]]&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5074</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5074"/>
		<updated>2008-10-02T09:41:20Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* TODO */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||                 ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: gf2n, padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/gf2n.py&lt;br /&gt;
|&lt;br /&gt;
*found here: http://www.bjrn.se/code/pytruecrypt/gf2npy.txt (python truecrypt)&lt;br /&gt;
*used for XTS chain mode&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: gf2pow128powof2, number2string, roundUp, string2number, xorstring, xorstring16&lt;br /&gt;
*gf2pow128powof2, xorstring16 are originally from the python truecrypt XTS implementation&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**&amp;lt;del&amp;gt;CBC for serpent, twofish, blowfish&amp;lt;/del&amp;gt;&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
**&amp;lt;del&amp;gt; decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&amp;lt;/del&amp;gt;&lt;br /&gt;
**GF2 not necessary anymore in XTS&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
	<entry>
		<id>https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5069</id>
		<title>PyCryptoPlus</title>
		<link rel="alternate" type="text/html" href="https://wiki.yobi.be/index.php?title=PyCryptoPlus&amp;diff=5069"/>
		<updated>2008-10-01T12:55:36Z</updated>

		<summary type="html">&lt;p&gt;Tiftof: /* setuptools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[SAGE &amp;amp; cryptology]]&lt;br /&gt;
== Info ==&lt;br /&gt;
=== Differences with pycrypto ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ||CryptoPlus||PyCrypto&lt;br /&gt;
|- style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block Ciphers&lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Block cipher algorithms&lt;br /&gt;
|-&lt;br /&gt;
|     Serpent      ||       Py        ||         &lt;br /&gt;
|-&lt;br /&gt;
|     Blowfish      ||      Py         ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     Twofish      ||       Py        ||           &lt;br /&gt;
|-&lt;br /&gt;
|     Idea         ||               ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     DES          ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     3DES         ||       Py        ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     AES          ||       Py        ||  C    &lt;br /&gt;
|-&lt;br /&gt;
|     Rijndael     ||       Py        ||     &lt;br /&gt;
|-&lt;br /&gt;
|     Present      ||                 ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Modes of operation&lt;br /&gt;
|-&lt;br /&gt;
|     CMAC         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XCBC         ||               ||       &lt;br /&gt;
|-&lt;br /&gt;
|     CBC-MAC      ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     CCM          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     GCM          ||               ||        &lt;br /&gt;
|-&lt;br /&gt;
|     ECB          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CBC          ||      Py       ||  C     &lt;br /&gt;
|-&lt;br /&gt;
|     CTR          ||      Py       ||  C      &lt;br /&gt;
|-&lt;br /&gt;
|     LRW          ||               ||         &lt;br /&gt;
|-&lt;br /&gt;
|     XTS          ||      Py       ||      &lt;br /&gt;
|-&lt;br /&gt;
|     MDC-2        ||               ||     &lt;br /&gt;
|- style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
| align=&amp;quot;left&amp;quot; colspan=&amp;quot;8&amp;quot;|Paddings&lt;br /&gt;
|-&lt;br /&gt;
|     bit padding    ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     zeros          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS7          ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     PKCS12         ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ISO 10126      ||      Py       ||         &lt;br /&gt;
|-&lt;br /&gt;
|     ANSI X.923     ||      Py       ||        &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*ciphers from pycrypto are being used with the python chaining modes and not the original pycrypto ones&amp;lt;br&amp;gt;=&amp;gt; plaintext can be supplied in arbitrary sizes instead of multiples of the blocksize like in pycrypto: the new chaining modes keep a cache to encrypt/decrypt data once the cachesize holds at least a blocksize of data&lt;br /&gt;
* new possibilities:&lt;br /&gt;
** Rijndael, Serpent, Twofish&lt;br /&gt;
*** Rijndael is limited to blocksizes of 128, 192 and 256 bits&lt;br /&gt;
** CMAC, XTS, CTR&lt;br /&gt;
*** XTS is usable for ciphers with blocksizes of 16 bytes =&amp;gt; XTS-AES, Serpent, Twofish&lt;br /&gt;
*** XTS encrypts the given input at once while all other chain modes encrypt only when a block plaintext is available in the cache&lt;br /&gt;
*** CMAC is usable for blocksizes of 8 and 16 bytes&lt;br /&gt;
** OFB,CFB and CTR can be accessed as a stream cipher (you get the encrypted message immediately, you don&#039;t have to wait until a complete block of plaintext has been provided to the cipher)&lt;br /&gt;
* test functions are available via doctests and extensive tests that loop through dictionary of test vectors&lt;br /&gt;
** new pycrypto version will have it&#039;s own test bench for ciphers, this is not implemented yet&lt;br /&gt;
&lt;br /&gt;
=== source structure ===&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| root of CryptoPlus package&lt;br /&gt;
|-&lt;br /&gt;
|src/Hash.py&lt;br /&gt;
|make all Crypto.Hash modules available under CryptoPlus.Hash&lt;br /&gt;
|-&lt;br /&gt;
|src/Protocol.py&lt;br /&gt;
|make all Crypto.Protocol modules available under CryptoPlus.Protocol&lt;br /&gt;
|-&lt;br /&gt;
|src/PublicKey.py&lt;br /&gt;
|make all Crypto.PublicKey modules available under CryptoPlus.PublicKey&lt;br /&gt;
|-&lt;br /&gt;
|src/__init__.py&lt;br /&gt;
|make the following modules available under the CryptoPlus package: &amp;quot;Cipher&amp;quot;,&amp;quot;PublicKey&amp;quot;,&amp;quot;Util&amp;quot;,&amp;quot;Protocol&amp;quot;,&amp;quot;Hash&amp;quot;,&amp;quot;testvectors&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|src/testvectors.py&lt;br /&gt;
|&lt;br /&gt;
*contains dictionaries with testvectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
*used by test/test.py&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| CryptoPlus.Cipher subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/__init__.py&lt;br /&gt;
|specify all the ciphers in the CryptoPlus.Cipher package + import of the streamcipher ARC4 and XOR&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/blockcipher.py&lt;br /&gt;
|&lt;br /&gt;
* class BlockCipher: parent class for every cipher you constructs. Holds some variabeles (key, blocksize) and objects (blockcipher, chain mode).&lt;br /&gt;
* classes for every chain mode: the BlockCipher uses one of these as the chaining mode object. They are all own python code but sometimes based on non-complete code that was available.&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pycrypto&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/AES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.AES&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB, CTR, XTS, CMAC (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/ARC2.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.ARC2&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.Blowfish&lt;br /&gt;
*doctests for: ECB, CBC, CFB, OFB&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/CAST.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.CAST&lt;br /&gt;
*doctests for: 2 ECB examples (128 bit and 40 bit key size)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES&lt;br /&gt;
*doctests for: ECB (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/DES3.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.DES3&lt;br /&gt;
*doctests for: CBC, CMAC TDES-EDE3, CMAC TDES-EDE2 (verified)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/IDEA.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.IDEA&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/RC5.py&lt;br /&gt;
|&lt;br /&gt;
*wraps Crypto.Cipher.RC5&lt;br /&gt;
*doctests for: 1 ECB example&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Wrappers for pure python implementations&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_AES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps rijndael.py (only for the AES blocksize of 128bits)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Blowfish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyblowfish.py&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_DES3.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyDes.py (only using &amp;quot;triple_des&amp;quot; class)&lt;br /&gt;
* doctests same as in the pycrypto wrapper&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyrijndael.py&lt;br /&gt;
* doctests for ECB, CBC, XTS (CBC and XTS are AES test vectors)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Serpent.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pyserpent.py&lt;br /&gt;
* doctests for ECB, CBC (?verified?)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/python_Twofish.py&lt;br /&gt;
|&lt;br /&gt;
* wraps pytwofish.py&lt;br /&gt;
* doctests for ECB (?unverified?)&lt;br /&gt;
|-style=&amp;quot;background-color:#eeeeee;&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot;| Pure python implementations for blockciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyDes.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://twhiteman.netfirms.com/des.html&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyblowfish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.michaelgilfix.com/files/blowfish.py&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pyserpent.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
* added class to wrap all the functions needed in one class so that the serpent cipher can be accessed like all other pure python ciphers&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/pytwofish.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://psionicist.online.fr/code/ (python truecrypt)&lt;br /&gt;
|-&lt;br /&gt;
|src/Cipher/rijndael.py&lt;br /&gt;
|&lt;br /&gt;
* originally found here: http://bitconjurer.org/rijndael.py but using the modified version of tlslite (compatibility fix with python 2.4) &lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Util subpackage&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/__init__.py&lt;br /&gt;
|&lt;br /&gt;
*import modules from original Crypto.Util: number, randpool, RFC1751&lt;br /&gt;
*make new modules available: gf2n, padding, util&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/gf2n.py&lt;br /&gt;
|&lt;br /&gt;
*found here: http://www.bjrn.se/code/pytruecrypt/gf2npy.txt (python truecrypt)&lt;br /&gt;
*used for XTS chain mode&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/padding.py&lt;br /&gt;
|&lt;br /&gt;
*own code for (un)padding raw strings&lt;br /&gt;
*testbench that will pad/unpad a string with all available methods and check for errors between original and unpadded string&lt;br /&gt;
|-&lt;br /&gt;
|src/Util/util.py&lt;br /&gt;
|&lt;br /&gt;
*provides: gf2pow128powof2, number2string, roundUp, string2number, xorstring, xorstring16&lt;br /&gt;
*gf2pow128powof2, xorstring16 are originally from the python truecrypt XTS implementation&lt;br /&gt;
|-style=&amp;quot;background-color:#dddddd;&amp;quot;&lt;br /&gt;
! align=&amp;quot;left&amp;quot; colspan=&amp;quot;2&amp;quot;| Test scripts&lt;br /&gt;
|-&lt;br /&gt;
|test/test.py&lt;br /&gt;
|runs extensive test with verified test vectors for: CBC, CFB, OFB and CTR with AES, DES,TDES2/3, Serpent128/192/256, CMAC-AES128/192/256, CMAC-TDES2/3, XTS-AES&lt;br /&gt;
|-&lt;br /&gt;
|test/test_doctests.py&lt;br /&gt;
|script to run all doctest available in every cipher wrapper (pure python and pycrypto wrapper)&lt;br /&gt;
|}&lt;br /&gt;
* verified = test vectors are support by an online source. A link is available in the doctest.&lt;br /&gt;
&lt;br /&gt;
==TODO==&lt;br /&gt;
*add chaining modes: &amp;lt;del&amp;gt;CMAC&amp;lt;/del&amp;gt;, CTR mod?&lt;br /&gt;
*&amp;lt;del&amp;gt;further importing of pycrypto&amp;lt;/del&amp;gt;&lt;br /&gt;
*&amp;lt;del&amp;gt;make test vectors available as variables&amp;lt;/del&amp;gt;&lt;br /&gt;
*add tests:&lt;br /&gt;
**CBC for serpent, twofish, blowfish&lt;br /&gt;
**XTS &amp;lt;del&amp;gt;is only tested by comparing deciphered ciphertext, not by checking ciphertext&amp;lt;/del&amp;gt;: XTS-AES doctest done&lt;br /&gt;
*check other implementation of Blowfish&lt;br /&gt;
*&amp;lt;del&amp;gt;final() method of chains&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;add a cipher.final() method? pycrypto doesn&#039;t have it, but it doesn&#039;t really conflict with the pycrypto API. It will just extend it&amp;lt;/del&amp;gt;&lt;br /&gt;
**&amp;lt;del&amp;gt;final() method should use padding. Choose padding function at initialization of the cipher =&amp;gt; again: extending the API&amp;lt;/del&amp;gt;&lt;br /&gt;
* XTS &lt;br /&gt;
** make other blocksizes available besides 16 bytes?&lt;br /&gt;
* CMAC&lt;br /&gt;
** make other blocksizes available besides 8 and 16 bytes?&lt;br /&gt;
** &amp;lt;del&amp;gt;supply XTS keys by splitting 1 big key or by supplying two keys?&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add rijndael instead of only AES&amp;lt;/del&amp;gt;&lt;br /&gt;
* &amp;lt;del&amp;gt;add docstring to every &amp;quot;new&amp;quot; function of every module, explaining what should be passed as arguments (probably the same for every function)&amp;lt;br&amp;gt;Move doctests there so they are easily viewable&amp;lt;/del&amp;gt;&lt;br /&gt;
* check GF2 in XTS + can it be replaced by Sage&#039;s implementation of GF2 ( -&amp;gt; [http://modular.math.washington.edu/sage/doc/tut/node55.html]? ) ?&lt;br /&gt;
** decision: stays the way it is. When Sage&#039;s GF2 would be used, then CryptoPlus wouldn&#039;t work without sage.&lt;br /&gt;
* use unittest for test functions&lt;br /&gt;
* check development of pycrypto:&lt;br /&gt;
** Util.Counter &amp;amp; Util._counter&lt;br /&gt;
** SelfTest: usable to perform the test for python algo&#039;s in CryptoPlus if testvectors are in right format?&lt;br /&gt;
&lt;br /&gt;
== Tests available ==&lt;br /&gt;
* Doctests&lt;br /&gt;
** Blowfish: ECB, CBC, CFB, OFB&lt;br /&gt;
** all chain modes in AES&lt;br /&gt;
* Extensive external test (via tester.py)&lt;br /&gt;
** DES,TDES2,TDES3: ECB&lt;br /&gt;
** Serpent 128/192/256: ECB&lt;br /&gt;
** CMAC: AES128/192/256&lt;br /&gt;
** XTS: AES128/256 and plaintext multiples and non-multiples of 16 bytes&lt;br /&gt;
&lt;br /&gt;
==Licenses==&lt;br /&gt;
*used from [http://psionicist.online.fr/code/pytruecrypt/ python truecrypt implementation]&amp;lt;br&amp;gt;all original code is under MIT license (much freedom according to [http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html])&lt;br /&gt;
**pyTwofish (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**pyserpent (untouched)&amp;lt;br&amp;gt;python truecrypt author isn&#039;t the original author = &amp;gt; extra copyright notice that should be left in place&lt;br /&gt;
**XTS (modified)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
**GF2n.py(untouched)&amp;lt;br&amp;gt;python truecrypt author is the original author =&amp;gt; only MIT License&lt;br /&gt;
*pyblowfish (untouched)&amp;lt;br&amp;gt;gpl or artistic license&amp;lt;br&amp;gt;To not affect the rest of the distribution we&#039;ve to redistribute it only under Artistic license terms&lt;br /&gt;
*rijndael.py (untouched)&amp;lt;br&amp;gt;using tls lite (public domain) implementation which uses code from Bram Cohen (public domain)&lt;br /&gt;
*pyDes (untouched)&amp;lt;br&amp;gt;public domain according to its homepage&lt;br /&gt;
*blockciphers CBC, ECB, CTR from [http://www.nightsong.com/phr/crypto/blockcipher.tgz] (modified)&amp;lt;br&amp;gt;keep copyright notice in place?&lt;br /&gt;
*CMAC: [http://github.com/jlhutch/jac/tree/master/omac.py omac.py]&amp;lt;br&amp;gt; GPL but not really used it, just used as a starting point&lt;br /&gt;
&lt;br /&gt;
== Various info  ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
*absolute relative imports: links with some info&lt;br /&gt;
** http://bugs.python.org/issue1510172&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0366/&lt;br /&gt;
** http://www.python.org/dev/peps/pep-0328/&lt;br /&gt;
** http://groups.google.com/group/comp.lang.python/msg/e35b1746b425b4c1&lt;br /&gt;
* collect all doctests&lt;br /&gt;
** http://docs.python.org/lib/doctest-unittest-api.html&lt;br /&gt;
* making a package&lt;br /&gt;
** http://docs.python.org/dist/&lt;br /&gt;
&lt;br /&gt;
==== Setup Script ====&lt;br /&gt;
===== distutils vs setuptools =====&lt;br /&gt;
Dependencies checking on install: some info [http://blog.doughellmann.com/2007/11/requiring-packages-with-distutils.html here].&lt;br /&gt;
:It seems that the &#039;requires&#039; keyword in distutils has only a purpose of documentation, but &#039;install_requires&#039; in setuptools really takes care of dependencies: availability of dependencies will be checked. If a package is not available, it will be checked for on [http://pypi.python.org/pypi pypi] and installed automatically.&lt;br /&gt;
===== distutils =====&lt;br /&gt;
* setup.py&lt;br /&gt;
** creating a distribution tar.gz: &amp;quot;python setup.py sdist&amp;quot;&lt;br /&gt;
** installing the source distribution (sdist):&amp;lt;br&amp;gt;- untar .tar.gz: &amp;quot;cd dist &amp;amp;&amp;amp; tar zxfv CryptoPlus-1.0.tar.gz -C ~/&amp;quot;&amp;lt;br&amp;gt;- &amp;quot;cd ~/CryptoPlus-1.0 &amp;amp;&amp;amp; python setup.py install&amp;quot;&lt;br /&gt;
===== setuptools =====&lt;br /&gt;
* http://pypi.python.org/pypi/setuptools/&lt;br /&gt;
* manual: http://peak.telecommunity.com/DevCenter/setuptools&lt;br /&gt;
* it isn&#039;t installed by default on debian&lt;br /&gt;
** apt-get install python-setuptools&lt;br /&gt;
** sage-python has setuptools by default&lt;br /&gt;
&lt;br /&gt;
===Test Vectors===&lt;br /&gt;
*Collection of test vectors for a broad group of ciphers&lt;br /&gt;
** http://www.3amsystems.com/monetics/vectors.htm&lt;br /&gt;
** https://www.cosic.esat.kuleuven.be/nessie/testvectors/&lt;br /&gt;
*AES, DES, 3DES: http://csrc.nist.gov/groups/STM/cavp/standards.html&lt;br /&gt;
**AES in CBC, CTR, OFB, CFB: [http://cryptome.org/bcm/sp800-38a.htm html version of pdf]&lt;br /&gt;
**CMAC test vectors in &#039;&#039;Special Publication 800-38B&#039;&#039; are faulty, use the corrected ones from [http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf here]&lt;br /&gt;
*Rijndael: http://fp.gladman.plus.com/cryptography_technology/rijndael/&lt;br /&gt;
**zip file contains a full set of round values for each of the 25 block and key length combinations from 128, 160, 192, 224 and 256 bits for &#039;&#039;&#039;one input block&#039;&#039;&#039; and one key value&lt;br /&gt;
*DES (enkel ECB): http://www.skepticfiles.org/faq/testdes.htm&lt;br /&gt;
*Blowfish: http://www.schneier.com/code/vectors.txt&lt;br /&gt;
*Serpent: http://www.cs.technion.ac.il/~biham/Reports/Serpent/&lt;br /&gt;
*Twofish: http://www.schneier.com/code/ecb_ival.txt&lt;br /&gt;
*AES, DES: http://svn.python.org/projects/external/openssl-0.9.8a/test/evptests.txt&lt;br /&gt;
*CMAC&lt;br /&gt;
**AES &amp;amp; TDES: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
**AES, TDES2 &amp;amp; TDES3: http://csrc.nist.gov/groups/STM/cavp/documents/mac/cmactestvectors.zip&lt;br /&gt;
***fax folder contains usefull stuff: generation and verification tests with results&amp;lt;br&amp;gt;generation test: generate a correct mac&amp;lt;br&amp;gt;verification test: verify if provided mac for plaintext is correct&lt;br /&gt;
*XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*ARC2: http://www.ietf.org/rfc/rfc2268.txt&lt;br /&gt;
** will be available in pycrypto &amp;gt;2.0.1&lt;br /&gt;
*CAST: http://www.rfc-editor.org/rfc/rfc2144.txt&lt;br /&gt;
&lt;br /&gt;
===Chaining Modes===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Wikipedia]&lt;br /&gt;
*[http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html NIST]&lt;br /&gt;
*XTS: &lt;br /&gt;
**https://siswg.net/index.php?option=com_content&amp;amp;task=view&amp;amp;id=38&amp;amp;Itemid=73&lt;br /&gt;
**http://blog.bjrn.se/2008/02/truecrypt-explained-truecrypt-5-update.html&lt;br /&gt;
**http://en.wikipedia.org/wiki/IEEE_P1619 = [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf XTS-AES]&lt;br /&gt;
**XTS-AES: [http://grouper.ieee.org/groups/1619/email/pdf00086.pdf IEEE P1619TM/D16: Standard for Cryptographic Protection of Data on Block-Oriented Storage Devices]&lt;br /&gt;
*CMAC = OMAC1:&lt;br /&gt;
** AES-CMAC: http://tools.ietf.org/html/rfc4493#page-2&lt;br /&gt;
** NIST:&amp;lt;br&amp;gt;Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication:[http://csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf SP 800-38B.pdf]&amp;lt;br&amp;gt;[http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf Updated CMAC Examples]&lt;br /&gt;
** OMAC.py: http://github.com/jlhutch/jac/tree/master/omac.py&lt;br /&gt;
** OMAC page: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html&lt;br /&gt;
&lt;br /&gt;
===Ciphers===&lt;br /&gt;
*Serpent&lt;br /&gt;
** http://www.cl.cam.ac.uk/~rja14/serpent.html&lt;br /&gt;
** python implementation used &amp;lt;del&amp;gt;at the moment&amp;lt;/del&amp;gt; in earlier versions: http://psionicist.online.fr/code/&lt;br /&gt;
** alternative python implementation (used in current version): http://www.cl.cam.ac.uk/~fms27/serpent/&lt;br /&gt;
*** more info on this python implementation: http://www.cl.cam.ac.uk/~fms27/serpent/serpent-abstract.html&lt;br /&gt;
*Present&lt;br /&gt;
**Article: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/present_ches2007.pdf PRESENT: An Ultra-Lightweight Block Cipher]&lt;br /&gt;
**Test Vector generator + ANSI-C implementation of present: [http://www.crypto.ruhr-uni-bochum.de/imperia/md/content/texte/publications/conferences/slides/present_testvectors.zip]&lt;br /&gt;
*ARC2&lt;br /&gt;
** http://www.ietf.org/rfc/rfc2268.txt: publication + testvectors&lt;br /&gt;
** current pycrypto implementation fails all testvectors because of not correctly handling the &amp;quot;effective keylength&amp;quot;. Fixed in upcoming release (+2.0.1) [https://bugs.launchpad.net/pycrypto/+bug/269843 bugreport][http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.0.x.git;a=commitdiff;h=4820664350a42ecca81cede53a6cb349fcffacde bugfix]&lt;br /&gt;
*CAST&lt;br /&gt;
**http://www.rfc-editor.org/rfc/rfc2144.txt&lt;/div&gt;</summary>
		<author><name>Tiftof</name></author>
	</entry>
</feed>