Skip to content
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

Bug 1303224 - Remove the PKCS#11 bypass #15

Closed

Conversation

ttaubert
Copy link
Contributor

@@ -23,7 +23,7 @@ cd nss && make nss_build_all
# we run scan-build on these folders
declare -a scan=("lib/ssl" "lib/freebl")
# corresponds to the number of errors that are expected in the |scan| folder
declare -a ignore=(1 0)
declare -a ignore=(0 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are no longer ignoring, maybe you can instead remove the ability to ignore entirely.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep the ignores. The plan is to enable scan-build on other folders where we'll have the same problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping.

** XXX: 'E' and 'x' were used in the past, please leave some
** time before resuing those. */
** XXX: 'B', 'E', 'q', and 'x' were used in the past, please
** leave some time before resuing those. */
Copy link
Contributor

@martinthomson martinthomson Sep 19, 2016

Choose a reason for hiding this comment

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

Include the release in which these were removed so that it is easier to decide when to overwrite them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1323,13 +1314,9 @@ main(int argc, char **argv)
progName = progName ? progName + 1 : tmp;

optstate = PL_CreateOptState(argc, argv,
"BC:DNP:TUV:W:a:c:d:f:gin:op:qst:uvw:z");
"C:DNP:TUV:W:a:c:d:f:gin:op:qst:uvw:z");
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -960,7 +957,7 @@ main(int argc, char **argv)
SSL_VersionRangeGetSupported(ssl_variant_stream, &enabledVersions);

optstate = PL_CreateOptState(argc, argv,
"46BCDFGHKM:OR:STUV:W:Ya:bc:d:fgh:m:n:op:qr:st:uvw:z");
"46CDFGHKM:OR:STUV:W:Ya:bc:d:fgh:m:n:op:qr:st:uvw:z");
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1199,7 +1199,10 @@ SSL_IMPORT SECStatus SSL_ExportKeyingMaterial(PRFileDesc *fd,
*/
SSL_IMPORT CERTCertificate *SSL_LocalCertificate(PRFileDesc *fd);

/* Test an SSL configuration to see if SSL_BYPASS_PKCS11 can be turned on.
/* DEPRECATED: The PKCS#11 bypass has been removed. This function will now
** always return false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the rest of the comment and the other comments on the #defines.

Copy link
Contributor Author

@ttaubert ttaubert Sep 19, 2016

Choose a reason for hiding this comment

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

Done.

spec->destroy(spec->encodeContext, freeit);
spec->destroy(spec->decodeContext, freeit);
spec->destroy(spec->encodeContext, PR_TRUE);
spec->destroy(spec->decodeContext, PR_TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to self: check if we actually need/use spec->destroy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we don't! Added another commit to get rid of it.

if (spec->bypassCiphers) {
/* This function doesn't support PKCS#11 bypass. We fallback on the
* non-constant time version. */
goto fallback;
Copy link
Contributor

Choose a reason for hiding this comment

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

You didn't remove the trailing fallback block at the end of this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need it in case PK11_SignWithSymKey() fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is only one case that calls that code, move it inline and remove the goto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good idea.

}
hashesForVerify = hashes;
} else {
if (!hashes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is the right change (and I think that it is), then I think that we can simply add a PORT_Assert on line 9657.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fought with scan-build about this change here, as I started by doing what you suggested. The problem is that _HandleCertificateVerify() can definitely be called when seeing a certificate_verify message but ssl3.hs.ws != wait_certificate_verify. In that case we should bail out before checking for (!hashes) because that will be true in those cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure that I understand given that the ssl3.hs.ws check is above this, but it's a nit only, so do as you see fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to say that ssl3_HandleCertificateVerify() will be called when we receive a certificate_verify message but don't expect any. In that case hashes == NULL. So we'd better assert after we checked that we actually expect a certificate_verify message, otherwise we'll throw a library error when we shouldn't.

@@ -1223,7 +1223,7 @@ ssl_run_tests()
SERVER_OPTIONS=
;;
"bypass")
Copy link
Contributor

@martinthomson martinthomson Sep 19, 2016

Choose a reason for hiding this comment

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

can we just remove the option entirely? I mean, it will disable tests without locks on, but those should be fine, modulo any threading errors they might expose (and we're not sure that the locks will guard against that anyhow).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's remove them.

Copy link
Contributor

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

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

lgtm modulo mt's comments. There might be more but we can do that in follow ups.

@@ -23,7 +23,7 @@ cd nss && make nss_build_all
# we run scan-build on these folders
declare -a scan=("lib/ssl" "lib/freebl")
# corresponds to the number of errors that are expected in the |scan| folder
declare -a ignore=(1 0)
declare -a ignore=(0 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep the ignores. The plan is to enable scan-build on other folders where we'll have the same problem.

@@ -1,716 +0,0 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

this removes the file? strange way to display the diff....

Copy link
Contributor

Choose a reason for hiding this comment

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

How would you show it? Just showing the filename and "deleted" means that you can't see what was deleted, which might be important.

if (requiredECCbits > signatureKeyStrength)
requiredECCbits = signatureKeyStrength;

ecGroup = ssl_GetECGroupWithStrength(NULL, requiredECCbits);
Copy link
Contributor

Choose a reason for hiding this comment

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

you can update ssl_GetECGroupWithStrength to assert the socket now. This is the only call that doesn't have a socket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More cleanup, yay, thanks!

@ttaubert ttaubert force-pushed the bug/1303224-remove-pk11-bypass branch from 4b3199e to de76a5b Compare September 20, 2016 12:25
@ttaubert
Copy link
Contributor Author

Rebased. r? @franziskuskiefer @martinthomson

@ttaubert ttaubert force-pushed the bug/1303224-remove-pk11-bypass branch from aa5bea4 to 51489b7 Compare September 20, 2016 12:58
if (!group || group->type != group_type_ec ||
group->bits < requiredECCbits) {
continue;
}
if (!ss || ssl_NamedGroupEnabled(ss, group)) {
Copy link
Contributor

@franziskuskiefer franziskuskiefer Sep 20, 2016

Choose a reason for hiding this comment

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

maybe assert the ss, just in case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@ttaubert ttaubert force-pushed the bug/1303224-remove-pk11-bypass branch from b85434a to 6bd6e62 Compare September 22, 2016 12:39
if (spec->bypassCiphers) {
/* This function doesn't support PKCS#11 bypass. We fallback on the
* non-constant time version. */
goto fallback;
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is only one case that calls that code, move it inline and remove the goto.

}
hashesForVerify = hashes;
} else {
if (!hashes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure that I understand given that the ssl3.hs.ws check is above this, but it's a nit only, so do as you see fit.

@ttaubert ttaubert force-pushed the bug/1303224-remove-pk11-bypass branch from 6bd6e62 to f8ea10b Compare September 23, 2016 22:13
@ttaubert ttaubert closed this Sep 24, 2016
@ttaubert ttaubert deleted the bug/1303224-remove-pk11-bypass branch September 24, 2016 09:05
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.

3 participants