Commit Graph

202 Commits (add-github-workflows)

Author SHA1 Message Date
Andrew Hutchings 3773979a36 Remove Travis CI 2022-05-12 16:16:30 +01:00
Andrew Hutchings 443dffc629
Create python-app.yml 2022-05-12 15:57:45 +01:00
Andrew Hutchings 1b6d6d76a1 Update to 5.3.0 2022-05-06 13:40:50 +02:00
Andrew Hutchings b9072e60c6 Add get_aad() function 2022-05-06 13:34:57 +02:00
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 7482e9d20f Don't use submodule if env var is set 2022-02-18 00:01:31 -08:00
Andrew Hutchings b602083429 Fix build recursion issue
Windows had an issue where it was trying to build the CFFI module after
it had already imported the CFFI module. Which caused permissions
errors during builds.

This fix does several things to make the Windows build work properly and
improve the Linux build too:

* The CFFI module is only build when needed, not as part of an sdist
  package
* Version numbering spilt out into separate file so __init__.py import
  is not required
* Merged _build_ffi.py and _build_wolfssl.py into one file
* Made CFFI only build when called as an executable (which happens
  during binary build time)
* Make tox use bdist-wheel instead of sdist
2022-02-18 00:01:31 -08:00
Hayden Roche 744a49e5a7
Merge pull request #36 from LinuxJedi/rsa-padding 2022-02-09 12:00:47 -08:00
Andrew Hutchings 013c1e6987 Gate RSA variables in ciphers.py 2022-02-09 17:51:43 +00:00
Andrew Hutchings e58d81533c Ungate constants and gate tests 2022-02-09 14:18:23 +00:00
Hayden Roche cdba0c7847
Merge pull request #38 from LinuxJedi/docs-members 2022-02-08 11:11:05 -08:00
Andrew Hutchings 3327d9ae39 Cleanup PSS constants and build
* Use constants from wolfSSL instead of copying them
* Add build gate for PSS
* Fix indentation
2022-02-08 17:56:48 +00:00
Andrew Hutchings c28704f22c Fix missing class members from docs
Inherited class members were missing from class documentation. Most
classes rely on these so this makes them visible in the docs.
2022-02-08 16:26:30 +00:00
Andrew Hutchings 501c269979 Fix AES_CTR breaking Windows builds
5.1.1 doesn't have a CMake option for this, so we do it the hard way for
  now.
