@@ -15,127 +15,101 @@ Test harness for wolfSSL integration with ST STSAFE-A120 secure element on Raspb
1515- GCC compiler
1616- Linux I2C development headers (` libi2c-dev ` )
1717
18- ## Directory Structure
19-
20- ```
21- stsafe/
22- ├── Makefile # Build configuration
23- ├── README.md # This file
24- ├── user_settings.h # wolfSSL configuration
25- ├── stsafe_test.c # STSELib basic tests
26- ├── wolfssl_stsafe_test.c # wolfSSL crypto callback tests
27- ├── wolfssl_stsafe_full_test.c # Full integration tests with benchmarks
28- └── platform/
29- ├── stse_conf.h # STSELib configuration
30- ├── stse_platform_generic.h # Platform type definitions
31- ├── stse_platform_linux.c # Linux I2C platform implementation
32- └── stse_platform_crypto_wolfssl.c # wolfSSL crypto for STSELib
33- ```
34-
35- ## Configuration
36-
37- ### I2C Setup
18+ ## Quick Start
3819
39- 1 . Enable I2C on Raspberry Pi:
40- ``` bash
41- sudo raspi-config
42- # Navigate to: Interface Options -> I2C -> Enable
43- ```
20+ ### 1. Enable I2C on Raspberry Pi
4421
45- 2 . Verify I2C device:
46- ``` bash
47- sudo i2cdetect -y 1
48- # STSAFE should appear at address 0x20
49- ```
50-
51- 3 . Set I2C permissions (optional, for non-root access):
52- ``` bash
53- sudo usermod -a -G i2c $USER
54- # Logout and login again
55- ```
56-
57- ### Environment
58-
59- Set paths to dependencies:
6022``` bash
61- export WOLFSSL_DIR= $HOME /wolfssl
62- export STSELIB_DIR= $HOME /STSELib
23+ sudo raspi-config
24+ # Navigate to: Interface Options -> I2C -> Enable
6325```
6426
65- ## Building
27+ Reboot if prompted, then verify the STSAFE device is detected:
6628
67- ### Prerequisites
68-
69- 1 . Build wolfSSL with required features:
70- ``` bash
71- cd $WOLFSSL_DIR
72- ./configure --enable-cryptocb --enable-ecc --enable-cmac --enable-sha384 --enable-debug
73- make
74- ```
29+ ``` bash
30+ sudo i2cdetect -y 1
31+ # STSAFE should appear at address 0x20
32+ ```
7533
76- 2 . Clone STSELib:
77- ``` bash
78- git clone https://github.com/STMicroelectronics/STSELib.git $STSELIB_DIR
79- ```
34+ Optional: Allow non-root I2C access:
35+ ``` bash
36+ sudo usermod -a -G i2c $USER
37+ # Logout and login again
38+ ```
8039
81- ### Build Targets
40+ ### 2. Build wolfSSL
8241
8342``` bash
84- # Build basic STSELib tests (no wolfSSL crypto callbacks)
43+ cd ~ /wolfssl
44+ ./configure --enable-cryptocb --enable-ecc --enable-cmac --enable-sha384
8545make
46+ ```
8647
87- # Build wolfSSL crypto callback tests
88- make wolfssl
48+ ### 3. Clone STSELib
8949
90- # Build full integration tests with benchmarks
91- make wolfssl-full
50+ ``` bash
51+ git clone https://github.com/STMicroelectronics/STSELib.git ~ /STSELib
52+ ```
9253
93- # Build without wolfSSL (basic I2C tests only)
94- make basic
54+ ### 4. Build and Run Tests
55+
56+ ``` bash
57+ cd ~ /wolfssl-examples/stsafe
9558
96- # Clean build artifacts
97- make clean
59+ # Build all test executables
60+ make
9861
99- # Show configuration
100- make info
62+ # Run all tests
63+ make test-all
10164```
10265
103- ## Running Tests
66+ ## Test Suites
10467
105- ### Basic STSELib Tests
106- ``` bash
107- ./stsafe_test
108- ```
68+ ### Basic STSELib Tests (` stsafe_test ` )
10969
110- Tests:
70+ Tests core STSAFE-A120 functionality :
11171- Echo command (I2C communication)
11272- Random number generation
11373- ECC P-256 key generation
11474- ECDSA P-256 signing
11575- ECC P-384 key generation
11676
117- ### wolfSSL Crypto Callback Tests
11877``` bash
119- ./wolfssl_stsafe_test
78+ make && ./stsafe_test
12079```
12180
122- Tests:
81+ ### wolfSSL Crypto Callback Tests (` wolfssl_stsafe_test ` )
82+
83+ Tests wolfSSL crypto callbacks with STSAFE:
12384- RNG with STSAFE-A120
124- - ECC P-256 key generation via crypto callback
125- - ECC P-384 key generation via crypto callback
126- - ECDSA P-256 sign/verify
127- - ECDSA P-384 sign/verify
85+ - ECC P-256/P-384 key generation via crypto callback
86+ - ECDSA P-256/P-384 sign/verify
12887
129- ### Full Integration Tests
13088``` bash
131- ./wolfssl_stsafe_full_test
89+ make wolfssl && ./wolfssl_stsafe_test
13290```
13391
134- Tests:
92+ ### Full Integration Tests (` wolfssl_stsafe_full_test ` )
93+
94+ Comprehensive tests with benchmarks:
13595- RNG benchmark
13696- ECDSA P-256 benchmark (keygen, sign, verify timing)
13797- Multiple sequential operations
13898
99+ ``` bash
100+ make wolfssl-full && ./wolfssl_stsafe_full_test
101+ ```
102+
103+ ## Build Targets
104+
105+ | Target | Description |
106+ | --------| -------------|
107+ | ` make ` | Build all test executables |
108+ | ` make test-all ` | Build and run all tests |
109+ | ` make basic ` | Build without wolfSSL (basic I2C tests only) |
110+ | ` make clean ` | Clean build artifacts |
111+ | ` make info ` | Show configuration |
112+
139113## Expected Output
140114
141115```
@@ -175,9 +149,51 @@ Test Summary: 5 passed, 0 failed
175149| ECDSA P-256 Sign | ~ 51 ms | 19.5 ops/sec |
176150| ECDSA P-256 Verify | ~ 79 ms | 12.7 ops/sec |
177151
152+ ## Directory Structure
153+
154+ ```
155+ stsafe/
156+ ├── Makefile # Build configuration
157+ ├── README.md # This file
158+ ├── user_settings.h # wolfSSL configuration
159+ ├── stsafe_test.c # STSELib basic tests
160+ ├── wolfssl_stsafe_test.c # wolfSSL crypto callback tests
161+ ├── wolfssl_stsafe_full_test.c # Full integration tests with benchmarks
162+ └── platform/
163+ ├── stse_conf.h # STSELib configuration
164+ ├── stse_platform_generic.h # Platform type definitions
165+ ├── stse_platform_linux.c # Linux I2C platform implementation
166+ └── stse_platform_crypto_wolfssl.c # wolfSSL crypto for STSELib
167+ ```
168+
169+ ## Environment Variables
170+
171+ Default paths assume ` ~/wolfssl ` and ` ~/STSELib ` . Override if needed:
172+
173+ ``` bash
174+ export WOLFSSL_DIR=/path/to/wolfssl
175+ export STSELIB_DIR=/path/to/STSELib
176+ ```
177+
178+ ## Troubleshooting
179+
180+ ### Error 0x0104 (STSE_PLATFORM_BUS_ERR)
181+
182+ I2C communication error. Check:
183+ 1 . I2C is enabled: ` ls /dev/i2c* `
184+ 2 . Device detected: ` sudo i2cdetect -y 1 ` (should show ` 20 ` )
185+ 3 . Wiring connections are secure
186+
187+ ### Build errors
188+
189+ Ensure wolfSSL is built with required features:
190+ ``` bash
191+ ./configure --enable-cryptocb --enable-ecc --enable-cmac --enable-sha384
192+ ```
193+
178194## References
179195
180196- [ wolfSSL Documentation] ( https://www.wolfssl.com/docs/ )
181197- [ STSELib GitHub] ( https://github.com/STMicroelectronics/STSELib )
182198- [ STSAFE-A120 Datasheet] ( https://www.st.com/en/secure-mcus/stsafe-a120.html )
183- - [ Raspberry Pi I2C Documentation] ( https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-and-the-40-pin-header )
199+ - [ Raspberry Pi I2C Documentation] ( https://www.raspberrypi.com/documentation/computers/raspberry-pi.html )
0 commit comments