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

Conversation

gojimmypi
Copy link
Contributor

Description

This minor PR changes the scope of the neg variable to be declared for all Espressif chipsets, not just the ESP32-S3.

Fixes #6373

See

Fixes zd# n/a

Testing

How did you test?

Ran the wolfssl_test for the ESP32 with #define OPENSSL_ALL in user_settings.h

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:6996
load:0x40078000,len:15352
load:0x40080400,len:3628
entry 0x4008061c
I (26) boot: ESP-IDF v5.0-dirty 2nd stage bootloader
I (26) boot: compile time 09:33:12
I (26) boot: chip revision: v1.0
I (29) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (37) boot.esp32: SPI Speed      : 80MHz
I (41) boot.esp32: SPI Mode       : DIO
I (46) boot.esp32: SPI Flash Size : 2MB
I (50) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (67) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (74) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (81) boot:  2 factory          factory app      00 00 00010000 00177000
I (89) boot: End of partition table
I (93) boot_comm: chip revision: 1, min. application chip revision: 0
I (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1c7e4h (116708) map
I (144) esp_image: segment 1: paddr=0002c80c vaddr=3ffb0000 size=01db4h (  7604) load
I (147) esp_image: segment 2: paddr=0002e5c8 vaddr=40080000 size=01a50h (  6736) load
I (152) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=4a564h (304484) map
I (250) esp_image: segment 4: paddr=0007a58c vaddr=40081a50 size=09384h ( 37764) load
I (264) esp_image: segment 5: paddr=00083918 vaddr=50000000 size=00010h (    16) load
I (269) boot: Loaded app from partition at offset 0x10000
I (269) boot: Disabling RNG early entropy source...
I (284) cpu_start: Pro cpu up.
I (284) cpu_start: Single core mode
I (292) cpu_start: Pro cpu start user code
I (292) cpu_start: cpu freq: 160000000 Hz
I (292) cpu_start: Application information:
I (297) cpu_start: Project name:     wolfssl_test
I (302) cpu_start: App version:      v5.6.0-stable-328-g714ec82e9
I (309) cpu_start: Compile time:     May  3 2023 09:32:18
I (315) cpu_start: ELF file SHA256:  c6683bf958023766...
I (321) cpu_start: ESP-IDF:          v5.0-dirty
I (327) heap_init: Initializing. RAM available for dynamic allocation:
I (334) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (340) heap_init: At 3FFB2600 len 0002DA00 (182 KiB): DRAM
I (346) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (352) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (359) heap_init: At 4008ADD4 len 0001522C (84 KiB): IRAM
I (365) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAM
I (372) spi_flash: detected chip: generic
I (376) spi_flash: flash io: dio
W (380) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Usi
ng the size in the binary image header.
I (393) cpu_start: Starting scheduler on PRO CPU.
I (398) wolfssl_test: --------------------------------------------------------
I (398) wolfssl_test: --------------------------------------------------------
I (408) wolfssl_test: ---------------------- BEGIN MAIN ----------------------
I (418) wolfssl_test: --------------------------------------------------------
I (428) wolfssl_test: --------------------------------------------------------
I (428) wolfssl_test: CONFIG_IDF_TARGET = esp32
I (438) wolfssl_test: LIBWOLFSSL_VERSION_STRING = 5.6.0
I (448) wolfssl_test: LIBWOLFSSL_VERSION_GIT_HASH = 714ec82e912ea91dc71227134e566e355df0ff46
I (448) wolfssl_test: LIBWOLFSSL_VERSION_GIT_SHORT_HASH = 714ec82e9
I (458) wolfssl_test: LIBWOLFSSL_VERSION_GIT_HASH_DATE = 'Wed May 3 07:50:23 2023 -0700'
I (468) wolfssl_test: CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ = 160 MHz
I (478) wolfssl_test: Xthal_have_ccount = 1
I (478) wolfssl_test: Stack HWM: 53792

I (488) wolfssl_test: ESP32WROOM32_CRYPT is enabled.
------------------------------------------------------------------------------
 wolfSSL version 5.6.0
------------------------------------------------------------------------------
error    test passed!
MEMORY   test passed!
base64   test passed!
base16   test passed!
asn      test passed!
RANDOM   test passed!
MD5      test passed!
MD4      test passed!
SHA      test passed!
SHA-224  test passed!
SHA-256  test passed!
SHA-512  test passed!
SHA-512/224  test passed!
SHA-512/256  test passed!
Hash     test passed!
HMAC-MD5 test passed!
HMAC-SHA test passed!
HMAC-SHA224 test passed!
HMAC-SHA256 test passed!
HMAC-SHA512 test passed!
HMAC-KDF    test passed!
TLSv1.3 KDF test passed!
GMAC     test passed!
DES      test passed!
DES3     test passed!
AES      test passed!
AES192   test passed!
AES256   test passed!
AES-GCM  test passed!
RSA      test passed!
PWDBASED test passed!
OPENSSL  test passed!
OPENSSL (EVP MD) passed!
OPENSSL (PKEY0) passed!
OPENSSL (PKEY1) passed!
OPENSSL (EVP Sign/Verify) passed!
ECC      test passed!
ECC buffer test passed!
CURVE25519 test passed!
ED25519  test passed!
logging  test passed!
time test passed!
mutex    test passed!
Test complete
I (162778) wolfcrypt_test: Exiting main with return code:  0

I (162778) wolfssl_test: wolf_test_task complete success result code = 0

@gojimmypi gojimmypi self-assigned this May 3, 2023
@gojimmypi gojimmypi added the bug label May 3, 2023
@gojimmypi gojimmypi requested a review from dgarske May 3, 2023 17:54
@gojimmypi
Copy link
Contributor Author

The Jenkins error is unrelated to the changes in this PR:

configure: error: unrecognized option: `-DWOLFSSL_MULTI_ATTRIB''

@@ -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.

@dgarske dgarske removed their assignment May 3, 2023
wolfcrypt/src/port/Espressif/esp32_mp.c Show resolved Hide resolved

#ifdef WOLFSSL_SP_INT_NEGATIVE
/* neg check: X*Y becomes negative */
int neg = (mp_isneg(X) == mp_isneg(Y)) ? MP_ZPOS : MP_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.

C style /* */ comments please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

erg. small monitor. miss that. fixed, thanks.

@gojimmypi
Copy link
Contributor Author

I've updated the original description to include a note regarding an additional minor but critical change to esp32_sha.c needed when WOLFSSL_SHA384 is enabled.

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.

Changes look good.

@dgarske dgarske merged commit 82e502d into wolfSSL:master May 4, 2023
joeftiger pushed a commit to joeftiger/wolfssl that referenced this pull request Sep 2, 2023
…SL#6374)

* WOLFSSL_SP_INT_NEGATIVE declaration for all Espressif chipsets
* correct naming for WOLFSSL_SHA384 on ESP32-C3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Enabling OPENSSL_ALL on the ESP32 causes compile error related to WOLFSSL_SP_INT_NEGATIVE
2 participants