Commit Graph

475 Commits (master)

Author SHA1 Message Date
philljj 392663eb0d
Merge pull request #114 from roberthdevries/add-support-for-crypto-callbacks
Add initial support for crypto callbacks.
2026-10-30 09:50:35 -05:00
David Garske 6e054800f4 Keep a crypto callback device registered until its outstanding hash contexts are freed 2026-10-28 22:28:54 -07:00
David Garske f0e3918d79 Deep copy crypto callback hashes with wolfCrypt copy functions and use wc_HmacCopy for HMAC digest 2026-10-21 11:18:49 -07:00
David Garske cdfeacd5f2 Give each hash object its own crypto callback context across copy and free 2026-10-19 14:26:42 -07:00
David Garske db57784506 Log crypto callback tracebacks, fail closed on handler errors and document the override contract 2026-10-19 12:53:48 -07:00
David Garske 3da4b6d0a3 Add crypto callback tests for error, fallback, re-registration and device_id paths 2026-10-19 12:40:54 -07:00
David Garske 42fcbc83f5 Track crypto callback device ownership, require full hash overrides and forward device_id in new() 2026-10-19 12:40:54 -07:00
David Garske 2b042fa892 Declare CRYPTOCB_UNAVAILABLE and WC_HW_E without ERROR_STRINGS and restore the no-PQC import smoke step 2026-10-19 12:40:54 -07:00
Robert de Vries 483b532bac Add more tests.
* Add parametrized callback test for all Sha classes.
* Add callback test for unsupported algo type AES GCM Stream.
2026-10-19 12:17:21 -07:00
Robert de Vries d884b75c6e Address review comments 2026-10-19 12:17:21 -07:00
Robert de Vries a62c87a770 INVALID_DEVID is always needed as default argument value.
This makes it also no longer necessary to use the hard-coded
magic value -2 as default argument for various cases where it was
already required.
2026-10-19 12:17:21 -07:00
Robert de Vries 3ba3def637 INVALID_DEVID is also needed when the CRYPTO_CB feature is enabled. 2026-10-19 12:17:21 -07:00
Robert de Vries 26041b75a0 Addressed review comments
* added various tests
* adapted hash interface to allow callbacks
2026-10-19 12:17:21 -07:00
Robert de Vries e943b88b2f Fix ruff errors and add type info. 2026-10-19 12:17:21 -07:00
Robert de Vries 97820a5331 Address review comments. 2026-10-19 12:17:21 -07:00
Robert de Vries 7412dd1306 Address review comments
* Add if _lib.CRYPT_CB_ENABLED guards around code that depends on that
  configuration option being enabled.
2026-10-19 12:17:21 -07:00
Robert de Vries 6a0a525205 Addressed review comments
* Comment out code in build_ffi.py instead of quoted string.
* Check return value of wolfCrypt_init()
* Complete algorithm type hash table
* Change dicts into defaultdicts with a sensible value when key is missing.
* Convert debug print to debug log messages
* Add length checks to produce nicer exceptions.
2026-10-19 12:17:21 -07:00
Robert de Vries e57bcfe097 Add initial support for crypto callbacks. 2026-10-19 12:17:21 -07:00
JacobBarthelmeh cb9885ba53
Merge pull request #143 from embhorn/zd22306
Fix ML-DSA example in docs
2026-08-10 10:25:58 -06:00
Eric Blankenhorn d4b8fbad0e Fix from review 2026-08-07 14:30:49 -05:00
Eric Blankenhorn 58520ace10 Fix ML-DSA example in docs 2026-08-07 14:11:45 -05:00
John Safranek e1bdcab5ea
Merge pull request #138 from MarkAtwood/fix/pin-setuptools-build-backend
build: declare the setuptools build backend floor (F-5426)
2026-08-02 21:38:30 -07:00
Mark Atwood ef980e4d09 build: declare the setuptools build backend floor (F-5426)
[build-system] declared bare `setuptools`, so isolated builds resolved
whatever version the index served at build time. This repo has no uv.lock,
so CI's `uv build --wheel` re-resolves the backend on every run.

Declare `setuptools>=77`. Nothing was broken before this: an unpinned
resolver always fetched a recent backend, so the build worked. The floor is
measured, not chosen. The PEP 639 `license` expression and `license-files`
key already in this file each require setuptools >= 77 independently (76 and
older reject either one alone, while the older `license = {file = ...}`
table form passes), so the project had an undeclared >= 77 requirement that
stayed invisible precisely because the version floated. Declaring it keeps a
build environment pinned below 77 from failing mid-build on an opaque
`project.license` config error with no hint that the fix is an upgrade.

No upper bound, matching the floor-only convention of every other bound in
this file (`cffi>=1.17`, `typing-extensions>=4.4.0`). A ceiling would not
address the reported risk anyway -- a malicious point release satisfies any
range, so only hash-pinned build requirements help there -- and setuptools
ships majors often enough (7 since 2025-03, with 81 and 82 two days apart)
that a stale ceiling silently excludes working versions instead of
protecting anything.

