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

Implement support for ALWAYS_AUTH and interactive prompting when the caller did not provide pin #309

Merged
merged 7 commits into from
Nov 30, 2023

Conversation

Jakuje
Copy link
Contributor

@Jakuje Jakuje commented Nov 16, 2023

Based on #298. The current version passes all existing tests and the default UI is not gated with a configuration option (but this can be added if needed).

Fixes #295 and #42

Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

in general it looks good to me, but there are some nits we can discuss.

src/signature.c Show resolved Hide resolved
src/session.c Outdated
ret = CKR_GENERAL_ERROR;
goto done;
/* this error can mean anything from the user canceling the prompt to no UI method provided
* Fall back to our prompt here */
Copy link
Member

Choose a reason for hiding this comment

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

if we did have a callback I do not think we should repeat the prompting,
we should prompt on our own if no callback is present, gated behind a config option that enables this behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As described in this comment, from store, we are always getting a callback, but if the calling application does not provide the UI, it just fails. I think we are getting the pointer to ossl_pw_get_passphrase() function from crypto/passphrase.c unconditionally. And based on what application provided, it works of fails with No password method specified:
https://github.com/openssl/openssl/blob/cf6342bc024868f5a55f2225f2e083415fb1329a/crypto/passphrase.c#L275

src/session.c Outdated
goto done;
/* We are asking the user off-band for the user consent -- from store
* we will always receive non-null (but unusable) callback */
ret = p11prov_session_get_pin(slot, (char *)cb_pin, &cb_pin_len);
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 gate this, see above

src/session.c Outdated Show resolved Hide resolved
@Jakuje Jakuje force-pushed the always_auth branch 3 times, most recently from e12ca0e to 9aec79f Compare November 20, 2023 14:56
@Jakuje Jakuje force-pushed the always_auth branch 2 times, most recently from c88fae3 to a69e05f Compare November 28, 2023 16:18
Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

Only two very minor nits, if you can quickly address them I'd like to merge asap.

src/session.c Outdated Show resolved Hide resolved
}
} else {
/* We are asking the user off-band for the user consent -- from
* store we will always receive non-null (but unusable) callback
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this is unusable? When we receive a callback it is always usable, the problem is that often we just do not have one, and we can't store the callback we were provided for the store operation for later operations as the calling application may not expect it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed above, from the store we will always get a callback (at least in OpenSSL in Fedora 38), but the callback just fails with the error mentioned above.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I do not get it, if pw_cb is empty it means we got a NULL callback, not an unusable one, so I am not sure what this comment means.

I guess we can change it later, but I would relaly like to understand what you meant to convey here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its the conversion from the UI methods on the store API to the low-level callbacks on the provider level. What you describe would make sense and I would be assuming this, but this is OpenSSL. So when the store API is called without the UI method, the provider gets non-null callback, but that one fails because there is no assigned UI method. Sounds as stupid as it is (or I followed the gdb wrongly -- there is obviously no documentation. You can double-check that this wont work if you remove this code branch).

@Jakuje
Copy link
Contributor Author

Jakuje commented Nov 29, 2023

Only two very minor nits, if you can quickly address them I'd like to merge asap.

So lets keep it for now without the configuration option discussed previously?

@Jakuje
Copy link
Contributor Author

Jakuje commented Nov 29, 2023

Noting here, that the macos CI picked up gnutls 3.8.2 with the following regression in handling ed25519 keys: https://gitlab.com/gnutls/gnutls/-/issues/1515

@Jakuje
Copy link
Contributor Author

Jakuje commented Nov 30, 2023

Noting here, that the macos CI picked up gnutls 3.8.2 with the following regression in handling ed25519 keys: https://gitlab.com/gnutls/gnutls/-/issues/1515

And now we have the broken gnutls also in Fedora 39. The update to Fedora 38 is on the way too:

https://bodhi.fedoraproject.org/updates/FEDORA-2023-e075ac32be

@simo5 simo5 merged commit c741dc1 into latchset:main Nov 30, 2023
18 of 19 checks passed
@simo5
Copy link
Member

simo5 commented Nov 30, 2023

Merged, and opened a followup issue for the gating config option.

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.

Consider a default callback call for PIN requests
2 participants