Skip to content

Fixes for things found with the NSS regression suite #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

LinuxJedi
Copy link
Member

@LinuxJedi LinuxJedi commented Jul 2, 2025

  • Declare CKM_HKDF_KEY_GEN properly
  • Increase object counts for NSS
  • Add configdir parameter during C_Initialize for NSS
  • C_CopyObject was not doing a proper copy. This changes the behaviour so that it does.
  • C_CopyObject template check if there is a ulCount
  • WP_EC_Derive would crash when the point isn't DER encoded
  • Add CKM_RSA_PKCS to wrap and unwrap
  • C_Decrypt should return CKR_ENCRYPTED_DATA_INVALID when decryption
    fails
  • Add support for CKO_DATA objects
  • Improve file path handling
  • Move debugging functions into public API file
  • Make salt length errors fail signature verification

@LinuxJedi LinuxJedi force-pushed the nss-fixes branch 4 times, most recently from 4c38cd8 to 94ad8ff Compare July 3, 2025 11:38
@LinuxJedi LinuxJedi marked this pull request as ready for review July 3, 2025 12:28
@JacobBarthelmeh
Copy link
Contributor

@julek-wolfssl when back could you review this? Please un-assign yourself and assign to wolfssl-bot when ready for final review/merge.

@LinuxJedi LinuxJedi force-pushed the nss-fixes branch 2 times, most recently from 6a48d28 to c929ebf Compare July 9, 2025 12:55
@LinuxJedi LinuxJedi requested a review from julek-wolfssl July 10, 2025 06:06
@LinuxJedi LinuxJedi assigned julek-wolfssl and unassigned LinuxJedi Jul 10, 2025
src/internal.c Outdated
Comment on lines 2072 to 2076
if (initialDerSz == LENGTH_ONLY_E || initialDerSz == 0) {
/* wolfSSL 5.6.6 compatibility */
derSz = 256; /* Conservative estimate for ECC key DER */
ret = 0;
} else if (initialDerSz > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just use wc_EccKeyDerSize in all cases to get the der size.

@LinuxJedi LinuxJedi mentioned this pull request Jul 22, 2025
@julek-wolfssl julek-wolfssl force-pushed the nss-fixes branch 2 times, most recently from bb1c7dd to 6e43521 Compare July 30, 2025 12:33
julek-wolfssl and others added 6 commits July 31, 2025 10:58
* Declare `CKM_HKDF_KEY_GEN` properly
* Increase object cuonts for NSS
* Add configdir parameter during `C_Initialize` for NSS
`C_CopyObject` was not doing a proper copy. This changes the behaviour
so that it does.
* `C_CopyObject` template check if there is a `ulCount`
* `WP_EC_Derive` would crash when the point isn't DER encoded
* `C_Decrypt` should return `CKR_ENCRYPTED_DATA_INVALID` when decryption
  fails
* Fix Clang compiler error
* Fix RSA test for storage disabled
* Fix NSS + storage disabled compiling
* Declare `CKM_HKDF_KEY_GEN` in mechanism list
julek-wolfssl and others added 28 commits July 31, 2025 10:58
…ation

This fixes a regression of revision c929ebf, which improved support for
CKO_DATA. Since the data in CKO_DATA objects is now stored in a
different format, we need to differentiate on the object class used
for the input key when performing an HKDF derivation.
WP11_Slot_CheckUserPin is very resource intensive and caching this result helps with speeding up tests
For some reason C_DeriveKey does not check if CKA_DERIVE is set
No longer returns the length but for now NSS doesn't use it to check length
Disabling SHA3 causes the following

```
In file included from lib/wolfssl/wolfssl/wolfcrypt/error-crypt.h:34,
                 from lib/wolfPKCS11/src/crypto.c:33:
lib/wolfPKCS11/src/crypto.c: In function 'C_SignInit':
lib/wolfssl/wolfssl/wolfcrypt/types.h:446:36: error: attribute 'fallthrough' not preceding a case label or default label [-Werror]
  446 |             #define FALL_THROUGH ; __attribute__ ((fallthrough))
      |                                    ^~~~~~~~~~~~~
lib/wolfPKCS11/src/crypto.c:4000:13: note: in expansion of macro 'FALL_THROUGH'
 4000 |             FALL_THROUGH;
      |             ^~~~~~~~~~~~
lib/wolfPKCS11/src/crypto.c: In function 'C_VerifyInit':
lib/wolfssl/wolfssl/wolfcrypt/types.h:446:36: error: attribute 'fallthrough' not preceding a case label or default label [-Werror]
  446 |             #define FALL_THROUGH ; __attribute__ ((fallthrough))
      |                                    ^~~~~~~~~~~~~
lib/wolfPKCS11/src/crypto.c:5019:13: note: in expansion of macro 'FALL_THROUGH'
 5019 |             FALL_THROUGH;
```
Length calculation was incorrect, causing an error. In addition, lengths
for arrays were double-stored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants