Commit Graph

39 Commits (add-github-workflows)

Author SHA1 Message Date
Andrew Hutchings fbefe7e7e5 Simplify OAEP and PSS
Makes things a little bit more like similar APIs.

* Hash type is now set in constructor.
* MGF is set automtically or manually with `set_mgf()`
* Label defaults to empty
2022-05-06 13:34:57 +02:00
Andrew Hutchings e34a0ece53 Completely refactor AES GCM
Some bad assumptions were made during the creation of our Python AES GCM
code. This is now modified to be more in-line with other libraries. This
is an API breaking change on unreleased code.

This now allows for aad data to be used, varying length of
authentication tags and fixes a bug for multipart.

1. Now unified to a single class AesGcmStream()
2. Used `encrypt()` and `decrypt()` instead of `update()` to avoid
   confusion over encryption and aad semantics
3. final tag_bytes is configurable in the constructor
4. `set_aad()` added to add the aad data
5. aad data is cleared after first `encrypt()` or `decrypt()` call due
   to quirk in the C API.
6. More tests added
2022-03-07 23:24:23 -08:00
Andrew Hutchings 969681a731 Fix issues causing tox not to run 2022-02-18 00:01:31 -08:00
Andrew Hutchings e58d81533c Ungate constants and gate tests 2022-02-09 14:18:23 +00:00
Andrew Hutchings 863e6836a9 Add RSA OAEP and PSS padding
Functions added:
* `encrypt_oaep(self, plaintext, hash_type, mgf, label)`
* `decrypt_oaep(self, ciphertext, hash_type, mgf, label)`
* `sign_pss(self, plaintext, hash_type, mgf)`
* `verify_pss(self, plaintext, signature, hash_type, mgf)`

