-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
ejohnstown
commented
Jun 1, 2024
•
edited by dgarske
Loading
edited by dgarske
- Add a check for wc_RsaPrivateKeyDecodeRaw() to configure.
- 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.
This comment was marked as outdated.
This comment was marked as outdated.
src/internal.c
Outdated
|
||
#else /* HAVE_WC_RSAPRIVATEKEYDECODERAW */ | ||
|
||
#include <wolfssl/wolfcrypt/integer.h> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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().
Using Decode Raw RSA Private Key
Using Decode Raw RSA Private Key
Using Decode Raw RSA Private Key
Using Decode Raw RSA Private Key