Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 1c31a1b

Browse files
committed
Initial version
1 parent 9ca4836 commit 1c31a1b

File tree

93 files changed

+54164
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+54164
-0
lines changed

CONTRIBUTING.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, useful file locations and parameters.
14+
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
15+
do not have permission to do that, you may request the second reviewer to merge it for you.
16+
17+
## Code of Conduct
18+
19+
### Our Pledge
20+
21+
In the interest of fostering an open and welcoming environment, we as
22+
contributors and maintainers pledge to making participation in our project and
23+
our community a harassment-free experience for everyone, regardless of age, body
24+
size, disability, ethnicity, gender identity and expression, level of experience,
25+
nationality, personal appearance, race, religion, or sexual identity and
26+
orientation.
27+
28+
### Our Standards
29+
30+
Examples of behavior that contributes to creating a positive environment
31+
include:
32+
33+
* Using welcoming and inclusive language
34+
* Being respectful of differing viewpoints and experiences
35+
* Gracefully accepting constructive criticism
36+
* Focusing on what is best for the community
37+
* Showing empathy towards other community members
38+
39+
Examples of unacceptable behavior by participants include:
40+
41+
* The use of sexualized language or imagery and unwelcome sexual attention or
42+
advances
43+
* Trolling, insulting/derogatory comments, and personal or political attacks
44+
* Public or private harassment
45+
* Publishing others' private information, such as a physical or electronic
46+
address, without explicit permission
47+
* Other conduct which could reasonably be considered inappropriate in a
48+
professional setting
49+
50+
### Our Responsibilities
51+
52+
Project maintainers are responsible for clarifying the standards of acceptable
53+
behavior and are expected to take appropriate and fair corrective action in
54+
response to any instances of unacceptable behavior.
55+
56+
Project maintainers have the right and responsibility to remove, edit, or
57+
reject comments, commits, code, wiki edits, issues, and other contributions
58+
that are not aligned to this Code of Conduct, or to ban temporarily or
59+
permanently any contributor for other behaviors that they deem inappropriate,
60+
threatening, offensive, or harmful.
61+
62+
### Scope
63+
64+
This Code of Conduct applies both within project spaces and in public spaces
65+
when an individual is representing the project or its community. Examples of
66+
representing a project or community include using an official project e-mail
67+
address, posting via an official social media account, or acting as an appointed
68+
representative at an online or offline event. Representation of a project may be
69+
further defined and clarified by project maintainers.
70+
71+
### Enforcement
72+
73+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
74+
reported by contacting the project team.
75+
All complaints will be reviewed and investigated and will result in a response that
76+
is deemed necessary and appropriate to the circumstances. The project team is
77+
obligated to maintain confidentiality with regard to the reporter of an incident.
78+
Further details of specific enforcement policies may be posted separately.
79+
80+
Project maintainers who do not follow or enforce the Code of Conduct in good
81+
faith may face temporary or permanent repercussions as determined by other
82+
members of the project's leadership.
83+
84+
### Attribution
85+
86+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87+
available at [http://contributor-covenant.org/version/1/4][version]
88+
89+
[homepage]: http://contributor-covenant.org
90+
[version]: http://contributor-covenant.org/version/1/4/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2018 Infineon Technologies AG
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# OPTIGA™ Trust X
2+
![TrustXPackage](https://github.com/Infineon/Assets/raw/master/Pictures/OPTIGA-Trust-X.png)
3+
4+
Infineon's [OPTIGA™ Trust X](https://www.infineon.com/cms/en/product/security-smart-card-solutions/optiga-embedded-security-solutions/optiga-trust/optiga-trust-x-sls-32aia/) security solution library for Arduino
5+
6+
## Summary
7+
[OPTIGA™ Trust X](https://www.infineon.com/dgdl/Infineon-OPTIGA%20TRUST%20X%20SLS%2032AIA-DS-v02_18-EN.pdf) is a security solution based on a secure micrcontroller.
8+
Each device is shipped with a unique elliptic-curve keypair and a corresponding X.509 certificate. OPTIGA™ Trust X enables easy integration into existing PKI infrastructure.
9+
10+
11+
## Key Features and Benefits
12+
* High-end security controller
13+
* Turnkey solution
14+
* One-way authentication using ECDSA
15+
* Mutual authentication using DTLS client (IETF standard RFC 6347)
16+
* Secure communication using DTLS
17+
* Compliant with the USB Type-C™ Authentication standard
18+
* I2C interface
19+
* Up to 10 KB user memory
20+
* Cryptographic support: ECC256, AES128, SHA-256, TRNG, DRNG
21+
* PG-USON-10-2 package (3 x 3 mm)
22+
* Standard & extended temperature ranges
23+
* Full system integration support
24+
* Common Criteria Certified EAL6+ (high) hardware
25+
* Cryptographic Tool Box based on ECC NIST P256, P384 and SHA256 (sign, verify, key generation, ECDH, session key derivation)
26+
27+
## Hardware
28+
The wiring to your arduino board depends on the [evaluation board](https://www.infineon.com/cms/en/product/evaluation-boards/optiga-trust-x-eval-kit/) or the
29+
Shield2GO (link pending) you are using.
30+
31+
## Installation
32+
33+
### Integration of Library
34+
Please download this repository from GitHub either from the latest [release](https://github.com/Infineon/OPTIGA-Trust-X-Security-Controller/releases) of directly [here](https://github.com/Infineon/OPTIGA-Trust-X-Security-Controller/archive/V1.0.0.zip):
35+
![Download Library](https://raw.githubusercontent.com/Infineon/assets/master/Pictures/DL_OPTIGA_Trust_X.jpg)
36+
37+
38+
To install the OPTIGA™ Trust X library in the Arduino IDE, please go to **Sketch** > **Include Library** > **Add .ZIP Library...** in the Arduino IDE and navigate to the downloaded .ZIP file of this repository. The library will be installed in your Arduino sketch folder in libraries and you can select as well as include this one to your project under **Sketch** > **Include Library** > **OPTIGATrustX**.
39+
40+
![Install Library](https://raw.githubusercontent.com/infineon/assets/master/Pictures/Library_Install_ZIP.png)
41+
42+
## Supported Devices
43+
In general, the library should be compatible with any Arduino board, however it has been tested for the following platforms:
44+
* Sparkfun ESP32 Thing (Espressif Systems, ESP32, Xtensa)
45+
* Adafruit Feather M0 (Atmel, SAMD21, Cortex M0)
46+
* STM32 Nucleo (ST Microelectronics, STM32F0, Cortex M0)
47+
* XMC1100 2Go (Infineon Technologies, XMC1100, Cortex M0)
48+
* XMC4700 Relax Kit (Infineon Technologies, XMC4700, Cortex M4)
49+
* WEMOS D1 mini (Espressif Systems, ESP8266, Xtensa)
50+
51+
## Usage
52+
The library is equiped with eight groups of examples which can be found on the following path: File->Examples>OPTIGATrustX
53+
The following sections describe all the examples in more detail.
54+
55+
### selfTest
56+
selfTest example demonstrates a trustX.checkChip() method usage, which authenticates the OPTIGA™ Trust X on the host MCU.
57+
This method implements a simple challenge-response authentication scheme, in which the host side authenticates the OPTIGA™ Trust X security chip.
58+
59+
### calculateHash
60+
calculateHash demonstrates example usage of the SHA256 hash, as well as a simple benchamarking for your microcontroller.
61+
The performance of this benchmark test greatly depends on I2C bus frame size (it affects mainly big blocks of data transmitted to the OPTIGA™ Trust X chip for hashing),
62+
which was limited by default down to 32 bytes (in case of 32 bytes the library will perfrom fragmentation).
63+
64+
Please check settings for your specific platform, if you want to improve the performance of the hashing function.
65+
66+
### calculateSignVerifySign
67+
calculateSignVerifySign demonstrates signature generation and signature verification methods of the library.
68+
This example shows two modes of operation:
69+
1) Calculate a signature using manufacturer private key, the result value is then verified against the public key
70+
2) Generate a public-private keypair and store the latter inside one of Object IDs of the OPTIGA™ Trust X,
71+
then sign the digest giving only the latter Object ID, the result value is then verified against the public key.
72+
73+
For the verification three methods are available:
74+
1) with a given raw public key
75+
2) with Object ID pointing to the memory slot where the public key is located,
76+
3) if neither Object ID nor raw public key were specified, the function will use a default Object ID with manufacturer public key certificate.
77+
78+
### generateKeypair
79+
calculateSignVerifySign demonstrates methods for keypair generation, either with a private key export, or without.
80+
In the latter case the developer should specify the Object ID of the private key.
81+
82+
### getCertificate, getUniqueID
83+
getCertificate and getUniqueID demonstrate examples of retrievieng various properties of the OPTIGA™ Trust X Chip.
84+
As well as these examples the developer can also call getCurrentLimit/setCurrentLimit in order to get or modify the
85+
current limitation of the chip (varies from 5mA by default to maximum 15mA)
86+
87+
### getRandom
88+
getRandom demonstrates random number generator capabilities. This example outputs random numbers of various sizes (16, 32, 64, 128, 256)
89+
90+
### testFullAPI
91+
testFullAPI is used to briefly test major API calls to the library. The expected output of this function can be found in Figure below.
92+
*Certificate output might be different
93+
94+
![testFullAPI expected result](https://github.com/Infineon/Assets/raw/master/Pictures/OPTIGA%20Trust%20X%20testFullAPI.png)
95+
96+
## Available functions
97+
Available API is discribed in Wiki of the repository
98+
99+
## Contributing
100+
101+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process of submitting pull requests to us.
102+
103+
## License
104+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

doc/OPTIGA_Trust_X_Datasheet_v2.5.pdf

1.09 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (c) 2018 Infineon Technologies AG
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE
23+
*
24+
* Demonstrates use of the
25+
* Infineon Technologies AG OPTIGA™ Trust X Arduino library
26+
*/
27+
28+
#include "OPTIGATrustX.h"
29+
30+
#define DATA_LENGTH 20
31+
#define BIGDATA_LENGTH 1024
32+
#define HASH_LENGTH 32
33+
34+
#define SUPPRESSCOLLORS
35+
#include "fprint.h"
36+
37+
/* Arrays to store results of operations */
38+
uint8_t data[DATA_LENGTH];
39+
uint8_t bigdata[BIGDATA_LENGTH];
40+
uint8_t hash[HASH_LENGTH];
41+
42+
void setup()
43+
{
44+
uint32_t ret = 0;
45+
46+
/*
47+
* Initialise a serial port for debug output
48+
*/
49+
Serial.begin(38400);
50+
Serial.println("Initializing ... ");
51+
52+
/*
53+
* Initialise an OPTIGA™ Trust X Board
54+
*/
55+
printGreen("Begin to trust ... ");
56+
ret = trustX.begin();
57+
if (ret) {
58+
printlnRed("Failed");
59+
while (true);
60+
}
61+
printlnGreen("OK");
62+
63+
/*
64+
* Speedup the board (from 6 mA to 15 mA)
65+
*/
66+
ret = trustX.setCurrentLimit(15);
67+
if (ret) {
68+
printlnRed("Failed");
69+
while (true);
70+
}
71+
printlnGreen("OK");
72+
73+
}
74+
75+
static void output_result(char* tag, uint32_t tstamp, uint8_t* in, uint16_t in_len)
76+
{
77+
printGreen("[OK] | Command executed in ");
78+
Serial.print(tstamp);
79+
Serial.println(" ms");
80+
printMagenta(tag);
81+
printMagenta(" Length: ");
82+
Serial.println(in_len);
83+
printMagenta(tag);
84+
printlnMagenta(":");
85+
HEXDUMP(in, in_len);
86+
}
87+
88+
void loop()
89+
{
90+
uint32_t ret = 0;
91+
uint8_t cntr = 10;
92+
// Timestamp is used to measure the execution time of a command
93+
uint32_t ts = 0;
94+
95+
/*
96+
* Calculate a hash of the given data
97+
*/
98+
printGreen("\r\nCalculate One-Time Hash for ");
99+
printlnGreen((char *)data);
100+
ts = millis();
101+
ret = trustX.sha256(data, DATA_LENGTH, hash);
102+
ts = millis() - ts;
103+
if (ret) {
104+
printlnRed("Failed");
105+
while (true);
106+
}
107+
output_result("Hash", ts, hash, HASH_LENGTH);
108+
109+
/*
110+
* Calculate a hash of the given data (big input)
111+
*/
112+
printlnGreen("\r\nCalculate One-Time Hash for 1024 bytes... ");
113+
ts = millis();
114+
ret = trustX.sha256(bigdata, BIGDATA_LENGTH, hash);
115+
ts = millis() - ts;
116+
if (ret) {
117+
printlnRed("Failed");
118+
while (true);
119+
}
120+
121+
output_result("Hash", ts, hash, HASH_LENGTH);
122+
printGreen("Hashrate is ");
123+
Serial.print(1024/ts);
124+
Serial.println(" kB/sec");
125+
126+
/*
127+
* Benchmarking hash for the current microcontroller
128+
*/
129+
printlnGreen("\r\nBenchmarking SHA256 100 times for 20 bytes data ... ");
130+
ts = millis();
131+
for (int i = 0; i < 100; i++) {
132+
trustX.sha256(data, DATA_LENGTH, hash);
133+
}
134+
ts = millis() - ts;
135+
if (ret) {
136+
printlnRed("Failed");
137+
while (true);
138+
}
139+
140+
printGreen("Becnhmark executed in ");
141+
Serial.print(ts);
142+
Serial.println(" ms");
143+
printGreen("Hashrate is ");
144+
Serial.print((1000 * 100)/ts);
145+
Serial.println(" H/sec");
146+
147+
/*
148+
* Count down 10 seconds and restart the application
149+
*/
150+
while(cntr) {
151+
Serial.print(cntr);
152+
Serial.println(" seconds untill restart.");
153+
delay(1000);
154+
cntr--;
155+
}
156+
}

0 commit comments

Comments
 (0)