Skip to content

Commit

Permalink
Introduce wolfssl_AES_CTR ARduino example
Browse files Browse the repository at this point in the history
  • Loading branch information
gojimmypi committed Feb 28, 2025
1 parent d63a180 commit 7fc7e57
Show file tree
Hide file tree
Showing 7 changed files with 610 additions and 1 deletion.
20 changes: 19 additions & 1 deletion IDE/ARDUINO/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@
# included from Top Level Makefile.am
# All paths should be given relative to the root

# Library files:
EXTRA_DIST+= IDE/ARDUINO/README.md

# There's an Arduino-specific Arduino_README_prepend.md that will be prepended to wolfSSL README.md
# Not to be confused with the interim PREPENDED_README.md that is created by script.
EXTRA_DIST+= IDE/ARDUINO/Arduino_README_prepend.md

EXTRA_DIST+= IDE/ARDUINO/wolfssl.h

EXTRA_DIST+= IDE/ARDUINO/keywords.txt
EXTRA_DIST+= IDE/ARDUINO/library.properties.template

EXTRA_DIST+= IDE/ARDUINO/sketches/README.md
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/README.md
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino

EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/README.md
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino

EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/README.md
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino
EXTRA_DIST+= IDE/ARDUINO/wolfssl.h

EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/README.md
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.adeps
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.sln
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.vgdbproj
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR/wolfssl_AES_CTR.ino

# Publishing script, either local install or to GitHub PR
EXTRA_DIST+= IDE/ARDUINO/wolfssl-arduino.sh
2 changes: 2 additions & 0 deletions IDE/ARDUINO/sketches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

There are currently two example Arduino sketches:

* [wolfssl_AES_CTR](./wolfssl_AES_CTR/README.md): Basic AES CTR Encryption / Decryption example.
* [wolfssl_client](./wolfssl_client/README.md): Basic TLS listening client.
* [wolfssl_server](./wolfssl_server/README.md): Basic TLS server.
* [wolfssl_version](./wolfssl_version/README.md): Bare-bones wolfL eample.

Check failure on line 8 in IDE/ARDUINO/sketches/README.md

View workflow job for this annotation

GitHub Actions / codespell

eample ==> example

