doegox / python-cryptoplus Goto Github PK
View Code? Open in Web Editor NEWPyCryptoPlus: a pycrypto extension written 100% in Python
License: Other
PyCryptoPlus: a pycrypto extension written 100% in Python
License: Other
PYCRYPTOPLUS ============= TABLE OF CONTENTS ================== 1. WHAT IS CRYPTOPLUS 2. INSTALLING 3. GETTING STARTED 4. LIMITATIONS 1. WHAT IS CRYPTOPLUS ====================== PyCryptoPlus is an extension to the Python Crypto module (www.pycrypto.org). PyCryptoPlus provides same ciphers as included in pycrypto but also new ones, all being written 100% in Python. Some additional chaining modes have been added, also in pure Python, while the ones already available in pycrypto are provided in pure python in this package. The reasoning is that Python code has the advantage to be more readable and so easier to be adapted to your needs or experiments. All other functions of pycrypto are still available via the interface of CryptoPlus. The new cipher implementations can be accessed via CryptoPlus.Cipher.python_* while the original ones from pycrypto are still available under their original name via CryptoPlus.Cipher.*. When using the original ciphers, the original pycrypto code written in C is used but the chaining modes being used are the new ones in Python. New functions: Ciphers: Rijndael Serpent Twofish Chaining Modes: XTS CMAC Note: for the cipher algorithms, code has been reused from third parties. Corresponding copyright notices are available in their source code. 2. INSTALLING ============== required packages before installing: - python-setuptools - python-pkg-resources python setup.py install 3. GETTING STARTED =================== Same API from PyCrypto can be used. See: http://www.dlitz.net/software/pycrypto/doc/ Biggest changes are the addition of some chain modes and block ciphers. A lot of examples are provided as docstrings. Have a look at them in '../CryptoPlus/Cipher/*.py' or via an interactive python session by using 'CryptoPlus.Cipher.python_AES.new?'. Once a cipher object is constructed with 'cipher = CryptoPlus.Cipher.python_AES.new(...)' you can get more info about encrypting and decrypting by reading the apprioprate docstring ('cipher.encrypt?','cipher.decrypt?'). Some test functions are provided in the docstrings and in the 'test' folder. Run all the doctests in the new Cipher function by using the '../test/test_doctest.py' script. '../test/test.py' provides some test function for the testvectors available from the module via 'CryptoPlus.Cipher.testvectors'. Have a look at the test.py sourcecode to have an idea of how to use those test vectors. 4. LIMITATIONS =============== CMAC can only be used with ciphers of 64 or 128 bits blocksizes XTS can only be used with ciphers of 128 bits blocksize
Per the documentation at http://packaging.python.org/en/latest/ and http://pythonhosted.org/setuptools/setuptools.html
On line 454 of blockcipher.py, the assertion:
assert len(data) < 128*pow(2,20)
should be
assert len(data) < 16*pow(2,20)
The NIST recommendation reads:
The length of the data unit for any instance of an implementation of XTS-AES shall not exceed
2^20 AES blocks
An AES block is 16 bytes, or 128 bits, and the data in the code at this point is bytes, not bits, so the number 16 should be used, not 128. Or even better, a constant AES_BLK_BYTES
should be created with the value of 16, and all the 16's in this section could be replaced with that constant.
When importing CryptoPlus.Hash
, I get this ImportError: ImportError: No module named 'Crypto.Hash._MD2'
. My pycrypto version is 2.6.1 (more specifically: 2.6.1-4ubuntu0.2 in Ubuntu 14.04).
Caveat: I'm not a crypto expert; I know enough to be dangerous.
I'm attempting to use CryptoPlus.Cipher.AES
to generate a CMAC-AES signature for an OAuth 1.0A Provider implementation. The message is a Unicode object containing a URL-encoded value; the key is a Unicode in hexadecimal format; the resulting cipher is to be base-64 encoded.
from CryptoPlus.Cipher import AES
def sign_cmac_aes(base_string, consumer_secret):
key, message = consumer_secret.decode('hex'), base_string.decode('utf-8')
return AES.new(key, AES.MODE_CMAC).encrypt(message).encode('base64')
The resulting signatures don't match the expected value. Considering the problems this Provider has in general, I'm not overly surprised, but I wanted to get another pair of eyes, perhaps with more experience with the CMAC-AES method being employed. Any thoughts?
Hi everyone,
I installed the library python-cryptoplus (downloaded here https://github.com/doegox/python-cryptoplus) and did python "setup.py install", but i have an error when i want to run IDEA.py.
"C:\Users...\CryptoPlus\Cipher\blockcipher.py, line 23, in from ..Util import util"
ValueError: Attempted relative import in non-package
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.