Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Not all XML serialisers write namespaces in same orderArthur de Jong2017-12-291-6/+6
| | | | | | This ignores the namespace declarations in the generated XML files because not all implementations on all environments write these in the same order.
* Add an is_encrypted propertyArthur de Jong2017-12-271-0/+8
| | | | | | This property can be use to see whether the PSKC file needs an additional pre-shared key or passphrase to decrypt any stored information.
* Implement signature checkingArthur de Jong2017-12-2711-7/+390
| | | | | | | | | | | | | | | This adds support for creating and verifying embedded XML signatures in PSKC files. This uses the third-party signxml library for actual signing and verification. The signxml library has a dependency on lxml and defusedxml (and a few others) but all parts of python-pskc still work correctly with our without lxml and/or defusedxml and signxml is only required when working with embedded signatures. This modifies the tox configuration to skip the signature checks if singxml is not installed and to only require 100% code coverage if the signature tests are done.
* Implement basic parsing of signature propertiesArthur de Jong2017-12-272-1/+25
|
* Fix typo in pin_max_failed_attempts attributeArthur de Jong2017-12-182-1/+20
| | | | | This makes the old name (pin_max_failed_attemtps) available as a deprecated property.
* Add limited support for very old draft PSKC versionsArthur de Jong2017-12-155-0/+353
| | | | | | | | | | | | This adds basic support for parsing the PSKC files as specified in draft-hoyer-keyprov-portable-symmetric-key-container-00 and draft-hoyer-keyprov-portable-symmetric-key-container-01. It should be able to extract secrets, counters, etc. but not all properties from the PSKC file are supported. It is speculated that this format resembles the "Verisign PSKC format" that some applications produce.
* Add test files from multiOTPArthur de Jong2017-12-1511-0/+2012
| | | | | | | This adds tests for parsing the files that are shipped as part of the multiOTP test suite. https://www.multiotp.net/
* Refactor internal storate of encrypted valuesArthur de Jong2017-12-153-3/+34
| | | | | | | | | | | This changes the way encrypted values are stored internally before being decrypted. For example, the internal _secret property can now be a decrypted plain value or an EncryptedValue instance instead of always being a DataType, simplifying some things (e.g. all XML encoding/decoding is now done in the corresponding module). This should not change the public API but does have consequences for those who use custom serialisers or parsers.
* Add support for KW-Camellia suite of algorithmsArthur de Jong2017-12-134-0/+117
|
* Add support for Camellia-CBC suite of algorithmsArthur de Jong2017-12-134-0/+147
|
* Replace pycrypto with cryptographyArthur de Jong2017-10-092-77/+6
| | | | | | | | | The cryptography library is better supported. This uses the functions from cryptography for AES and Triple DES encryption, replaces the (un)padding functions that were previously implemented in python-pskc with cryptography and uses PBKDF2 implementation from hashlib.
* Replace use of pycrypto utility functionsArthur de Jong2017-10-012-6/+6
| | | | | | This uses os.urandom() as a source for random data and replaces other utility functions. This also removes one import for getting the lengths of Tripple DES keys.
* Implement our own XML formattingArthur de Jong2017-09-251-8/+8
| | | | | | This avoids a using xml.dom.minidom to indent the XML tree and keep the attributes ordered alphabetically. This also allows for customisations to the XML formatting.
* Support hashlib from Python 2.7.3Arthur de Jong2017-09-241-1/+4
| | | | | Some Python versions don't have the algorithms_available property but do have the algorithms property in hashlib.
* Fix bug in saving PBKDF2 salt on Python3Arthur de Jong2017-09-241-2/+20
| | | | | | | The PBKDF2 salt was saved in the wrong way (b'base64encodeddata' instead of base64encodeddata) when using Python 3. This fixes that problem and tests that saving and loading of a file that uses PBKDF2 key derivation works.
* Add tests for the pskc2csv scriptArthur de Jong2017-09-241-0/+185
| | | | | This makes minor changes to the pskc2csv script to make it more easily testable.
* Provide Key.userid convenience propertyArthur de Jong2017-06-101-4/+4
| | | | | This provides a read-only userid property on Key objects that uses the key_userid or device_userid value, whichever one is defined.
* Refactor MAC lookupsArthur de Jong2017-06-092-1/+137
| | | | | | | | This switches to using the hashlib.new() function to be able to use all hashes that are available in Python (specifically RIPEMD160). This also adds a number of tests for HMACs using test vectors from RFC 2202, RFC 4231 and RFC 2857.
* Correct name of ActivIdentity test fileArthur de Jong2017-01-212-1/+1
|
* Split vendor testsArthur de Jong2017-01-152-27/+55
| | | | Have one doctest file per vendor to make tests a little more manageable.
* Add tests for Yubikey filesArthur de Jong2017-01-154-0/+295
| | | | This adds tests from draft-josefsson-keyprov-pskc-yubikey-00.
* Support legacy ActivIdentity filesArthur de Jong2017-01-152-0/+96
| | | | | | This adds support for parsing ActivIdentity files that conform to a very old version of an Internet Draft. The implementation and test were based on a file provided by Jaap Ruijgrok.
* Use original examples from old profiles Internet DraftArthur de Jong2017-01-114-125/+121
| | | | | | | | | | | | | This updates the tests to use the original examples from draft-hoyer-keyprov-pskc-algorithm-profiles-01 instead of modifying them to fit the RFC 6030 schema (but does include some minor changes to make them valid XML). This adds a few additions to the parser to handle legacy challenge and resposne encoding and a few key policy properties. This also includes a fix for 0b757ec in the handling of the <ChallengeFormat> element under a <Usage> element.
* Add all figures from RFC 6030 to test suiteArthur de Jong2016-12-213-10/+191
| | | | Note that asymmetric encryption and digital signature checking has not yet been implemented so the tests are pretty minimal.
* Add support for older Internet Draft versionArthur de Jong2016-12-219-0/+787
| | | | | | | | | | | | | | This adds support for parsing most examples from draft-ietf-keyprov-pskc-02. That file uses a few other names for elements and attributes of the PSKC file and a few other minor differences. The XML parsing has been changed to allow specifying multiple matches and the find*() functions now return the first found match. While all examples from draft-ietf-keyprov-pskc-02 are tested support for verifying digital signatures and asymmetric keys have not yet been implemented.
* Fix typo in testArthur de Jong2016-12-201-4/+4
|
* Allow MAC over plaintext or ciphertextArthur de Jong2016-12-206-75/+71
| | | | | | | | | | | | | | | | | | RFC 6030 implies that the MAC should be performed over the ciphertext but some earlier drafts implied that the MAC should be performed on the plaintext. This change accpets the MAC if either the plaintext or ciphertext match. Note that this change allows for a padding oracle attack when CBC encryption modes are used because decryption (and unpadding) needs to be done before MAC checking. However, this module is not expected to be available to users to process arbitrary PSKC files repeatedly. This removes the tests for a missing MAC key (and replaces it for tests of missing EncryptionMethod) because falling back to using the encryption key (implemented in a444f78) in combination with this change means that decryption is performed before MAC checking and is no longer possible to trigger a missing MAC key error.
* Add sanity checks to unpaddingArthur de Jong2016-12-201-0/+76
|
* Close read files in testsArthur de Jong2016-12-191-2/+4
| | | | | This ensures that the files that are read in the test suite are properly closed to avoid leaking open file descriptors.
* Support separate device from keyArthur de Jong2016-09-172-3/+67
| | | | | | | | This allows having multiple keys per device while also maintaining the previous API. Note that having multiple keys per device is not allowed by the RFC 6030 schema but is allowed by some older internet drafts.
* Some minor improvements to the testsArthur de Jong2016-09-143-2/+18
|
* Improve branch coverageArthur de Jong2016-09-1410-11/+273
| | | | This enables branch coverage testing and adds tests to improve coverage.
* Support specifying PRF in setup_pbkdf2()Arthur de Jong2016-09-111-2/+6
| | | | This also ensures that the PRF URL is normalised.
* Fall back to encryption key for MACArthur de Jong2016-04-234-0/+97
| | | | | | This uses the encryption key also as MAC key if no MAC key has been specified in the PSKC file. Earlier versions of the PSKC draft specified this behaviour.
* Allow global specification of IVArthur de Jong2016-04-232-0/+49
| | | | | | In older versions of the PSKC standard it was allowed to have a global initialization vector for CBC based encryption algorithms. It is probably not a good idea to re-use an IV in general.
* Add encryption error testsArthur de Jong2016-03-261-0/+74
|
* Add tests for writing encrypted PSKC filesArthur de Jong2016-03-261-0/+175
|
* Allow configuring PBKDF2 key derivationArthur de Jong2016-03-261-0/+58
| | | | | This factors out the PBKDF2 key derivation to a separate function and introduces a function to configure KeyDerivation instances with PBKDF2.
* Allow configuring a MAC keyArthur de Jong2016-03-261-0/+27
| | | | | This method will set up a MAC key and algorithm as specified or use reasonable defauts.
* Write encryption key informationArthur de Jong2016-03-261-0/+4
| | | | | | This writes information about a pre-shared key or PBKDF2 key derivation in the PSKC file. This also means that writing a decrypted version of a previously encrypted file requires actively removing the encryption.
* Add algorithm_key_lengths propertyArthur de Jong2016-03-261-0/+11
| | | | | This property on the Encryption object provides a list of key sizes (in bytes) that the configured encryption algorithm supports.
* Also check key expiry in may_use()Arthur de Jong2016-03-233-10/+26
|
* Support writing to text streams in Python 3Arthur de Jong2016-03-191-3/+1
| | | | | This supports writing the XML output to binary streams as well as text streams in Python 3.
* Improve tests and test coverageArthur de Jong2016-03-1912-54/+162
| | | | | | | | | | This adds tests to ensure that incorrect attribute and value types in the PSKC file raise a ValueError exception and extends the tests for invalid encryption options. This removes some code or adds no cover directives to a few places that have unreachable code or are Python version specific and places doctest directives inside the doctests where needed.
* Support both CheckDigit and CheckDigitsArthur de Jong2016-03-192-0/+75
| | | | | | RFC 6030 is not clear about whether the attribute of ChallengeFormat and ResponseFormat should be the singular CheckDigit or the plural CheckDigits. This ensures that both forms are accepted.
* Implement policy checkingArthur de Jong2016-03-192-0/+122
| | | | | This checks for unknown policy elements in the PSKC file and will cause the key usage policy check to fail.
* Add a few tests for vendor filesArthur de Jong2016-03-194-0/+434
| | | | | Some vendor-specific files were lifted from the LinOTP test suite and another Feitian file was found in the oath-toolkit repository.
* Support various integer representationsArthur de Jong2016-03-192-1/+56
| | | | | | | | | | | | | | | | | | | This extends support for handling various encoding methods for integer values in PSKC files. For encrypted files the decrypted value is first tried to be evaluated as an ASCII representation of the number and after that big-endian decoded. For plaintext values first ASCII decoding is tried after which base64 decoding is tried which tries the same encodings as for decrypted values. There should be no possibility for any base64 encoded value (either of an ASCII value or a big-endian value) to be interpreted as an ASCII value for any 32-bit integer. There is a possibility that a big-endian encoded integer could be incorrectly interpreted as an ASCII value but this is only the case for 110 numbers when only considering 6-digit numbers.
* Re-organise test filesArthur de Jong2016-01-3034-32/+32
| | | | | This puts the test PSKC files in subdirectories so they can be organised more cleanly.
* Add test for incorrect key derivationArthur de Jong2016-01-301-0/+10
| | | | | If no key derivation algorithm has been specified in the PSKC file an exception should be raised when attempting to perform key derivation.