Closed Bug 295298 Opened 19 years ago Closed 19 years ago

RSA key size limits are not applied to key pair generation in freebl

Categories

(NSS :: Libraries, defect, P2)

3.9.5
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.10.2

People

(Reporter: julien.pierre, Assigned: wtc)

Details

Attachments

(1 file)

The RSA algorithms has a hardcoded limit of 8192 bits in freebl/rsa.c . But that limit is only applied to public key ops. Key gen is not limited . The side effect of this is that C_GenerateKeyPair can generate any size key . However, you can't really generate >8192 keys with NSS because of pk11wrap . PK11_GenerateKeyPair calls C_GenerateKeyPair, which succeeds, but then it calls PK11_ExtractPublicKey, which fails . The fix is to apply the same limit to keygen and private key ops in freebl that we do to public key ops .
This patch should enforce the maximum modulus size (and public exponent size) when we generate a key pair. It does not check the modulus size during private key operations.
I want to broaden the scope of this bug to include the RSA key size limits in softoken also. While we're at it, we may also want to check out limits for DSA and DH keys and params, too. Softoken imposes lower bounds on RSA public key sizes with calls to sftk_ConstrainAttribute in sftk_handlePublicKeyObject (near http://lxr.mozilla.org/security/source/security/nss/lib/softoken/pkcs11.c#1046 ) but does not impose an upper bound. Since we now have an upper bound, I think it should be imposed at key import/derive/unwrap/gen time also, and imposing the limit in the calls to sftk_ConstrainAttribute would do that. sftk_handlePrivateKeyObject (near http://lxr.mozilla.org/security/source/security/nss/lib/softoken/pkcs11.c#1197 should impose similar limits on the corresponding private keys, IMO.
Summary: RSA key size limits are not uniformly applied in freebl → RSA key size limits are not uniformly applied in freebl and softoken
Comment on attachment 184426 [details] [diff] [review] Patch for key pair generation (checked in) This patch looks good as far as it goes. Do we also want to limit private key ops?
Attachment #184426 - Flags: review+
Comment on attachment 184426 [details] [diff] [review] Patch for key pair generation (checked in) Thanks for the code review, Nelson. Julien, do you have the setup to test this patch?
Comment on attachment 184426 [details] [diff] [review] Patch for key pair generation (checked in) I tested this patch and it works fine - it prevents keygen above 8192 bits from starting. I think we should limit private key ops as well.
Attachment #184426 - Flags: superreview+
Comment on attachment 184426 [details] [diff] [review] Patch for key pair generation (checked in) I checked in this patch on the NSS trunk for NSS 3.10.1.
Attachment #184426 - Attachment description: Patch → Patch for key pair generation (checked in)
QA Contact: bishakhabanerjee → jason.m.reid
Part of the fix was made on NSS_3_10_BRANCH for the keygen, but the private key size check remains to be done. For now, I'm tentatively setting the target to 3.10.1 .
Priority: -- → P2
Target Milestone: --- → 3.10.1
Target Milestone: 3.10.1 → 3.10.2
I opened bug 308724 for the remaining work. I updated the bug's summary to reflect what was fixed in NSS 3.10.2.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Summary: RSA key size limits are not uniformly applied in freebl and softoken → RSA key size limits are not applied to key pair generation in freebl
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: