Commit Graph

18 Commits (a59a4f8b965c8ad42c6af95c80fc3873e77cd0cc)

Author SHA1 Message Date
sebastian-carpenter a59a4f8b96 update license to GPLv3 2026-07-09 18:24:23 +02:00
Robert de Vries 747243cc50 Address more review comments.
Tests are now also type checked as this helps verifying the correctness
of the type annotations.
2026-07-06 22:02:48 +02:00
Robert de Vries 7edbd3e45c Enable more ruff rules requiring only minor or no fixes.
Extra rules:
All E pycodestyle error rules
C4   flake8-comprehensions
DTZ  flake8-datetimez
EXE  flake8-executable
FA   flake8-future-annotations
INT  flake8-gettext
ISC  flake8-implicit-str-concat
ICN  flake8-import-conventions
LOG  flake8-logging
G    flake8-logging-format
RSE  flake8-raise
SLOT flake8-slots
TID  flake8-tidy-imports
TC   flake8-type-checking
FLY  flynt
PERF Perflint
W    pycodestyle warnings
FURB refurb

Ignore E501:  line too long
2026-07-04 16:54:56 +02:00
Juliusz Sosinowicz 2ecf721695 Reject unsafe HMAC copy() (F-5428)
_Hmac inherited _Hash.copy(), which - lacking a wolfCrypt copy function
for Hmac - fell back to a byte-level memmove and returned an object
marked _shallow_copy that aliases the original's internal C state. In
async or hardware-accelerated builds those internal pointers are shared,
so freeing the original leaves the copy with stale state
(use-after-free, wrong MACs, or corruption). wolfCrypt exposes no safe
public Hmac copy, so override copy() to raise NotImplementedError.
digest()/hexdigest() are unaffected. Update the shared hash tests to
expect this for HMAC.
2026-06-23 12:43:03 +00:00
Jeremiah Mackey 664e887f09 Fix hash copy semantics and add tests 2026-04-16 14:34:26 +00:00
Robert de Vries 2f630a4353 Clean up import statements.
* Remove unused imports.
* Move import statements together at the top of the file.
2026-04-09 20:02:01 +02:00
Daniele Lacamera e8e49f4cb9 Updated wolfcrypt, copyright notes. Add pwdbased on by default. 2022-01-10 21:23: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
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 606ead172a native feature detection for wolfSSL algorithms, cffi cleanup 2019-09-24 14:38:42 -06:00
Daniele Lacamera 94c39551d4 Fixed Hmac types, fixed wolfSSL version 2019-03-27 18:09:26 +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