2220 Commits

Author SHA1 Message Date
Daniel Pouzzner
2c5db7b64c fix whitespace. 2022-04-26 09:57:25 -05:00
Sean Parkinson
8737d46bb1
Merge pull request #5018 from haydenroche5/libspdm
Make changes to compatibility layer to support libspdm.
2022-04-26 09:55:22 +10:00
Sean Parkinson
d362b6dd08
Merge pull request #5033 from haydenroche5/ec_key_print_fp
Add wolfSSL_EC_KEY_print_fp to compat layer.
2022-04-26 09:51:37 +10:00
Masashi Honma
3ab5ccd04f
Add support for EVP_PKEY_sign/verify functionality (#5056)
* Fix wolfSSL_RSA_public_decrypt() return value to match Openssl
* Add support for EVP_PKEY_verify_init() and EVP_PKEY_verify()
* wpa_supplicant SAE public key functionality requires this function.
* Add DSA support for EVP_PKEY_sign/verify()
* Add ECDSA support for EVP_PKEY_sign/verify()
* Add tests for EVP_PKEY_sign_verify()
* Fix "siglen = keySz" at error cases
* Fix wolfSSL_DSA_do_sign() usage
1. Check wolfSSL_BN_num_bytes() return value
2. Check siglen size
3. Double the siglen
* Check return code of wolfSSL_i2d_ECDSA_SIG() in wolfSSL_EVP_DigestSignFinal()
* Add size calculations to `wolfSSL_EVP_PKEY_sign`
* Add size checks to wolfSSL_EVP_PKEY_sign before writing out signature
* Use wc_ecc_sig_size() to calculate ECC signature size
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
Co-authored-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2022-04-25 14:19:56 -07:00
Eric Blankenhorn
b543aa0148 Fix for mingw builds 2022-04-22 14:35:46 -05:00
Daniel Pouzzner
4a4b019e30 tests/api.c: in test_wc_ecc_verify_hash_ex(), check that passing zero r and/or s to wc_ecc_verify_hash_ex() returns MP_ZERO_E. 2022-04-21 07:21:42 +02:00
Hayden Roche
cfab451328
Merge pull request #5024 from dgarske/zd13538 2022-04-20 13:08:13 -07:00
David Garske
49f510544a
Merge pull request #5057 from haydenroche5/pem_write_ec_rsa_pub
Add wolfSSL_PEM_write_RSAPublicKey and wolfSSL_PEM_write_EC_PUBKEY.
2022-04-19 16:19:38 -07:00
Hayden Roche
d7085069d6 Add wolfSSL_PEM_write_RSAPublicKey and wolfSSL_PEM_write_EC_PUBKEY.
These were compatibility layer stubs before.
2022-04-19 09:42:10 -07:00
Juliusz Sosinowicz
a6319fc2a9 Add missing XFCLOSE() 2022-04-15 16:26:31 +02:00
Hayden Roche
0ef7435580 Make changes to compatibility layer to support libspdm.
- Add support for ASN1_TIME_compare, DH_new_by_nid, OBJ_length, OBJ_get0_data,
and ChaCha20-Poly1305 and HKDF in the EVP layer.
- Map EC_POINT_get_affine_coordinates to
wolfSSL_EC_POINT_get_affine_coordinates_GFp and EC_POINT_set_affine_coordinates
to wolfSSL_EC_POINT_set_affine_coordinates_GFp.
- Add kdf.h compatibility header.
2022-04-11 15:07:27 -07:00
Hayden Roche
0717135e49 Add wolfSSL_EC_KEY_print_fp to compat layer. 2022-04-11 13:02:38 -07:00
David Garske
80766566fc Fixes for X509_add_ext and new test case. 2022-04-06 16:35:53 -07:00
David Garske
1b5af2fdd9
Merge pull request #5022 from SparkiDev/wycheproof_fixes
Wycheproof fixes/changes
2022-04-06 10:29:17 -07:00
Sean Parkinson
e9187f5f00 Wycheproof fixes/changes
Allow Chachac20-Poly1305 to take an empty msg.
Allow AES-SIV to have an empty nonce.
Don't allow the length to be malleable. Must use the smallest number of
bytes to represent value.
ECDSA and DSA signature values are positive.
Add Sha512-224 and Sha512-256 OIDs.
ASN template - ensure the ECDSA/DSA signature uses all data.
Curve25519/Curve448 - WOLFSSL_ECDHX_SHARED_NOT_ZERO means shared secret
can't be 0.
Curve25519/Curve448 - check public value is less than order.
ECC - x or y may be zero but not both.
Ed25519/Ed448 - check S is less than order.
Ed448 - ge_p3_dbl can be simplified for ASM.
Prime check (integer.c/tfm.c/sp_int.c): Don't allow negative values and
make sure random candidate doesn't have bits higher than those in a set
when bits not a multiple of 8.
RSA: support Sha512-224 and Sha512-256.
RSA: Fix check for invalid in decryption. Affects plaintexts 256 bytes
and longer.
RSA: Don't allow base be larger than modulus.
RSA: Check small ciphertext (1 or 0) on decrypt when not using OAEP.
RSA: WOLFSSL_RSA_DECRYPT_TO_0_LEN allows decrypted value to be 0.
SP math all: fix div to handle large a and d when checking size of
remainder.
SP math all: set sign of result in sp_mod_2d()
2022-04-06 15:35:01 +10:00
David Garske
6a3f98627e
Merge pull request #5013 from anhu/wc_CheckCertSigPubKey
Add new public API wc_CheckCertSigPubKey()
2022-04-05 09:48:08 -07:00
Daniel Pouzzner
328de3ed63 remove -Wno-strict-aliasing from AX_HARDEN_CC_COMPILER_FLAGS and AX_HARDEN_CXX_COMPILER_FLAGS in m4/ax_harden_compiler_flags.m4, and fix strict aliasing infractions in api.c. 2022-04-05 08:10:16 -05:00
Sean Parkinson
77485d987e
Merge pull request #5010 from haydenroche5/asn1_time_diff_2038
Fix year 2038 problem in wolfSSL_ASN1_TIME_diff.
2022-04-05 07:58:36 +10:00
Anthony Hu
fc6e10ff42 Another test fixup. 2022-04-04 17:42:25 -04:00
David Garske
6513e2ce8f
Merge pull request #5019 from douzzer/20220404-linux5v18-etc
20220404 linux5v18 etc
2022-04-04 11:08:18 -07:00
Hayden Roche
9c1e2a83d1 Fix year 2038 problem in wolfSSL_ASN1_TIME_diff.
Prior to this commit, this function used XMKTIME (mktime) to convert the
passed in WOLFSSL_ASN1_TIMEs to Unix timestamps. On platforms where time_t is
32 bits long, times after the year 2038 can't be represented with this type. To
fix this, we need to not use XMKTIME. With this commit, the static function
time2epoch is added to ssl.c, which uses the date time information to compute
seconds since the Unix epoch without the use of mktime. It returns the seconds
as a long long. This is sufficient to make the function work for years > 2038 on
the platform of the user who discovered this problem in the first place (Yocto
Linux on ARMv7).
2022-04-04 11:01:21 -07:00
Anthony Hu
400c7238ef Test fixup. 2022-04-04 13:43:06 -04:00
Anthony Hu
ae9926cc42 Missing flag in unit test. 2022-04-04 12:39:10 -04:00
David Garske
9b5ad6f218
Merge pull request #4968 from miyazakh/cryptonly
add WOLF_CRYPTO_CB_ONLY_RSA and WOLF_CRYPTO_CB_ONLY_ECC
2022-04-04 08:31:41 -07:00
Daniel Pouzzner
0d6c283f7a fixes for -Werror=declaration-after-statement in debug builds. 2022-04-04 09:29:26 -05:00
Sean Parkinson
0fba16a394
Merge pull request #4998 from haydenroche5/get_conv_form
Add wolfSSL_EC_KEY_get_conv_form to compatibility layer.
2022-04-04 08:47:14 +10:00
Hayden Roche
880afe0d89 Add wolfSSL_EC_KEY_get_conv_form to compatibility layer. 2022-04-02 13:57:33 -07:00
Anthony Hu
c522baa75e Unit tests. 2022-04-01 18:34:21 -04:00
Daniel Pouzzner
ae3996fd0e fix codebase for -Wvla -Wdeclaration-after-statement; fix some whitespace. 2022-04-01 14:44:10 -05:00
David Garske
bd0e222fec
Merge pull request #5012 from julek-wolfssl/evp-enc-dec-block
Implement `EVP_EncodeBlock` and `EVP_DecodeBlock`
2022-04-01 12:24:23 -07:00
Juliusz Sosinowicz
6dffa8a13d Implement EVP_EncodeBlock and EVP_DecodeBlock 2022-04-01 13:29:40 +02:00
Hideki Miyazaki
d3a379adac
add WOLF_CRYPTO_CB_ONLY_RSA and WOLF_CRYPTO_CB_ONLY_ECC 2022-04-01 09:36:52 +09:00
Sean Parkinson
79444fdb56
Merge pull request #4997 from dgarske/qat_eckg
Support for Intel QuickAssist ECC KeyGen acceleration
2022-04-01 08:32:21 +10:00
Sean Parkinson
1add8703e2
Merge pull request #4996 from haydenroche5/bn_rand
Improve wolfSSL_BN_rand.
2022-04-01 08:12:22 +10:00
David Garske
61f6b5e29c Peer review feedback. 2022-03-31 10:04:23 -07:00
David Garske
c905c613e9 Support for Intel QuickAssist ECC KeyGen acceleration. 2022-03-30 13:07:47 -07:00
Hayden Roche
2077690bf0 Improve wolfSSL_BN_rand.
- Previously, this function would round up the requested bits to the next
multiple of 8. With this commit, the function returns a number of exactly the
number of bits requested, which is the same behavior as OpenSSL. This problem
was discovered by a user using the compatibility layer with OpenSSH's ssh-keygen
utility.
- This function now respects the top and bottom parameters.
- Improved unit testing.
2022-03-29 18:08:21 -07:00
Jacob Barthelmeh
f7f94cede0 support creating new mem bio of length 0 2022-03-28 15:52:42 -06:00
Daniel Pouzzner
008c8509c6 multi-test fixes: whitespace in wolfcrypt/src/random.c and wolfcrypt/test/test.c, bugprone-macro-parentheses and -Wenum-compare in WS_RETURN_CODE() (wolfssl/ssl.h), and clang-analyzer-deadcode.DeadStores in api.c. 2022-03-25 13:26:41 -05:00
Juliusz Sosinowicz
88d5059c36 Jenkins fixes
`WS_RETURN_CODE` was not functioning properly in master
2022-03-24 12:16:59 +01:00
Juliusz Sosinowicz
98bc8402db Refactor memory BIO
- use the `WOLFSSL_BUF_MEM` struct to resize the internal memory buffer
- add a `WOLFSSL_BIO_RESIZE_THRESHOLD` define that will be used to determine how often to shrink the internal buffer. This should cut down on the number of free/malloc calls made significantly. This should help with our inefficient 1 byte reads in `loadX509orX509REQFromPemBio`.
- implement `wolfSSL_BUF_MEM_resize` which allows bi-directional buffer size manipulation
2022-03-24 12:16:59 +01:00
Juliusz Sosinowicz
9763030675
Merge pull request #4845 from cconlon/pkcs7compat 2022-03-21 15:26:37 +01:00
Hayden Roche
dcaa218ed8
Merge pull request #4927 from cconlon/upRef 2022-03-18 18:10:36 -07:00
Hayden Roche
2637e5e361
Merge pull request #4926 from cconlon/namePrintRFC5523 2022-03-18 15:53:07 -07:00
David Garske
a79daa5ea8
Merge pull request #4959 from haydenroche5/asn1_time_diff_bug
Fix bug in wolfSSL_ASN1_TIME_diff.
2022-03-18 14:28:23 -07:00
Chris Conlon
582f0d82e4 address review feedback for PKCS7 compat additions 2022-03-18 12:07:44 -06:00
Juliusz Sosinowicz
1fd090d094 Update wolfSSL_get_session docs
Recommend using `wolfSSL_get1_session` and `NO_SESSION_CACHE_REF` for session resumption purposes. `wolfSSL_get_session` should not be used unless to inspect the current session object.
2022-03-17 12:56:28 +01:00
Hayden Roche
6e6aa5b0c1 Fix bug in wolfSSL_ASN1_TIME_diff.
This function should not error out if one of the passed in times is the Unix
epoch. This amounts to erroring out when the XMKTIME returns < 0, rather than
<= 0.
2022-03-15 10:52:05 -07:00
Chris Conlon
6762cd90da add tests for PKCS7_sign(), PKCS7_final(), SMIME_write_PKCS7() 2022-03-15 10:21:22 -06:00
Chris Conlon
a7d5e6400d add support for PKCS7_TEXT flag to PKCS7_verify() 2022-03-15 10:21:22 -06:00