The following custom exceptions are replaced with ValueError:
* Crypto.Util.PaddingError
* Crypto.PublicKey.KeyFormatError
The custom Crypto.Util.asn1.NoDerElementError is now private to the
module.
Some white spaces have been removed.
The following changes are included:
- Decoding is a much simpler operation. The internal
logic is based on stream of binary data, and not
on string indexing anymore. Additionally,
decoding used to look like this:
bitmap = DerObject()
bitmap.decode(input_buffer, True)
if bitmap.isType('BIT STRING'):
... proceed with parsing ...
else:
... error ...
Whereas now, it is cleaner and more compact:
bitmap = DerBitString()
bitmap.decode(input_buffer)
Any error condition will lead to an exception.
- isType() method has been removed because of the above.
- Added examples and documentation
- Added support IMPLICIT tags
- Added support for negative INTEGERs
- Added DerSetOf ASN.1 class
- DerObjectID can be initialized from the dotted representation of
the Object ID.
- DerBitString has a new member 'value' to hold the binary
string. The member 'payload' should not be accessed anymore.
- DerObjectID has a new member 'value' to hold the dotted representation
of the Object ID string. The member 'payload' should not be accessed
anymore.
- Added operator += to DER SEQUENCE. Now it is possible to do:
my_str = DerOctetString(b'ZYZ')
seq = DerSequence()
seq += 0
seq += my_str.encode()
- Update to test cases
o _fastmath now builds and runs on PY3K
o Changes to setup.py to allow /usr/include for gmp.h
o Changes to setup.py to allow linking fastmath w/ static mpir
on Windows without warning messages
o Changes to test_DSA/test_RSA to throw an exception if _fastmath
is present but cannot be imported (due to an issue building
_fastmath or the shared gmp/mpir libraries not being reachable)
o number.py has the code to flag a failing _fastmath, but that
code is commented out for a better runtime experience
o Clean up the if for py21compat import - should have been == not is
o Clean up some '== None' occurences, now 'is None' instead
Typical usage for importing an RSA key:
f = file("ssl.pem")
key = RSA.importKey(f.read())
f.close()
key.verify(hash, signature)
Typical usage for exporting an RSA public key:
key = RSA.generate(512, randfunc)
f = file("ssl.der","w")
f.write(key.publickey.exportKey('DER'))
f.close()
I confirm I am eligible for submitting code to pycrypto according
to http://www.dlitz.net/software/pycrypto/submission-requirements/
fetched on 27 December 2009.
Committer: Legrandin <gooksankoo@hoiptorrow.mailexpire.com>