Skip to content

Conversation

@gojimmypi
Copy link
Contributor

@gojimmypi gojimmypi commented Feb 28, 2025

Description

This PR introduces a new AES CTR (Counter Mode) Arduino example sketch along with supporting template files and configuration updates. The example demonstrates AES CTR encryption and decryption capabilities of wolfSSL on Arduino platforms.

edit: Moving Arduino examples. See wolfSSL/wolfssl-examples#499

edit (2): Expanded the scope of handling the various combinations of these macros in user_settings.h:

  • #define NO_TLS
  • #define WOLFCRYPT_ONLY
  • #define NO_WOLFSSL_CLIENT
  • #define NO_WOLFSSL_SERVER

Some combinations would cause compiler warnings about things declared and note used. Additional gating applied to handle this.

One combination now causes a hard error via settings.h:

//#define NO_TLS
//#define WOLFCRYPT_ONLY
#define NO_WOLFSSL_CLIENT
#define NO_WOLFSSL_SERVER

Key Changes

  1. New AES CTR Example:

    • Added IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.ino - A complete example demonstrating AES CTR encryption/decryption
    • Added supporting project files (README.md, .adeps, .sln, .vgdbproj) for various Arduino IDE environments
    • Tested on Arduino using Teensy 4.1 (ARM Cortex-M7 at 600 MHz)
    • AES CTR GPLV2 Contributed by Chris Jennings Feb 2025; Thank you!
  2. Arduino Template Example:

    • Added IDE/ARDUINO/sketches/template/ directory with reference template files
    • Includes multi-file example structure with helper files and library organization
    • Provides VisualGDB project files for easier development
  3. Configuration Updates:

    • Updated examples/configs/user_settings_arduino.h to include AES CTR support
    • Added WOLFSSL_AES and WOLFSSL_AES_COUNTER macros
    • Updated version identifier to v5.7.6
    • Added ECC and RSA hardening options
  4. Arduino Integration Improvements:

    • Added wolfssl-arduino.cpp with Arduino-specific Serial.print helper function
    • Updated wolfssl.h to properly declare the helper function
    • Updated wolfssl-arduino.sh script to include the new cpp file in Arduino library builds
  5. Documentation Updates:

    • Updated IDE/ARDUINO/README.md with references to new examples
    • Updated IDE/ARDUINO/sketches/README.md to include new examples
    • Added troubleshooting information for common Arduino build issues
  6. Code Cleanup:

    • Fixed file locations and directory references
    • Removed stray tabs and improved formatting
    • Fixed spelling errors in documentation and comments

Fixes zd# 19275

Testing

How did you test?

Tested on Arduino using Teensy 4.1

  • ARM Cortex-M7 at 600 MHz
  • Float point math unit, 64 & 32 bits
  • 7936K Flash, 1024K RAM (512K tightly coupled), 4K EEPROM (emulated)
  • QSPI memory expansion, locations for 2 extra RAM or Flash chips

See https://www.pjrc.com/store/teensy41.html

Checklist

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

@gojimmypi gojimmypi requested a review from dgarske February 28, 2025 02:09
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from 7fc7e57 to 8ce26d8 Compare February 28, 2025 02:31
@gojimmypi
Copy link
Contributor Author

Jenkins retest this please

to retry "Unable to create live FilePath for wolf-linux-cloud-node"

@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from 8ce26d8 to 34043ab Compare March 3, 2025 20:10
@gojimmypi
Copy link
Contributor Author

Edit: I added a new updated file: examples/configs/user_settings_arduino.h that includes these macros for the AES_CTR example that would otherwise need to be added manually.

#define WOLFSSL_AES
#define WOLFSSL_AES_COUNTER

This user_settings_arduino.h file will be the new default user_settings.h for the next release of the Arduino-wolfSSL library. In the meantime, the changes can be made manually or with the install script.

I also included some minor changes to avoid warnings in Arduino related to hardening and not using client nor server examples.

@gojimmypi
Copy link
Contributor Author

Jenkins retest this please.

To retry unrelated DTLS 1.3 group 6 failure 4740 "invalid stream header: 636F7272"

@dgarske dgarske removed their assignment Mar 7, 2025
@gojimmypi gojimmypi requested a review from dgarske March 11, 2025 20:50
@gojimmypi gojimmypi changed the title Introduce wolfssl_AES_CTR Arduino example Introduce new Arduino examples and configuration updates. TLSX gating Mar 11, 2025
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch 2 times, most recently from 34d7a35 to c4a2975 Compare March 11, 2025 23:46
@gojimmypi
Copy link
Contributor Author