Verified: builds at 77.0.3 and 83.0.0, 76.1.0 refused at resolve time,
License-Expression intact in wheel METADATA, ruff clean, 196 passed.
2026-07-31 15:05:30 -07:00
philljj b297f8a00b
Merge pull request #141 from julek-wolfssl/fenrir-dilithium-ctxlen-fix
Use byte ctxLen in wc_dilithium_verify_ctx_msg cdef (F-4014)
2026-07-29 23:25:42 -05:00
JacobBarthelmeh f82dbb6e11
Merge pull request #142 from kareem-wolfssl/592changelog
Update changelog for 5.9.2 release.
2026-07-16 14:16:03 -06:00
Kareem ec17e626eb Update changelog for 5.9.2 release. 2026-07-16 12:10:13 -07:00
Juliusz Sosinowicz 2fea30cd32 Validate ctx length in MlDsa.verify (F-4014)
MlDsa.sign/sign_with_seed reject a context longer than 255 bytes with
ValueError, but verify did not. With ctxLen now correctly declared as byte in
the cdef, an over-long ctx would surface as a low-level CFFI OverflowError
instead of the consistent ValueError callers get from the signing paths.

Reject len(ctx) > 255 with ValueError in verify, matching sign.
2026-07-16 13:44:55 +00:00
Juliusz Sosinowicz 8bb46362b7 Use byte ctxLen in wc_dilithium_verify_ctx_msg cdef (F-4014)
The CFFI cdef declared wc_dilithium_verify_ctx_msg with word32 ctxLen while the
sign variants use byte ctxLen. wolfSSL's real API (wc_MlDsaKey_VerifyCtx in
wolfcrypt/wc_mldsa.h, which the wc_dilithium_verify_ctx_msg macro forwards to)
takes byte ctxLen, matching FIPS 204's 255-byte context cap. The mismatched
cdef made CFFI marshal a 4-byte word32 into a 1-byte slot, silently truncating
any ctxLen > 255 to its low byte.

Declare ctxLen as byte to match the sign cdef and the underlying API.
2026-07-16 08:48:55 +00:00
sebastian-carpenter a59a4f8b96 update license to GPLv3 2026-07-09 18:24:23 +02:00
David Garske 905682a036
Merge pull request #130 from mjdemilliano/add-hashdrbg-reseed
Random: add DRBG reseed support
2026-07-08 12:28:45 -07:00
David Garske 1cb9b5d6c1
Merge pull request #133 from roberthdevries/pipeline-use-uv-and-ruff
Change workflow to using uv and ruff.
2026-07-08 12:26:11 -07:00
David Garske 2281b705df
Merge pull request #125 from roberthdevries/add-more-typing
Add typing: asn, exceptions, hashes, pwdbased, utils.
2026-07-08 12:26:02 -07:00
Robert de Vries 1a2829a4cd Fixed a few type annotations and added bad type tests.
Also added one note to the ChangeLog.
2026-07-08 15:22:37 +02:00
Robert de Vries 3b5050657f Fix more review comments and remove requirements sub-directory.
All information in requirements is now present in the pyproject.toml file.
2026-07-08 14:39:24 +02:00
Martijn de Milliano c1be234aa6 Process review comments:
- Update lib.pyi
- Remove obsolete comment from test_reseed_multiple
- Update HASHDRBG detection logic to match random.h
2026-07-07 19:14:59 +02:00
Robert de Vries 0d2e15ffed Addressed multiple review comments. 2026-07-06 22:42:35 +02:00
Robert de Vries 35f9108a5f Update Makefile so that lint, test, test-all, check-all work again. 2026-07-06 22:29:31 +02:00
Robert de Vries 55d4a35805 Address review comments
* Update README.rst to fix remaining unclarities in using uv to
  install locally built version and various other smaller issues.
* Pipeline changes:
  * Build wheel
  * Test against locally built wheel
  * Make sure no-pqc version doesn't have ML-DSA/ML-KEM enabled.
2026-07-06 22:29:31 +02:00
Robert de Vries 04b58c0038 Fix ruff errors 2026-07-06 22:29:31 +02:00
Robert de Vries 2c35de76c7 Revert to actions/*v3 2026-07-06 22:29:31 +02:00
Robert de Vries 5126115d38 Fixed github actions document and processed review comments. 2026-07-06 22:29:31 +02:00
Robert de Vries 3078cd5b69 Change workflow to using uv and ruff.
uv is used to manage virtual environments and building wheels and
source distributions.
This replaces tox.
ruff is used to do static checking.
README is updated to reflect this change.
2026-07-06 22:29:31 +02:00
Robert de Vries 397725336e Address more review comments. 2026-07-06 22:27:34 +02:00
Robert de Vries 47b0ac5af9 Fix ruff issues. 2026-07-06 22:13:48 +02:00
Robert de Vries 147021d07c Enable and fix test_chacha_enc_dec. 2026-07-06 22:02:48 +02:00
Robert de Vries 00c57b5e91 Rebased on master and fixed any (extra) issues found with ruff and ty. 2026-07-06 22:02:48 +02:00
Robert de Vries 7f82b412e3 Address more review comments. 2026-07-06 22:02:48 +02:00
Robert de Vries 97766d708b Address more review comments.
Also added a line to the change log to mention that typing information
has been added.
2026-07-06 22:02:48 +02:00
Robert de Vries 66b2ffb7c8 Addressed more review comments. 2026-07-06 22:02:48 +02:00
Robert de Vries fda2869cce Add py.typed file to indicate that this library has typing annotations. 2026-07-06 22:02:48 +02:00