Examples have been most recently confirmed operational on the
[Arduino IDE](https://www.arduino.cc/en/software) 2.2.1.
Expand Down
34 changes: 34 additions & 0 deletions IDE/ARDUINO/sketches/wolfssl_AES_CTR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Arduino AES CTR Example

Open the [wolfssl_AES_CTR.ino](./wolfssl_AES_CTR.ino) file in the Arduino IDE.

Other IDE products are also supported, such as:

- [PlatformIO in VS Code](https://docs.platformio.org/en/latest/frameworks/arduino.html)
- [VisualGDB](https://visualgdb.com/tutorials/arduino/)
- [VisualMicro](https://www.visualmicro.com/)

For examples on other platforms, see the [IDE directory](https://github.com/wolfssl/wolfssl/tree/master/IDE).
Additional examples can be found on [wolfSSL/wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/).


### Troubleshooting

When encountering odd errors such as `undefined reference to ``_impure_ptr'`, such as this:

```text
c:/users/gojimmypi/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\gojimmypi\AppData\Local\Temp\arduino\sketches\EAB8D79A02D1ECF107884802D893914E\libraries\wolfSSL\wolfcrypt\src\logging.c.o:(.literal.wolfssl_log+0x8): undefined reference to `_impure_ptr'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
```

Try cleaning the Arduino cache directories. For Windows, that's typically in:

```text
C:\Users\%USERNAME%\AppData\Local\Temp\arduino\sketches
```

Remove all other boards from other serial ports, leaving one the one being programmed.
21 changes: 21 additions & 0 deletions IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.adeps
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Add this file to source control in order to automatically restore library dependencies when opening the project on another machine -->
<ArduinoDependencyCollection xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Dependencies>
<Dependency>
<Type>Platform</Type>
<Key>
<Packager>teensy</Packager>
<Name>avr</Name>
<Version>1.59.0</Version>
</Key>
</Dependency>
<Dependency>
<Type>Library</Type>
<Key>
<Packager>wolfSSL Inc.</Packager>
<Name>wolfssl</Name>
<Version>5.7.6</Version>
</Key>
</Dependency>
</Dependencies>
</ArduinoDependencyCollection>
22 changes: 22 additions & 0 deletions IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35728.132 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{803FD0C6-D64E-4E16-9DC3-1DAEC859A3D2}") = "wolfssl_AES_CTR", "wolfssl_AES_CTR.vgdbproj", "{86FF6ABD-3C7F-446C-B2CE-93E488EA77D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Teensy_4 1 = Debug|Teensy_4 1
Release|Teensy_4 1 = Release|Teensy_4 1
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{86FF6ABD-3C7F-446C-B2CE-93E488EA77D9}.Debug|Teensy_4 1.ActiveCfg = Debug|Teensy_4 1
{86FF6ABD-3C7F-446C-B2CE-93E488EA77D9}.Debug|Teensy_4 1.Build.0 = Debug|Teensy_4 1
{86FF6ABD-3C7F-446C-B2CE-93E488EA77D9}.Release|Teensy_4 1.ActiveCfg = Release|Teensy_4 1
{86FF6ABD-3C7F-446C-B2CE-93E488EA77D9}.Release|Teensy_4 1.Build.0 = Release|Teensy_4 1
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
249 changes: 249 additions & 0 deletions IDE/ARDUINO/sketches/wolfssl_AES_CTR/wolfssl_AES_CTR.vgdbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
<?xml version="1.0"?>
<VisualGDBProjectSettings2 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Project xsi:type="com.visualgdb.project.external.arduino">
<CustomSourceDirectories>
<Directories />
<PathStyle>Unknown</PathStyle>
</CustomSourceDirectories>
<AutoProgramSPIFFSPartition>true</AutoProgramSPIFFSPartition>
<ProjectModeSettings>
<ProjectGUID>86ff6abd-3c7f-446c-b2ce-93e488ea77d9</ProjectGUID>
<GroupSourcesByTypes>true</GroupSourcesByTypes>
<GroupSourcesByPaths>true</GroupSourcesByPaths>
<SketchSubdirectory>wolfssl_AES_CTR</SketchSubdirectory>
<MainSketchFile>wolfssl_AES_CTR.ino</MainSketchFile>
<RootSketchFolder>
<Subfolders />
<Files>
<string>wolfssl_AES_CTR.ino</string>
</Files>
</RootSketchFolder>
<OtherFiles />
</ProjectModeSettings>
</Project>
<Build xsi:type="com.visualgdb.build.external.arduino">
<BuildLogMode xsi:nil="true" />
<IgnoreNormalLibraryDirectories>false</IgnoreNormalLibraryDirectories>
<OutputSubdirectory>Output\$(PlatformName.defuse)\$(ConfigurationName.defuse)</OutputSubdirectory>
<EnableVerboseBuild>false</EnableVerboseBuild>
<PreprocessorMacros />
<ExtraLinkerFlags>
<string>-Wl,-q</string>
</ExtraLinkerFlags>
<AutoBuildSPIFFSPartition>true</AutoBuildSPIFFSPartition>
</Build>
<CustomBuild>
<PreSyncActions />
<PreBuildActions />
<PostBuildActions />
<PreCleanActions />
<PostCleanActions />
</CustomBuild>
<CustomDebug>
<PreDebugActions />
<PostDebugActions />
<DebugStopActions />
<BreakMode>Default</BreakMode>
</CustomDebug>
<DeviceTerminalSettings>
<Connection xsi:type="com.sysprogs.terminal.connection.serial">
<ComPortName>COM102</ComPortName>
<AdvancedSettings>
<BaudRate>115200</BaudRate>
<DataBits>8</DataBits>
<Parity>None</Parity>
<StopBits>One</StopBits>
<FlowControl>None</FlowControl>
</AdvancedSettings>
</Connection>
<LastConnectionTime>0</LastConnectionTime>
<EchoTypedCharacters>false</EchoTypedCharacters>
<ClearContentsWhenReconnecting>false</ClearContentsWhenReconnecting>
<ReconnectAutomatically>false</ReconnectAutomatically>
<DisplayMode>ASCII</DisplayMode>
<Colors>
<Background>
<Alpha>255</Alpha>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Background>
<Disconnected>
<Alpha>255</Alpha>
<Red>169</Red>
<Green>169</Green>
<Blue>169</Blue>
</Disconnected>
<Text>
<Alpha>255</Alpha>
<Red>211</Red>
<Green>211</Green>
<Blue>211</Blue>
</Text>
<Echo>
<Alpha>255</Alpha>
<Red>144</Red>
<Green>238</Green>
<Blue>144</Blue>
</Echo>
<Inactive>
<Alpha>255</Alpha>
<Red>169</Red>
<Green>169</Green>
<Blue>169</Blue>
</Inactive>
</Colors>
<HexSettings>
<MaximumBytesPerLine>16</MaximumBytesPerLine>
<ShowTextView>true</ShowTextView>
<BreaksAroundEcho>true</BreaksAroundEcho>
<AutoSend>true</AutoSend>
<SendAsHex>true</SendAsHex>
<TimeoutForAutoBreak>0</TimeoutForAutoBreak>
</HexSettings>
<LineEnding>LF</LineEnding>
<TreatLFAsCRLF>false</TreatLFAsCRLF>
<KeepOpenAfterExit>true</KeepOpenAfterExit>
<ShowAfterProgramming>true</ShowAfterProgramming>
</DeviceTerminalSettings>
<CustomShortcuts>
<Shortcuts />
<ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
</CustomShortcuts>
<UserDefinedVariables />
<ImportedPropertySheets />
<CodeSense>
<Enabled>Unknown</Enabled>
<ExtraSettings>
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
<SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis>
<CheckForClangFormatFiles>true</CheckForClangFormatFiles>
<FormattingEngine xsi:nil="true" />
</ExtraSettings>
<CodeAnalyzerSettings>
<Enabled>false</Enabled>
</CodeAnalyzerSettings>
</CodeSense>
<Configurations>
<VisualGDBConfiguration>
<PlatformName>Teensy_4 1</PlatformName>
<DebugSettingsOverride xsi:type="com.visualgdb.debug.embedded">
<AdditionalStartupCommands />
<AdditionalGDBSettings>
<Features>
<DisableAutoDetection>false</DisableAutoDetection>
<UseFrameParameter>false</UseFrameParameter>
<SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
<ListLocalsSupported>false</ListLocalsSupported>
<ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
<ThreadInfoSupported>false</ThreadInfoSupported>
<PendingBreakpointsSupported>false</PendingBreakpointsSupported>
<SupportTargetCommand>false</SupportTargetCommand>
<ReliableBreakpointNotifications>false</ReliableBreakpointNotifications>
</Features>
<EnableSmartStepping>false</EnableSmartStepping>
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
<ForceSingleThreadedMode>false</ForceSingleThreadedMode>
<UseAppleExtensions>false</UseAppleExtensions>
<CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
<MakeLogFile>false</MakeLogFile>
<IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
<UseRelativePathsOnly>false</UseRelativePathsOnly>
<ExitAction>None</ExitAction>
<DisableDisassembly>false</DisableDisassembly>
<ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
<StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
<ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
<DisableSignals>false</DisableSignals>
<EnableAsyncExecutionMode>false</EnableAsyncExecutionMode>
<AsyncModeSupportsBreakpoints>true</AsyncModeSupportsBreakpoints>
<TemporaryBreakConsolidationTimeout>0</TemporaryBreakConsolidationTimeout>
<EnableNonStopMode>false</EnableNonStopMode>
<MaxBreakpointLimit>0</MaxBreakpointLimit>
<EnableVerboseMode>true</EnableVerboseMode>
<EnablePrettyPrinters>false</EnablePrettyPrinters>
<EnableAbsolutePathReporting>true</EnableAbsolutePathReporting>
</AdditionalGDBSettings>
<DebugMethod>
<ID>com.sysprogs.arm.openocd</ID>
<Configuration xsi:type="com.visualgdb.edp.openocd.settings">
<CommandLine>-f interface/ftdi/tigard.cfg -f target/imxrt.cfg -c "adapter speed 3000"</CommandLine>
<ExtraParameters>
<Frequency xsi:nil="true" />
<BoostedFrequency xsi:nil="true" />
<ConnectUnderReset>false</ConnectUnderReset>
</ExtraParameters>
<LoadProgressGUIThreshold>131072</LoadProgressGUIThreshold>
<ProgramMode>Enabled</ProgramMode>
<StartupCommands>
<string>set remotetimeout 60</string>
<string>target extended-remote :$$SYS:GDB_PORT$$</string>
<string>load</string>
</StartupCommands>
<ProgramFLASHUsingExternalTool>false</ProgramFLASHUsingExternalTool>
<PreferredGDBPort>0</PreferredGDBPort>
<PreferredTelnetPort>0</PreferredTelnetPort>
<AlwaysPassSerialNumber>false</AlwaysPassSerialNumber>
<SelectedCoreIndex xsi:nil="true" />
<LiveMemoryTimeout>5000</LiveMemoryTimeout>
</Configuration>
</DebugMethod>
<AutoDetectRTOS>true</AutoDetectRTOS>
<SemihostingSupport>Auto</SemihostingSupport>
<SemihostingPollingDelay>0</SemihostingPollingDelay>
<StepIntoEntryPoint>false</StepIntoEntryPoint>
<ReloadFirmwareOnReset>false</ReloadFirmwareOnReset>
<ValidateEndOfStackAddress>true</ValidateEndOfStackAddress>
<StopAtEntryPoint>false</StopAtEntryPoint>
<EnableVirtualHalts>false</EnableVirtualHalts>
<DynamicAnalysisSettings />
<EndOfStackSymbol>_estack</EndOfStackSymbol>
<TimestampProviderTicksPerSecond>0</TimestampProviderTicksPerSecond>
<KeepConsoleAfterExit>false</KeepConsoleAfterExit>
<UnusedStackFillPattern xsi:nil="true" />
<SoftwareTracingSettings>
<TraceWhileDebugging>true</TraceWhileDebugging>
<AutoStart>false</AutoStart>
<DynamicProgramAreaSize>0</DynamicProgramAreaSize>
<SkipInitiallyDisabledTracepoints>false</SkipInitiallyDisabledTracepoints>
<TraceProgramOptimization>Size</TraceProgramOptimization>
<OutputMode>NonBlocking</OutputMode>
<AssumeFramePointerIsValid>true</AssumeFramePointerIsValid>
<InstrumentWithNoFeasibleTracepoints>false</InstrumentWithNoFeasibleTracepoints>
<MaximumStringLength>255</MaximumStringLength>
<DeferVectorTablePatching>true</DeferVectorTablePatching>
<ShowAdvancedConfiguration>false</ShowAdvancedConfiguration>
<WorkAreaSize>4096</WorkAreaSize>
<DisableLiveCodePatching>false</DisableLiveCodePatching>
</SoftwareTracingSettings>
<CheckInterfaceDrivers>true</CheckInterfaceDrivers>
</DebugSettingsOverride>
<BuildSettingsExtension xsi:type="com.visualgdb.build.external.arduino.extension">
<BoardID>teensy:avr:teensy41</BoardID>
<COMPort>COM102</COMPort>
<Properties>
<Entries>
<KeyValue>
<Key>usb</Key>
<Value>serial</Value>
</KeyValue>
<KeyValue>
<Key>speed</Key>
<Value>600</Value>
</KeyValue>
<KeyValue>
<Key>opt</Key>
<Value>o2std</Value>
</KeyValue>
<KeyValue>
<Key>keys</Key>
<Value>en-us</Value>
</KeyValue>
</Entries>
</Properties>
<DebugUnoptimizedComponentTypes>Sketch</DebugUnoptimizedComponentTypes>
</BuildSettingsExtension>
</VisualGDBConfiguration>
</Configurations>
<ProgramArgumentsSuggestions />
</VisualGDBProjectSettings2>
Loading

0 comments on commit 7fc7e57

Please sign in to comment.