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

Add 'ec-ecparam.softhsm' test #465

Merged
merged 2 commits into from
Aug 10, 2022
Merged

Conversation

ulrichb
Copy link
Contributor

@ulrichb ulrichb commented Aug 10, 2022

This adds an additional test for #456.

It runs openssl ecparam -genkey ... with an additional -engine pkcs11.

The test passes after @dengert's fixes for #456 (commit 5ab3c0d) ... but not on the current master.

The commit which breaks the test is feb22a6. When reverting this commit on the current master the test becomes green (and all other are green too).

@mtrojnar
Copy link
Member

It needs chmod a+x tests/ec-ecparam.softhsm.

@ulrichb
Copy link
Contributor Author

ulrichb commented Aug 10, 2022

Ooops, committed it under Windows. Fixed.

@ulrichb
Copy link
Contributor Author

ulrichb commented Aug 10, 2022

... now they run and - yipee - the ec-ecparam.softhsm test fails. And as expected only in the OpenSSL 3 builds.

@mtrojnar mtrojnar merged commit 5c5e2b6 into OpenSC:master Aug 10, 2022
@mtrojnar
Copy link
Member

Thank you. This test will be very useful for fixing it and and for finding any future regressions.

mtrojnar added a commit that referenced this pull request Aug 13, 2022
This test only works on OpenSSL 1.1.1, because while `openssl ecparam`
opens the engine specified in the `-engine` parameter, it never uses the
engine for actual key generation.

This bug in OpenSSL 1.1.1 can be easily confirmed with:
```sh
$ openssl version
OpenSSL 1.1.1n  15 Mar 2022
$ pkcs11-tool --list-token-slots
Available slots:
No slots.
$ openssl ecparam -engine pkcs11 -name prime256v1 -genkey -out ec_key.pem
engine "pkcs11" set.
$ cat ec_key.pem
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEILV/lcPsKV8J37hOf7nMmT9FBgync4fLx73HkH+STektoAoGCCqGSM49
AwEHoUQDQgAE5+qQeMjnQNZJrkB1RuwjDgvpTec2diaQR94K2xIy+aqawRFCUnCn
5HXHrIwCMtpb7LwRikA8tuQxtSKfPIILXw==
-----END EC PRIVATE KEY-----
```

Generating a key on an engine and saving the private key to a file is
*not* a functionality that we want to support.  It's easier, faster and
more secure to generate the key pair in software instead.

This reverts commit 5c5e2b6 (#465).
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.

None yet

2 participants