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

Enable using objects with no user PIN #695

Merged

Conversation

niooss-ledger
Copy link
Contributor

Using password-less SSH keys is a nice feature, which can be achieved in PKCS#11 by not setting CKF_LOGIN_REQUIRED in token information.

The information whether a PIN is empty or not is stored in a new attribute of the token configuration, named empty-user-pin. This attribute is set when tpm2_ptool addtoken is used with --userpin="" and it is updated when users change their PIN using tpm2_ptool changepin or tpm2_ptool initpin.

In src/pkcs11.c, update auth_min_ro_user in order to accept using functions such as C_SignInit without the user being logged in, when the user PIN is empty.

Regarding operations related to the TPM, using no user PIN is implemented as using an empty PIN. So table sealobjects is still used to unseal the wrapping key. The main difference between "no PIN" and "a usual PIN" is that an empty string is combined with userauthsalt instead of a user PIN.

With this change, using OpenSSH client does not prompt for a PIN code,
when using a key stored in a token with an empty PIN.

Fixes: #629

Using password-less SSH keys is a nice feature, which can be achieved in
PKCS#11 by not setting `CKF_LOGIN_REQUIRED` in token information.

The information whether a PIN is empty or not is stored in a new
attribute of the token configuration, named `empty-user-pin`. This
attribute is set when `tpm2_ptool addtoken` is used with `--userpin=""`
and it is updated when users change their PIN using
`tpm2_ptool changepin` or `tpm2_ptool initpin`.

In `src/pkcs11.c`, update `auth_min_ro_user` in order to accept using
functions such as `C_SignInit` without the user being logged in, when
the user PIN is empty.

Regarding operations related to the TPM, using no user PIN is
implemented as using an empty PIN. So table `sealobjects` is still used
to unseal the wrapping key. The main difference between "no PIN" and "a
usual PIN" is that an empty string is combined with `userauthsalt`
instead of a user PIN.

With this change, using OpenSSH client does not prompt for a PIN code,
when using a key stored in a token with an empty PIN.

Fixes: tpm2-software#629

Signed-off-by: Nicolas Iooss <nicolas.iooss@ledger.fr>
Signed-off-by: Nicolas Iooss <nicolas.iooss@ledger.fr>
@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #695 (fd50ffb) into master (06ca8f4) will decrease coverage by 0.18%.
The diff coverage is 43.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #695      +/-   ##
==========================================
- Coverage   73.34%   73.16%   -0.19%     
==========================================
  Files          33       33              
  Lines        8989     9039      +50     
==========================================
+ Hits         6593     6613      +20     
- Misses       2396     2426      +30     
Impacted Files Coverage Δ
src/lib/emitter.c 54.02% <10.00%> (-1.76%) ⬇️
src/lib/token.c 78.86% <40.00%> (-4.63%) ⬇️
src/lib/object.c 74.11% <100.00%> (ø)
src/lib/parser.c 75.88% <100.00%> (+0.23%) ⬆️
src/pkcs11.c 76.43% <100.00%> (+0.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06ca8f4...fd50ffb. Read the comment docs.

@williamcroberts williamcroberts merged commit 4e45b2e into tpm2-software:master Aug 12, 2021
@niooss-ledger niooss-ledger deleted the feature-empty-user-pin branch August 14, 2021 18:22
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.

Creating SSH keys without a PIN
2 participants