Commit Graph

31 Commits (a59a4f8b965c8ad42c6af95c80fc3873e77cd0cc)

Author SHA1 Message Date
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
Robert de Vries 1fb34e5cd8 Address review comments and annotate overrides. 2026-07-06 22:02:48 +02:00
Robert de Vries 2081edd6d7 Add typing information to ciphers.py
This has some fallout in random.py to simplify checks.
Also one test is slightly adapted to produced the desired failure.
2026-07-06 22:02:48 +02:00
Martijn de Milliano 0124b33202 Process review comments for random and test_random
- add pragma no cover
- format using ruff
- fix module factor in test_random
2026-06-30 20:47:41 +02:00
Martijn de Milliano e6f4632030 Random: add DRBG reseed support 2026-06-26 14:26:46 +02: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
Andrew Hutchings ce93174570 Fix Random.__init__ AttributeError on builds without ML-KEM/ML-DSA
Random.__init__ used _lib.INVALID_DEVID as a default parameter value,
but INVALID_DEVID is only declared in the CFFI cdef inside
`if features["ML_KEM"] or features["ML_DSA"]`. Since default parameters
are evaluated at module import time, any wolfSSL build that lacks both
ML-KEM and ML-DSA (e.g. via USE_LOCAL_WOLFSSL pointing at a custom
build) raises AttributeError on `import wolfcrypt.random`, cascading
into wolfcrypt.ciphers and effectively breaking the entire library.

Hardcode the default to -2, matching the convention already used by
_Hmac._init and AesGcmStream.__init__ (which call wc_HmacInit /
wc_AesInit with -2 directly rather than referencing _lib.INVALID_DEVID).

Add a build-no-pqc GitHub Actions job that builds wolfSSL with
--disable-kyber --disable-dilithium, installs wolfcrypt-py against it
via USE_LOCAL_WOLFSSL, and runs an import-smoke step plus the full
pytest suite. The smoke step is the explicit regression guard: it
imports wolfcrypt.random and instantiates Random(), which would fail
at import time if the default ever again references a CFFI symbol that
is only conditionally declared.

F-2659
2026-05-11 12:02:26 +01:00
David Garske 4ec45a6511
Merge pull request #110 from roberthdevries/special-wc-api-retval-exceptions
Raise specialized WolfCryptApiError for failed API calls.
2026-05-08 15:59:50 -07:00
David Garske efe131ee96
Merge pull request #109 from kareem-wolfssl/gh108
Wrap _delete/_copy class attrs in staticmethod so self isn't bound as an extra arg.
2026-05-05 10:43:56 -07:00
Robert de Vries 0ac207d34a Raise specialized WolfCryptApiError for failed API calls.
This exception takes the return value and converts that to
a human-readable string (if error string support is compiled in.)

The specialized exception is derived from WolfCryptError meaning
that existing users will not notice the difference except for the
nicer description.
2026-04-24 22:01:02 +02:00
Kareem f6c27bf55d Wrap _delete/_copy class attrs in staticmethod so self isn't bound as an extra arg.
Fixes #108.
2026-04-22 16:19:41 -07:00
Robert de Vries 61c7990be0 Addressed various review comments. 2026-04-20 22:37:07 +02:00
Robert de Vries 917e2942ea Add a few missed type annotations in random.py. 2026-04-17 23:20:15 +02:00
Robert de Vries 338a4839b9 Fix various review comments.
- Missing import in _ffi/__init__.py
- Updated docstring of t2b
- Reverted change to Random.__del__()
2026-04-17 23:20:15 +02:00
Robert de Vries 8448f41b42 Added ffi to all in _ffi/__init__.py
Removed unused import.
2026-04-17 23:20:15 +02:00
Robert de Vries 6e36bd3a24 Start adding typing information.
Initially only random.py and utils.py.
2026-04-17 23:20:15 +02:00
Robert de Vries e6c5afaaa9 Remove parent class object everywhere.
Since Python 3, all classes inherit from `object` by default, so `object` can
be omitted from the list of base classes.
2026-04-12 21:30:44 +02:00
Robert de Vries 4564459a9e Prepare python interface for use of device_id callbacks. 2026-04-06 20:20:21 +02:00
Robert de Vries 01fcd2af6c Add support for nonce in random number generation. 2026-04-05 23:10:29 +02:00
Andrew Hutchings a142619dd5 Port missing things from wolfSSL Python wrapper
wolfSSL's source tree had a stale version of the Python wolfCrypt
wrapper. There were a couple of bits in it that weren't here, so this
ports them accross.

Mostly notably a minor issue where `Random.__del__` can throw a race
condition exception during shutdown.
2022-07-13 16:08:25 +02: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
Moisés Guimarães bf298548ab move files to wolfssl/wrappers/python 2016-05-15 15:23:21 -03:00
Moisés Guimarães 9af1f0d034 adds random and hashes docstrings. 2016-05-01 11:17:37 -03:00
Moisés Guimarães 2287ebad58 renames utils functions 2016-05-01 10:14:56 -03:00
Moisés Guimarães 7297310498 fixes random tests 2016-05-01 09:15:44 -03:00
Moisés Guimarães 7cab8863d6 adds error handling with Exceptions. 2016-05-01 09:13:57 -03:00
Moisés Guimarães 647f65c0cc fixes python3 issues 2016-04-30 23:14:51 -03:00
Moisés Guimarães 919cc67a9d fixes multiple ffi instances error 2016-04-24 20:49:07 -03:00
Moisés Guimarães 6a78b4f41d fixes import * making some variables 'private' 2016-04-16 19:32:39 -03:00
Moisés Guimarães 691c59bd64 adds RNG wrappers 2016-04-14 21:32:39 -03:00