Commit Graph

418 Commits (d1ac3d5f37b15ec825e6a3dc4c2d4396e83058c2)

Author SHA1 Message Date
Robert de Vries d1ac3d5f37 Add typing: asn, exceptions, hashes, hkdf, pwdbased, utils. 2026-07-06 22:02:46 +02:00
David Garske 257151a82c
Merge pull request #127 from roberthdevries/enable-more-ruff-checks
Enable more ruff rules requiring only minor or no fixes.
2026-07-06 08:19:19 -07:00
David Garske b370c19fd9
Merge pull request #136 from roberthdevries/re-instate-coverage-test
Reinstate the possibility to run coverage tests using make cov.
2026-07-06 08:08:44 -07:00
Robert de Vries ba7f942657 Reinstate the possibility to run coverage tests using make cov. 2026-07-05 16:35:30 +02:00
Robert de Vries fe648f183b Remove obsolete boiler plate comment from the ruff example configuration. 2026-07-04 16:54:59 +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
David Garske c69d2f1eea
Merge pull request #134 from mjdemilliano/prepare-v5.9.2
Prepare for v5.9.2 release
2026-07-02 16:42:48 -07:00
David Garske 17aa8b6c6c
Merge pull request #128 from julek-wolfssl/fenrir/20260623
Fenrir fixes (2026-06-23)
2026-07-02 16:20:26 -07:00
Martijn de Milliano 38c541ab42 ML-DSA: Move check on signing/verifying without context to top
This makes it more clear what the requirements for calling this
function are and avoids unnecessary computations for objects
which are not used.
2026-07-02 13:21:58 +02:00
Martijn de Milliano 8f214f77cd Update changelog 2026-07-02 08:29:17 +02:00
Martijn de Milliano fbe650ac8e Fix typo in comment 2026-07-01 08:13:51 +02:00
Martijn de Milliano 9cf73e0c42 Update skip reason for test_encrypt_short_tag 2026-06-30 18:55:36 +02:00
Martijn de Milliano c0803d0c66 Update ML-KEM and ML-DSA feature selection + detection 2026-06-30 18:53:45 +02:00
lealem47 5a4d8d2053
Merge pull request #129 from sebastian-carpenter/no-max-dep-version
modify version bounds for dependencies
2026-06-30 08:40:55 -06:00
Martijn de Milliano 319c9200ff Prepare for v5.9.2 release 2026-06-30 16:33:18 +02:00
Martijn de Milliano 28b0c9a6bf Process review comments on test_encrypt_short_tag 2026-06-30 16:25:51 +02:00
David Garske c1c06c59f5
Merge pull request #132 from roberthdevries/fix-const-in-func-defs
Fix some function definitions to match const-ness as defined in headers.
2026-06-29 17:32:18 -07:00
Martijn de Milliano c4d926950c AES-GCM stream tests
Test response by library explicitly when called with unsupported
number of tag bytes.
2026-06-29 18:41:17 +02:00
Martijn de Milliano 0466adbf1b ML-DSA: Add missing test cases
- Test signing with empty context
- Test deterministic signing with context
2026-06-29 18:41:17 +02:00
Martijn de Milliano afcebbf946 Rename flag to ML_DSA_NO_CTX_ENABLED 2026-06-29 18:41:17 +02:00
Martijn de Milliano 408ac74e9a Move MIN_AUTH_TAG_SZ next to AES-GCM-stream
This place is more logical
2026-06-29 18:41:01 +02:00
Robert de Vries 9e84d054d1 Fix some function definitions to match const-ness as defined in headers. 2026-06-27 22:09:34 +02:00
Martijn de Milliano f8e56cd063 ML-DSA: fix ML_DSA_NO_CTX detection and add to default features
Also detect WOLFSSL_DILITHIUM_FIPS204_DRAFT as implying no-ctx support,
mirroring the logic in dilithium.h. Add ML_DSA_NO_CTX to the default
features dict for consistency with peer flags.
2026-06-26 00:35:32 +02:00
Martijn de Milliano fc5ea53605 Update AESGCM test
Read minimum supported tag size from settings and make the
test less ambiguous.
2026-06-26 00:31:05 +02:00
Martijn de Milliano aec3f2d553 Add tests for no-context signing 2026-06-26 00:10:34 +02:00
Martijn de Milliano 8d87cb4d13 ML-DSA: fix wording of message and docstrings 2026-06-26 00:05:15 +02:00
sebastian-carpenter dbb21f3a99 modify version bounds for dependencies
* Remove bound for maximum version
 * Synchronize minimum version for cffi to 1.17
2026-06-24 12:07:02 -06:00
Juliusz Sosinowicz b13aeea62b Address Copilot review on wolfcrypt-py (F-4015, F-4463)
- ChaCha.set_iv(): only mark _iv_set after _set_key() succeeds, and clear
  it first, so a failed re-key cannot leave encrypt()/decrypt() unblocked
  with a stale or partially-applied IV. Add a regression test.
- Update _Cipher.new()/encrypt()/decrypt() docstrings that still referred
  to CFB/segment-size behavior to match the actually supported modes
  (MODE_CBC, MODE_CTR) and their IV requirements.