2022-02-03 16:13:39 +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
Andrew Hutchings cbbe08b256 Minor fixups to tox
1. sdist based build/test works now. Better to use that.
2. switch to py3 instead of py39 to better suit older versions.
3. remove pep8 testing for now, some more work needed for that.
2022-01-31 23:42:45 -08:00
Daniele Lacamera 59a1d5c825 Removed stale comment 2022-02-01 08:37:03 +01:00
Andrew Hutchings c7125b04b1 Fix sdist and packaging
wolfcrypt was not being packaged in the sdist and the build system did
not work if the source wasn't a git checkout. Both fixed.
2022-01-31 04:34:03 -08: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 40a6da2b1b
Merge pull request #30 from haydenroche5/fipsv5
Call wolfCrypt_SetPrivateKeyReadEnable_fips at init, if necessary.
2022-01-25 01:44:19 -08:00
Hayden Roche 4c59f4fb72 Call wolfCrypt_SetPrivateKeyReadEnable_fips at init, if necessary.
This is another FIPS v5 change. This function needs to be called before we can
do private key ops with the new FIPS module.
2022-01-24 13:38:30 -08:00
Daniele Lacamera d2668d507a
Merge pull request #29 from haydenroche5/fipsv5
Call wc_SetSeed_Cb in __init__.py if needed.
2022-01-24 01:52:13 -08:00
Hayden Roche c4bba33ab3 Call wc_SetSeed_Cb in __init__.py if needed.
When using wolfCrypt FIPS v5 with an application (e.g. wolfcrypt-py), the
application needs to set an RNG seed generation callback with wc_SetSeed_Cb.
This can simply be wc_GenerateSeed. This commit adds code to __init__.py
to do just that.
2022-01-20 19:29:33 -08:00
Hayden Roche 2916871003
Merge pull request #28 from danielinux/version-up-pwdbased-on 2022-01-18 08:29:50 -08:00
Daniele Lacamera e8e49f4cb9 Updated wolfcrypt, copyright notes. Add pwdbased on by default. 2022-01-10 21:23:12 +01:00
Daniele Lacamera 5da42db7a9 wolfCrypt version update, enabled pwdbased by default 2022-01-10 21:23:12 +01:00
Daniele Lacamera 9c57867f5e
Merge pull request #27 from haydenroche5/signature
Add signature generation and verification.
2022-01-04 10:13:20 -08:00
Hayden Roche 7a847cf9b1 Add signature generation and verification. 2021-12-21 14:35:42 -08:00
Daniele Lacamera 10ba23046b
Merge pull request #26 from haydenroche5/pem
Add a pem_to_der function and support for PEM RSA keys.
2021-12-21 03:25:32 -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
David Garske 7900cf7dc0
Merge pull request #25 from danielinux/ed448
Adding support for ed448
2021-12-13 09:44:50 -08:00
Daniele Lacamera e3968d1932 Adding support for ed448 2021-12-13 13:40:12 +01:00
Daniele Lacamera e5a2bbe738
Merge pull request #24 from haydenroche5/fips
Make wolfcrypt-py work with FIPS ready and other improvements.
2021-09-27 10:18:06 -07: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
Daniele Lacamera 8ed0316993
Merge pull request #23 from haydenroche5/fips
Modify hashes.py to use correct hash type values when FIPS is enabled.
2021-07-14 06:37:02 -07:00
Hayden Roche 5598580b1b Modify hashes.py to use correct hash type values when FIPS is enabled. 2021-07-12 15:25:40 -07:00
Daniele Lacamera 3569c39d35
Merge pull request #22 from haydenroche5/rsa_blinding
Added detection of FIPS and RSA blinding. Fixed wc_PBKDF2.
2021-07-08 22:56:57 -07:00
Hayden Roche 812d359700 Make several improvements.
- Refactor the feature detection section of _build_ffi.py to be more Pythonic.
- Add detection of FIPS and RSA blinding. Don't enable RSA blinding if FIPS is
enabled. Full-fledged FIPS checks for other features are not included; this just
helps with RSA blinding, for now. Use this to determine if wc_RsaSetRNG is
available.
- Change the various *_ENABLED variables to have extern, since they're
declared in a header and initialized in a source file.
- Add a missing include of pwdbased.h to provide the declaration of wc_PBKDF2.
2021-07-01 14:57:59 -07:00
Chris Conlon 270a7903eb
Merge pull request #20 from haydenroche5/PBKDF2
Add module pwdbased.py and expose wc_PBKDF2.
2021-02-25 15:49:14 -07:00
Hayden Roche 2d7c43714e Add module pwdbased.py and expose wc_PBKDF2. 2021-02-25 16:40:30 -06:00
Hayden Roche 4d03ebbf9c
Merge pull request #21 from cconlon/rmpython2.7
remove python 2.7 from make/osx scripts
2021-02-25 10:03:42 -06:00
Chris Conlon a3c809d585 remove python 2.7 from make/osx scripts 2021-02-24 09:50:44 -07:00
Chris Conlon 4d8e4a3dd5
Merge pull request #19 from haydenroche5/RsaPrivate
Add support for RSA private keys in PKCS #8 format.
2021-01-21 15:49:28 -07:00
Hayden Roche 46b6d6ac0b Add support for RSA private keys in PKCS #8 format. 2021-01-21 10:53:36 -06:00
Chris Conlon 78ee7f77ec
Merge pull request #16 from ejohnstown/update-build
Modernize
2020-11-05 17:15:43 -07:00