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
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
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
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.
* 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
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.
- 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.
- 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.