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

ECC: blind private key after use in signing #7416

Merged
merged 2 commits into from
May 14, 2024

Conversation

SparkiDev
Copy link
Contributor

Description

Use a mask to blind the private key after use so that stored private key is always changing.

Fixes zd#17783

Testing

./configure '--disable-shared' 'CFLAGS=-DWOLFSSL_ECC_BLIND_K'

Checklist

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

@SparkiDev SparkiDev self-assigned this Apr 12, 2024
@SparkiDev SparkiDev force-pushed the ecc_blind_k branch 7 times, most recently from e06c022 to 361dc0b Compare April 18, 2024 06:14
@SparkiDev SparkiDev force-pushed the ecc_blind_k branch 4 times, most recently from 19a2d86 to 3c79312 Compare April 23, 2024 01:31
@SparkiDev SparkiDev assigned wolfSSL-Bot and unassigned SparkiDev May 9, 2024
@SparkiDev SparkiDev requested a review from wolfSSL-Bot May 9, 2024 12:47
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.

Have you checked code size and performance impact with the new options?

@@ -297,6 +297,48 @@ ECC Curve Sizes:

#endif

#ifdef WOLFSSL_ECC_BLIND_K
Copy link
Contributor

Choose a reason for hiding this comment

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

Please document WOLFSSL_BLIND_PRIVATE_KEY and WOLFSSL_ECC_BLIND_K at the top of ecc.c.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

void sp_xor_ct(const sp_int* a, const sp_int* b, int len, sp_int* r)
{
if ((a != NULL) && (b != NULL) && (r != NULL)) {
unsigned int i;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is unsigned int the right type here? Should it be sp_digit or sp_int_digit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'i' is only used as an index.
It shouldn't be sp_int_digit.

@@ -601,7 +612,17 @@ struct ecc_key {
#endif
};

#define wc_ecc_key_get_priv(key) ((key)->k)
#ifndef WOLFSSL_ECC_BLIND_K
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add WOLFSSL_LOCAL or WOLFSSL_API to these....

$./configure CFLAGS="-DWOLFSSL_ECC_BLIND_K -DWOLFSSL_BLIND_PRIVATE_KEY" && make
...
/usr/bin/ld: wolfcrypt/test/test.o: in function `ecc_def_curve_test':
test.c:(.text+0x1ae8): undefined reference to `ecc_get_k'
/usr/bin/ld: test.c:(.text+0x1af4): undefined reference to `ecc_get_k'
/usr/bin/ld: test.c:(.text+0x1b00): undefined reference to `ecc_get_k'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:6196: wolfcrypt/test/testwolfcrypt] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/davidgarske/GitHub/wolfssl'
make[1]: *** [Makefile:8391: check-recursive] Error 1
make[1]: Leaving directory '/home/davidgarske/GitHub/wolfssl'
make: *** [Makefile:8860: check] Error 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@dgarske dgarske assigned SparkiDev and unassigned wolfSSL-Bot May 13, 2024
Use a mask to blind the private key after use so that stored private key
is always changing.
When WOLFSSL_BLIND_PRIVATE_KEY is defined, blind the private key DER
encoding so that stored private key data is always changing.
@SparkiDev
Copy link
Contributor Author

retest this please

@SparkiDev SparkiDev assigned dgarske and wolfSSL-Bot and unassigned SparkiDev May 14, 2024
@dgarske dgarske merged commit 1c44798 into wolfSSL:master May 14, 2024
103 checks passed
jefferyq2 pushed a commit to jefferyq2/wolfssl that referenced this pull request Jun 9, 2024
ECC: blind private key after use in signing
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.

3 participants