Constants added:
* MGF1SHA224
* MGF1SHA256
* MGF1SHA384
* MGF1SHA512
* HASH_TYPE_NONE
* HASH_TYPE_MD2
* HASH_TYPE_MD4
* HASH_TYPE_MD5
* HASH_TYPE_SHA
* HASH_TYPE_SHA224
* HASH_TYPE_SHA256
* HASH_TYPE_SHA384
* HASH_TYPE_SHA512
* HASH_TYPE_MD5_SHA
* HASH_TYPE_SHA3_224
* HASH_TYPE_SHA3_256
* HASH_TYPE_SHA3_384
* HASH_TYPE_SHA3_512
* HASH_TYPE_BLAKE2B
* HASH_TYPE_BLAKE2S
2022-02-03 15:43:04 +00:00
Hayden Roche 726c37e9e7
Merge pull request #33 from danielinux/aes-ctr 2022-02-01 15:43:12 -08:00
Andrew Hutchings 16334bf5e6 Add support for AES GCM streaming 2022-02-01 07:45:21 -08:00
Daniele Lacamera 59a1d5c825 Removed stale comment 2022-02-01 08:37:03 +01:00
Daniele Lacamera 8a514e0f8e Added support for AES-CTR 2022-01-31 13:32:14 +01:00
Andrew Hutchings bd4432b7be Refactor build for better platform support
* Fix some path and compiler things for Windows
* Move source code to align better with Python standards
* Have setup.py build wolfSSL and FFI
* Update Python versions in tox
* Add CMake building for Windows build
* Add missing __init__.py for tox
* Make wolfSSL a git submodule
2022-01-31 00:51:45 -08:00
Daniele Lacamera e8e49f4cb9 Updated wolfcrypt, copyright notes. Add pwdbased on by default. 2022-01-10 21:23:12 +01:00
Hayden Roche 7a847cf9b1 Add signature generation and verification. 2021-12-21 14:35:42 -08:00
Hayden Roche ab332f5869 Add a pem_to_der function and support for PEM RSA keys. 2021-12-20 15:23:04 -08:00
Daniele Lacamera e3968d1932 Adding support for ed448 2021-12-13 13:40:12 +01:00
Hayden Roche b79527f876 Make wolfcrypt-py work with FIPS ready and other improvements.
- Detect ECC timing resistance and call wc_ecc_set_rng where appropriate.
- Detect FIPS version and use that information to figure out how to map hash
enum values (see _TYPE_SHA and friends).
- Don't call wc_HmacSetKey in the _Hmac constructor if the key passed to _init
is length 0. This can happen, for example, when the _Hmac object is being
copied. The copy operation copies over the raw memory from the underlying C
object, so it's not important that we call wc_HmacSetKey in this case.
- Removed a unit test that expected importing an ECC public key from a private
key to fail. This does fail in the default wolfSSL version for wolfcrypt-py,
v4.1.0-stable, but we added the feature to be able to import public from
private with wolfSSL PR #2916. As a result, this test fails with v4.8.1-stable.
We should upgrade wolfcrypt-py's default wolfSSL version (and the wolfcrypt-py
version itself) in the near future.
- The array slicing in test_key_encoding was wrong in many places. This likely
stemmed from the author thinking slices were inclusive, but that's only true
for the first element of the slice (e.g. [0:31] is elements 0-30 inclusive, not
elements 0-31 inclusive). This was uncovered by testing with FIPS ready, which
adds -DWOLFSSL_VALIDATE_ECC_IMPORT, causing us to check ECC keys with
wc_ecc_check_key. wc_ecc_check_key kept saying, "hey, that point's not on the
curve." The array slicing problem was the culprit.
- Fixed tests that were doing HMAC with a key less than HMAC_FIPS_MIN_KEY.
2021-09-16 12:55:47 -07:00
Hayden Roche 2d7c43714e Add module pwdbased.py and expose wc_PBKDF2. 2021-02-25 16:40:30 -06:00
Hayden Roche 46b6d6ac0b Add support for RSA private keys in PKCS #8 format. 2021-01-21 10:53:36 -06:00
Daniele Lacamera 6954491dbd Fixed arguments in Chacha.set_iv(nonce, counter=0) 2020-06-18 10:01:28 +02:00
Daniele Lacamera 1852a13c7f Added support for ChaCha stream cipher 2020-06-09 16:47:17 +02:00
David Garske 7181c60f7a
Merge pull request #10 from cconlon/copyright2020
update copyright to 2020
2020-03-30 06:29:47 -07:00
Daniele Lacamera 0b4cbfcb4d Added support for SHA3 2020-01-07 20:02:50 +01:00
Chris Conlon e7601183c4 update copyright to 2020 2020-01-03 16:29:04 -08:00
Chris Conlon 8aeb58df62 feature detection for RSA keygen, line length cleanup 2019-09-24 15:06:50 -06:00
Chris Conlon 606ead172a native feature detection for wolfSSL algorithms, cffi cleanup 2019-09-24 14:38:42 -06:00
Daniele Lacamera 44b5002dfe [RSA] New methods:
- .make_key()
- .encode_key()
2019-09-03 18:40:42 +02:00
Daniele Lacamera effb3b621a Added ecc_sign_raw and ecc_verify_raw + test cases
ECC signature can be represented in its raw element R,S
2019-04-16 20:32:47 +02:00
David Garske 5e9d6d7bec
Merge pull request #3 from danielinux/ed25519-pubkey
Ed25519Private: change to handle public keys
2019-04-15 15:24:51 -07:00
Daniele Lacamera 80124da3c7 Added methods for ECC key handling via raw elements
* EccPrivate.decode_key_raw()
* EccPrivate.encode_key_raw()
* EccPublic.decode_key_raw()
* EccPublic.encode_key_raw()
2019-04-05 16:17:43 +02:00
Daniele Lacamera 2e4e2db493 Ed25519Private can now handle public keys 2019-04-04 14:57:31 +02:00
Daniele Lacamera 94c39551d4 Fixed Hmac types, fixed wolfSSL version 2019-03-27 18:09:26 +01:00
Daniele Lacamera afcbe851d6 Added Ed25519 cipher + tests 2019-03-27 15:37:24 +01:00
Moisés Guimarães 07b547b80c updates docs 2018-03-19 22:07:53 +01:00
Moisés Guimarães f706b1c4b5 maxes code coverage 2018-02-26 23:20:44 +01:00
Moisés Guimarães b2d93c219c adds ecc api mapping and tests 2018-02-26 20:19:33 +01:00
Moisés Guimarães b4556ba294 updates copyright and fixes docs 2018-01-08 16:04:27 -03:00
Moisés Guimarães f232680c54 fixes flake8 issues 2018-01-08 15:11:59 -03:00
Moisés Guimarães 69d21052f1 updates copyright year 2017-12-19 13:47:02 -03:00
Moisés Guimarães 640041c285 migrates tests to py.test 2017-12-18 15:24:28 -03:00
Moisés Guimarães 71e205943f moving files to wolfcrypt-py 2017-12-11 17:27:41 -03:00