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

RSA Decryption: check private value after decryption #7167

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

SparkiDev
Copy link
Contributor

Description

After RSA decryption check d is still valid.

Fixes zd#17266

Testing

Ran tests with WOLFSSL_RSA_CHECK_D_ON_DECRYPT defined.
Benchmark difference was negligible.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@SparkiDev SparkiDev assigned SparkiDev and wolfSSL-Bot and unassigned SparkiDev Jan 24, 2024
@@ -2723,6 +2723,17 @@ static int RsaFunctionSync(const byte* in, word32 inLen, byte* out,
if (mp_to_unsigned_bin_len_ct(tmp, out, (int)*outLen) != MP_OKAY)
ret = MP_TO_E;
}
#ifdef WOLFSSL_RSA_CHECK_D_ON_DECRYPT
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that should be on be default and optionally turned off rather than off be default and optionally turned on?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to enable with WOLFSSL_CHECK_SIG_FAULTS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WOLFSSL_CHECK_SIG_FAULTS is currently for signature and ECC.
This code is only for RSA decryption and not signing.
If there was a better generic 'check data after op' define, I would consider enabling it as part of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

@SparkiDev should this be on by default and have a different macro name to disable it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are very limited circumstances that would require the checking of d.
It is unnecessary work that we should avoided if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's merge as-is then document clearly those reasons

@@ -2723,6 +2723,17 @@ static int RsaFunctionSync(const byte* in, word32 inLen, byte* out,
if (mp_to_unsigned_bin_len_ct(tmp, out, (int)*outLen) != MP_OKAY)
ret = MP_TO_E;
}
#ifdef WOLFSSL_RSA_CHECK_D_ON_DECRYPT
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to enable with WOLFSSL_CHECK_SIG_FAULTS?

@@ -2723,6 +2723,17 @@ static int RsaFunctionSync(const byte* in, word32 inLen, byte* out,
if (mp_to_unsigned_bin_len_ct(tmp, out, (int)*outLen) != MP_OKAY)
ret = MP_TO_E;
}
#ifdef WOLFSSL_RSA_CHECK_D_ON_DECRYPT
Copy link
Contributor

Choose a reason for hiding this comment

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

@SparkiDev should this be on by default and have a different macro name to disable it?

@dgarske dgarske assigned SparkiDev and unassigned dgarske and JacobBarthelmeh Jan 29, 2024
@dgarske dgarske merged commit de4a6f9 into wolfSSL:master Jan 29, 2024
108 checks passed
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.

None yet

5 participants