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

Read PEM Keys #583

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Read PEM Keys #583

merged 1 commit into from
Sep 18, 2023

Conversation

ejohnstown
Copy link
Contributor

  1. Update wolfSSH_ReadKey_buffer() to decode PEM keys.
  2. Add detection of PEM files to wolfSSH_ReadKey_file().
  3. Add parameter labels to the prototypes of the ReadKey functions.

Test Cases

$ ./configure && make

$ ./examples/echoserver/echoserver -e
$ ./examples/client/client -u hansel -i keys/hansel-key-ecc.der -j keys/hansel-key-ecc.pub
$ ./examples/client/client -u hansel -i keys/hansel-key-ecc.pem -j keys/hansel-key-ecc.pub

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

src/ssh.c Outdated
ret = WS_SUCCESS;
}
else {
ret = WS_ERROR;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be helpful to use/capture or log the actual failure return code from wc_KeyPemToDer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating.

ret = IdentifyKey(newKey, newKeySz, 1, heap);
if (ret > 0) {
*outSz = newKeySz;
*outType = (const byte*)IdToName(ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a NULL check for *outType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

outType is checked for NULL. It is a pointer to a string pointer. We're assigning *outType a string pointer.

1. Update wolfSSH_ReadKey_buffer() to decode PEM keys.
2. Add detection of PEM files to wolfSSH_ReadKey_file().
3. Add parameter labels to the prototypes of the ReadKey functions.
@dgarske dgarske merged commit 417388c into wolfSSL:master Sep 18, 2023
@ejohnstown ejohnstown deleted the pem-keys branch September 18, 2023 20:06
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