Commit graph

36 commits

Author SHA1 Message Date
Helder Eijs
4679c5e5ef Reject DER objects if length has leading zero 2019-03-18 21:20:21 +01:00
Helder Eijs
92cc11cdf2 Support for 0 value in OID path 2019-03-04 23:16:18 +01:00
Michael Nix
81cdf9ec4d make function signature compatible with supertype
The type checker flagged several decode() methods as not compatible with its supertype, since the strict parameter was missing or in the wrong place.
2018-11-24 21:34:51 +01:00
Helder Eijs
cd7f0128b6 Make code base suitable for Python 2 and 3 - stop using 2to3 2018-11-04 15:04:23 +01:00
Helder Eijs
8f6b6757c6 Small ASN.1 code cleanup 2018-04-12 22:16:53 +02:00
Helder Eijs
75c4f8359d Added Wycheproof tests for DSA 2018-04-12 14:13:12 +02:00
Helder Eijs
5f87e3193a Refinement to new API docs 2017-08-20 15:00:58 +02:00
Helder Eijs
c2dcf73212 Added Util and Crypto to new API docs 2017-08-20 01:09:51 +02:00
Legrandin
ca4b9ec301 First ECC key being imported 2016-01-26 04:47:29 -05:00
Legrandin
a53023c304 Simplify RSA and DSA import 2016-01-23 21:33:50 +01:00
Legrandin
707b2bb81f Add check for SEQUENCEs containing only INTEGERs 2016-01-23 20:45:52 +01:00
Legrandin
a58e6e53a6 DerSequence.decode checks number of elements 2016-01-23 20:45:37 +01:00
Legrandin
ab759b3936 Remove the need to consider EOFError when parsing DER 2016-01-23 20:45:28 +01:00
Legrandin
78d51d0b2e Make Crypto.Util.asn1 more PEP8 compliant 2016-01-23 20:45:16 +01:00
Legrandin
3e185c286e Remove remaining Crypto.Util.asn1.newDer* 2016-01-23 20:44:54 +01:00
Legrandin
718501e42a Remove Crypto.Util.asn1.newDerBitString 2016-01-23 20:44:40 +01:00
Legrandin
820176457b Remove Crypto.Util.asn1.newDerSequence 2016-01-23 20:44:33 +01:00
Legrandin
9e2233db9e DerSequence can automatically encode Der objects 2016-01-23 20:44:26 +01:00
Legrandin
12b75141c4 Minor simplification to DER decoding code 2015-03-18 08:42:04 +01:00
Legrandin
ec7f3c8662 Remove _fastmath and _slowmath from code base 2014-12-06 12:04:12 +01:00
Legrandin
213c171550 Add EXTERNAL tags for INTEGERs 2014-07-15 23:01:34 +02:00
Legrandin
d83380a048 Removed support for Python<2.4 2014-06-16 20:36:35 +02:00
Legrandin
4bf7577338 Remove a few custom exception types.
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.
2014-03-04 22:04:34 +01:00
Legrandin
5a0ee14e99 Refactoring of the asn1 module
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
2013-07-14 21:16:46 -07:00
Dwayne Litzenberger
20cf8add93 asn1: Python 2.1 compatibility 2013-02-16 11:14:09 -08:00
Dwayne Litzenberger
f3135db3fa asn1: make DerObject into a new-style class 2013-02-16 09:43:56 -08:00
Legrandin
8390495a9d Further fixed for python 3 2011-10-19 23:02:58 +02:00
Legrandin
c22fa18c0d Merged from upstream (py3k support) and modified so that all unit tests pass. 2011-10-18 23:20:26 +02:00
Legrandin
075f0726aa Added isType() method, ability to initialize an object with a payload, DerObjectId object. 2011-10-11 23:53:43 +02:00
Legrandin
2980aa475f Add DerNull and DerOctetString 2011-02-03 01:35:59 +01:00
Legrandin
1221bebb3e Pure tab-to-space conversion with :retab in vim. 2011-01-16 22:05:54 +01:00
Legrandin
e74df2ad6a Added DocStrings to all DER classes.
DerInteger.decode raises an exception if no INTEGER tag is found.
2011-01-13 00:22:58 +01:00
Thorsten Behrens
cb48387f66 PY3K _fastmath support
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
2010-12-29 13:21:05 -05:00
Thorsten Behrens
295ce314d9 Changes to allow pycrpyto to work on Python 3.x as well as 2.1 through 2.7 2010-12-28 16:26:52 -05:00
Legrandin
902ea14fc2 Support for older versions of python
This patch add support for older python 2.1/2.2 to the previous one (DER/PEM).

Committer: Legrandin <gooksankoo@hoiptorrow.mailexpire.com>
2010-08-02 16:34:53 -04:00
Legrandin
0f45878cef Add ability to export and import RSA keys in DER and PEM format.
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>
2010-08-02 16:34:13 -04:00