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

WOLFSSL_SP_INT_NEGATIVE declaration for all Espressif chipsets #6374

Merged
merged 4 commits into from
May 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions wolfcrypt/src/port/Espressif/esp32_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
{
int ret = 0;

#ifdef WOLFSSL_SP_INT_NEGATIVE
int neg = (X->sign == Y->sign) ? MP_ZPOS : MP_NEG;
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend this just be int neg and keep the existing setting of it in CONFIG_IDF_TARGET_ESP32S3. The !CONFIG_IDF_TARGET_ESP32S3 case overrides this with a different value.

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 point on the code inconsistency. I left the declaration & assignment at the top and instead moved the Z->sign logic completely out of the IF/CONFIG sections.

The negative flag setting is now assigned regardless of IDF_TARGET_[n] value at the end of the function as updated in 2ec486e.

#endif

#if CONFIG_IDF_TARGET_ESP32S3

int BitsInX = mp_count_bits(X);
Expand All @@ -345,10 +349,6 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z)
int WordsForOperand = bits2words(MinXYBits);
int WordsForResult = bits2words(BitsInX + BitsInY);

#ifdef WOLFSSL_SP_INT_NEGATIVE
int neg;
neg = (X->sign == Y->sign) ? MP_ZPOS : MP_NEG;
#endif
/* Make sure we are within capabilities of hardware. */
if ( (WordsForOperand * BITS_IN_ONE_WORD) > ESP_HW_MULTI_RSAMAX_BITS ) {
ESP_LOGW(TAG, "exceeds max bit length(2048)");
Expand Down