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

Using Decode Raw RSA Private Key #705

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Conversation

ejohnstown
Copy link
Contributor

@ejohnstown ejohnstown commented Jun 1, 2024

  1. Add a check for wc_RsaPrivateKeyDecodeRaw() to configure.
  2. If wc_RsaPrivateKeyDecodeRaw() is available (from PR Import Raw RSA Private Key wolfssl#7608), use it to load the private key from GetOpenSshKeyRsa(). If unavailable, process the key the original way.

dgarske
dgarske previously approved these changes Jun 2, 2024
@ejohnstown

This comment was marked as outdated.

src/internal.c Outdated

#else /* HAVE_WC_RSAPRIVATEKEYDECODERAW */

#include <wolfssl/wolfcrypt/integer.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just include <wolfssl/wolfcrypt/wolfmath.h> now to handle all cases. Its possible integer.h (heap math) could be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.

src/internal.c Outdated
@@ -1353,6 +1352,46 @@ int IdentifyAsn1Key(const byte* in, word32 inSz, int isPrivate, void* heap)


#ifndef WOLFSSH_NO_RSA

#ifdef HAVE_WC_RSAPRIVATEKEYDECODERAW
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a portable way to detect this... meaning someone not using configure won't detect or use this new API. But its probably still the best option for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched this to checking that wolfSSL is greater than v5.7.0. The new function isn't available in v5.7.0.

src/internal.c Show resolved Hide resolved
1. If wc_RsaPrivateKeyDecodeRaw() is available, use it to load the
   private key from GetOpenSshKeyRsa(). If unavailable, process the key
   the original way.
2. Check for wolfSSL version and if greater than v5.7.0, the new
   function is available.
3. When loading an OpenSSH format RSA key, if wolfSSL's RSA_LOW_MEM is
   set, skip the u value, and do not calculate dP and dQ.
4. Rename RsaCalcInverses() to RsaCalcDX().
@dgarske dgarske merged commit 79ef513 into wolfSSL:master Jun 3, 2024
24 checks passed
@ejohnstown ejohnstown deleted the rsa-raw branch June 5, 2024 22:36
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Sep 24, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 18, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 29, 2024
jefferyq2 pushed a commit to jefferyq2/wolfssh that referenced this pull request Oct 29, 2024
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.

4 participants