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

wolfSSH support for using TPM based key for authentication #754

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

aidangarske
Copy link

@aidangarske aidangarske commented Dec 13, 2024

Description

wolfSSH tpm support using client side public key authentication with rsa. Code working just like the non tpm public key authentication.with rsa

Testing

Just SSH

For ssh public key auth with rsa use ./examples/echoserver/echoserver and for client side use the command:

./examples/client/client -u hansel -i ./keys/hansel-key-rsa.der -j ./keys/hansel-key-rsa.pub

With TPM

For tpm based public key auth with rsa use a tpm simulator and ./examples/echoserver/echoserver and for client use the command:

./examples/client/client -i ../wolfTPM/keyblob.bin -u hansel

Note: refer to the README for detailed build steps and further information.

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Various errors building without TPM:

src/ssh.c:1810:15: error: call to undeclared function 'wc_PubKeyPemToDer'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        ret = wc_PubKeyPemToDer(in, inSz, newKey, newKeySz);
              ^
src/ssh.c:1810:15: note: did you mean 'wc_KeyPemToDer'?
/Users/runner/work/wolfssh/wolfssh/build-dir/include/wolfssl/wolfcrypt/asn_public.h:692:21: note: 'wc_KeyPemToDer' declared here
    WOLFSSL_API int wc_KeyPemToDer(const unsigned char* pem, int pemSz,
                    ^
1 error generated.
make[1]: *** [src/libwolfssh_la-ssh.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
src/internal.c:12950:25: error: unused variable 'sigSz' [-Werror,-Wunused-variable]
                    int sigSz;
                        ^
1 error generated.

src/ssh.c Show resolved Hide resolved
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

This PR is very close to ready. Let's change it to use endorsement primary key are parent to avoid the SRK handle/auth.


#define TPM2_DEMO_STORAGE_KEY_HANDLE 0x81000200 /* Persistent Storage Key Handle (RSA) */

static const char gStorageKeyAuth[] = "ThisIsMyStorageKeyAuth";
Copy link
Contributor

Choose a reason for hiding this comment

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

The SRK handle and password being hard coded is not good. Both of these should be macros wrapped with #ifndef at a minimum. Ideally they would be arguments to the example client or not needed at all.

If I were writing this example I would create the key using the endorsement primary key... then you would not need anything related to the SRK... It's a pretty easy change, mostly to your README.md to create the key under the endorsement hierarchy using -eh.

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.

2 participants