2026-06-24 08:48:54 +00: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
Juliusz Sosinowicz 39acd415fc Reject ChaCha encrypt/decrypt before set_iv (F-4463)
ChaCha.__init__ leaves _IV_nonce empty and requires set_iv() before
use, but encrypt()/decrypt() (inherited from _Cipher) did not check
this. The first call ran _set_key(), which passed the empty nonce to
wc_Chacha_SetIV() - a function that unconditionally reads 12 bytes -
reading past the buffer and silently producing output with an
undefined IV. Track an _iv_set flag and override encrypt()/decrypt()
to raise WolfCryptError until set_iv() has been called.
2026-06-23 11:35:58 +00:00
Juliusz Sosinowicz 53b3f6cef9 Remove contradictory cipher mode validation (F-4015)
_FEEDBACK_MODES advertised MODE_ECB/MODE_CFB/MODE_OFB as supported, but
_Cipher.__init__ then rejected every mode other than CBC/CTR with a
contradictory 'not supported by this cipher' error after they had
already passed the 'is supported' check. Prune _FEEDBACK_MODES to the
modes the cipher actually implements (CBC, CTR) so unsupported modes
get a single, accurate rejection, and drop the now-dead else branch.
2026-06-23 11:30:00 +00:00
David Garske 3c911eeb29
Merge pull request #124 from roberthdevries/remove-redundant-open-modes
Remove redundant open modes.
2026-06-08 15:45:07 -07:00
David Garske d36990dad3
Merge pull request #122 from roberthdevries/mark-unused-variable
Mark unused variable in test code with a leading underscore.
2026-06-08 15:44:52 -07:00
David Garske 117d7bcbb9
Merge pull request #121 from roberthdevries/fix-imports-test-ciphers
Fix duplicate and unsorted imports in test_ciphers.py
2026-06-08 15:44:37 -07:00
David Garske 3294a1d492
Merge pull request #123 from roberthdevries/remove-unnecessary-utf-8-encoding-declaration
Remove unnecessary UTF-8 encoding declarations.
2026-06-08 15:44:17 -07:00
Martijn de Milliano eb93f657bf Test AESGCM stream: ignore failures for small auth tags
Smaller authentication tags may not be supported by the library.
This fix makes the test work for the default case that tags
should be minimum 12 bytes in size.
2026-06-04 18:05:58 +02:00
Martijn de Milliano 52886c4034 ML-DSA: Deal with signing without context not always supported
In the newer wolfSSL signing and verifying without context is
not available unless it is explicitly enabled.

This change modifies the Python binding and test suite to
accommodate this.
2026-06-04 18:03:35 +02:00
Martijn de Milliano 1e20bc9b80 Prepare for v5.9.1 release 2026-06-04 16:59:24 +02:00
Robert de Vries 92ca0e57af Remove redundant open modes.
Redundant `open` mode arguments are unnecessary and should be removed to
avoid confusion.
2026-05-18 20:30:39 +02:00
Robert de Vries 914a9b473a Remove unnecessary UTF-8 encoding declarations.
PEP 3120 makes UTF-8 the default encoding, so a UTF-8 encoding
declaration is unnecessary.
2026-05-18 20:25:36 +02:00
Robert de Vries b15d6f47c4 Mark unused variable in test code with a leading underscore. 2026-05-18 20:21:53 +02:00
Robert de Vries f3ae55b2b1 Fix duplicate and unsorted imports in test_ciphers.py 2026-05-18 19:47:25 +02:00
David Garske aa34a9c67d
Merge pull request #112 from roberthdevries/remove-unicode-prefix
Remove unicode prefix.
2026-05-17 22:32:20 -07:00
David Garske f0c187a7ad
Merge pull request #120 from roberthdevries/use-f-string-instead-of-percent-formatting
Use f string instead of percent formatting
2026-05-17 22:03:16 -07:00
Robert de Vries 18701e3b62 Use format specifiers instead of percent format.
printf-style string formatting has a number of quirks, and leads to less
readable code than using str.format calls or f-strings.
In general, prefer the newer str.format and f-strings constructs over
printf-style string formatting.
2026-05-17 16:14:52 +02:00
Robert de Vries 31475dddac Remove unicode prefix.
In Python 3, all strings are Unicode by default. The Unicode kind prefix is
unnecessary and should be removed to avoid confusion.
2026-05-17 15:00:03 +02:00
David Garske 8b3acfc12a
Merge pull request #119 from LinuxJedi/f-fixes2
Address Fenrir findings
2026-05-12 09:29:01 -07:00
Andrew Hutchings ef4195f99a Address Fenrir findings
F-3340: AesGcmStream.final decrypt path passed len(authTag) straight to
wc_AesGcmDecryptFinal, letting a caller truncate the verification window
(forgery probability ~2^-32 instead of 2^-128 for a 4-byte tag against a
16-byte configuration). Reject len(authTag) != self._tag_bytes and pass
self._tag_bytes to wolfSSL, mirroring ChaCha20Poly1305.decrypt. Added
test_decrypt_rejects_wrong_tag_length. Also fixed test_encrypt_short_tag
which was relying on the bug (decrypt side defaulted to tag_bytes=16
against a 12-byte tag).

F-3089: Declare label as const byte* in the wc_RsaPublicEncrypt_ex and
wc_RsaPrivateDecrypt_ex cdefs so CFFI can accept Python bytes without
exposing a writable pointer into immutable memory. wolfSSL does not
modify label.

F-3090: Declare nonce as const byte* in the wc_InitRngNonce and
wc_InitRngNonce_ex cdefs for the same reason.

F-1983, F-1984: Add minimum + upper bounds to requirements/{prod,test,
docs}.txt so a hijacked release of cffi, tox, pytest, types-cffi,
Sphinx, or sphinx_rtd_theme does not get pulled silently on the next
pip install. setup.txt resolves transitively via prod.txt.
2026-05-12 13:15:35 +01:00
David Garske c6d23d30f4
Merge pull request #118 from LinuxJedi/f-fixes
Fenrir fixes
2026-05-11 10:27:11 -07:00
Andrew Hutchings 98215b60f6 Address Copilot concerns 2026-05-11 13:05:23 +01:00