Commit Graph

32 Commits (master)

Author SHA1 Message Date
Koji Takeda c59e5910d1 Fix details by hand 2025-03-03 16:14:07 +09:00
Koji Takeda db90b836a2 Support ML-KEM 2025-02-21 17:04:40 +09:00
Jack Tjaden 59b3356e36 Added working test for chacha20poly1305 2024-09-27 14:11:32 +02:00
Jack Tjaden 18a8609c86 Rough adding of chacha20poly1305 2024-09-27 14:11:32 +02:00
Eric Blankenhorn e65ce4288a Exclude AES CTR from block size check 2023-12-27 17:12:20 +01:00
Hayden Roche 352219fc87 Make several improvements to the CFFI build process.
- Move _build_ffi.py to scripts/build_ffi.py. Do as little in the global
namespace of the script as possible by putting functionality into functions,
including a new main function.
- Improve feature detection by allowing user_settings.h in addition to
options.h. This is particularly useful on Windows.
- Add the windows directory. This contains subdirectories non_fips and
fips_ready, which each have a user_settings.h. The non_fips user_settings.h is
used by the build script to build on Windows with CMake, when not using
USE_LOCAL_WOLFSSL. The fips_ready user_settings.h is an example user_settings.h
that works with our FIPS Ready code and wolfcrypt-py.
- Improve Windows support. This commit modifies the way we build wolfSSL for
wolfcrypt-py on Windows. Instead of using CMake directly, we use it with
user_settings.h. This is typically how Windows users are building wolfSSL, and
it gets around some shortcoming of wolfSSL's CMake support (e.g. not all
required features are supported). Additionally, USE_LOCAL_WOLFSSL now works
properly on Windows. When using USE_LOCAL_WOLFSSL, it should point to a wolfSSL
source code directory. This works for FIPS bundles, too. Finally, for FIPS on
Windows, we only support DLL builds. The CFFI library (.pyd extension) requires
this DLL to work. build_ffi.py detects this scenario and copies the .dll into
the wolfcrypt package directory. I've modified setup.py to distribute the
.dll with the package.
- Add some missing FIPS gates. Testing against FIPS v2 triggered some errors.
Those are fixed in this commit.
2022-11-03 14:56:04 +01:00
Hayden Roche 5c28f695e1 Improve the RSA PSS code.
- sign_pss and verify_pss need to digest the data before calling into their
respective wolfCrypt functions. Those wolfCrypt functions expect digests, not
plaintext.
- RsaPrivate make_key should take an optional hash_type parameter for the case
where the key will be used to create PSS signatures.
- test_rsa_pss_sign_verify appears to have been deliberately coded to have the
input plaintext length line up with the digest size, which masked the problem
where we weren't digesting the plaintext. I modified the plaintext so that this
is no longer the case.
2022-10-12 19:10:40 +02:00
Hayden Roche bf0a4c2425 Add optional hash_type parameter to RSA from_pem functions. 2022-09-30 18:01:01 +02:00
Andrew Hutchings b9072e60c6 Add get_aad() function 2022-05-06 13:34:57 +02:00
Andrew Hutchings fbefe7e7e5 Simplify OAEP and PSS
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
2022-05-06 13:34:57 +02:00
Andrew Hutchings e34a0ece53 Completely refactor AES GCM
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
2022-03-07 23:24:23 -08:00
Andrew Hutchings 013c1e6987 Gate RSA variables in ciphers.py 2022-02-09 17:51:43 +00:00
Andrew Hutchings 3327d9ae39 Cleanup PSS constants and build
* Use constants from wolfSSL instead of copying them
* Add build gate for PSS
* Fix indentation
2022-02-08 17:56:48 +00:00
Andrew Hutchings 863e6836a9 Add RSA OAEP and PSS padding
Functions added:
* `encrypt_oaep(self, plaintext, hash_type, mgf, label)`
* `decrypt_oaep(self, ciphertext, hash_type, mgf, label)`
* `sign_pss(self, plaintext, hash_type, mgf)`
* `verify_pss(self, plaintext, signature, hash_type, mgf)`

Constants added:
* MGF1SHA224
* MGF1SHA256
* MGF1SHA384
* MGF1SHA512
* HASH_TYPE_NONE
* HASH_TYPE_MD2
* HASH_TYPE_MD4
* HASH_TYPE_MD5
* HASH_TYPE_SHA
* HASH_TYPE_SHA224
* HASH_TYPE_SHA256
* HASH_TYPE_SHA384
* HASH_TYPE_SHA512
* HASH_TYPE_MD5_SHA
* HASH_TYPE_SHA3_224
* HASH_TYPE_SHA3_256
* HASH_TYPE_SHA3_384
* HASH_TYPE_SHA3_512
* HASH_TYPE_BLAKE2B
* HASH_TYPE_BLAKE2S
2022-02-03 15:43:04 +00:00
Hayden Roche 726c37e9e7
Merge pull request #33 from danielinux/aes-ctr 2022-02-01 15:43:12 -08:00
Andrew Hutchings 16334bf5e6 Add support for AES GCM streaming 2022-02-01 07:45:21 -08:00
Daniele Lacamera 8a514e0f8e Added support for AES-CTR 2022-01-31 13:32:14 +01: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 f84d395d69 finished docs for v0.1.0 rc1 2016-05-03 00:01:18 -03:00
Moisés Guimarães b50afa900c adds ciphers docstrings 2016-05-01 12:11:58 -03:00
Moisés Guimarães 2287ebad58 renames utils functions 2016-05-01 10:14:56 -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 765a8f8aff removes constructor restrictions in hashes and ciphers 2016-04-29 17:50:36 -03:00
Moisés Guimarães 525b29bb01 adds RSA cipher 2016-04-24 22:02:14 -03:00
Moisés Guimarães 919cc67a9d fixes multiple ffi instances error 2016-04-24 20:49:07 -03:00
Moisés Guimarães 7e5efb125f adds tests; simplifies hashes and fixes ciphers to retain state. 2016-04-18 20:20:50 -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 efa336be2b adds Hmac wrappers 2016-04-14 21:00:44 -03:00
Moisés Guimarães 8c8f471486 adds Aes wrappers 2016-04-14 20:23:17 -03:00
Moisés Guimarães 1aeb5e90ec adds Des3 wrappers 2016-04-14 18:13:11 -03:00