Jenkins retest this please.

For "Unable to create live FilePath for wolf-linux-cloud-node-nnn; wolf-linux-cloud-node-nnn was marked offline: Connection was broken"

@dgarske I've expanded the scope of this PR to include an additional example. See ZD 19275. Updated description and PR title.

In particular note the new additional gating changes to tls.c that otherwise gave compiler warnings depending on client / server settings.

@gojimmypi
Copy link
Contributor Author

Jenkins retest this please.

multi-test-script 5141 unavailable.

@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from c4a2975 to b72edc7 Compare March 13, 2025 21:45
@gojimmypi
Copy link
Contributor Author

Jenkins retest this please.

no output (or no permissions?) to test 4416.

java.io.StreamCorruptedException: invalid stream header in 7660

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.

Is it possible to put these example into wolfssl-examples or another public repo?

@dgarske dgarske removed their assignment Mar 20, 2025
@gojimmypi
Copy link
Contributor Author

gojimmypi commented Mar 21, 2025

Yes, it's certainly possible, although that would not have been my first choice. I get it that wolfSSL could contain only the core library, and arguably no examples at all.

It should be possible to modify the Arduino publishing script to pull from multiple repositories (core + examples) and push everything to the Arduino-wolfSSL repo for publishing to Arduino (or a local directory).

Do you prefer that all or only some of the Arduino examples be moved?

@dgarske
Copy link
Contributor

dgarske commented Mar 26, 2025

@gojimmypi in my opinion its better to split out library changes like TLSX gating and this Arduino feature to separate PR's. I also think you should not have the Arduino examples in the library proper. They should be in a different repo like wolfssl-examples.

@gojimmypi
Copy link
Contributor Author

@dgarske I've created wolfSSL/wolfssl-examples#499 to move the Arduino examples.

It will be a multi-step process. I'll next remove the examples from this repo in this PR, leaving only the README.md files that are known to be included in docs, blogs, other PRs, etc.

Once the wolfssl-examples PR is merged, I will create a new PR here to modify the install script to pull the examples from new location when publishing to Arduino-wolfSSL.

Once this PR is merged, I'll create a new PR in the wolfssl-examples to enable more testing in the new arduino.yml workflow file that would otherwise fail without the changes in this PR.

@dgarske dgarske removed their assignment Apr 9, 2025
@gojimmypi gojimmypi requested a review from dgarske April 9, 2025 19:18
@dgarske
Copy link
Contributor

dgarske commented Apr 11, 2025

Retest this please: multiple "Found unhandled org.jenkinsci.plugins.workflow.support.steps.AgentOfflineException exception:".

@dgarske dgarske removed their assignment Apr 11, 2025
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from bf66445 to 254a2fb Compare April 11, 2025 17:51
@gojimmypi gojimmypi requested a review from dgarske April 11, 2025 17:53
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from 1b83efb to 8e5a613 Compare April 11, 2025 19:47
@gojimmypi gojimmypi requested a review from dgarske April 11, 2025 19:52
@dgarske
Copy link
Contributor

dgarske commented Apr 11, 2025

Retest this please: "Found unhandled hudson.remoting.RequestAbortedException exception:"

@dgarske dgarske removed their assignment Apr 11, 2025
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from 8e5a613 to dd5b228 Compare April 11, 2025 23:00
@gojimmypi
Copy link
Contributor Author

No, just one error and one section that includes !WOLFCRYPT_ONLY && !NO_TLS

Yes, I had that at one point, but when the WOLFCRYPT_ONLY was missing, the error was not very intuitive.

In any case, I've applied your exact change as exactly specified.

@dgarske dgarske removed their assignment Apr 12, 2025
@gojimmypi gojimmypi force-pushed the pr-introduce-arduino-wolfssl_AES_CTR branch from 844f2e3 to 241a1ed Compare April 12, 2025 13:38
@gojimmypi
Copy link
Contributor Author

Jenkins retest this please

for Unable to create live FilePath for wolf-linux-cloud-node-nnn; marked offline: Connection was broken

@dgarske dgarske merged commit b38ab8a into wolfSSL:master Apr 12, 2025
186 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.

3 participants