Initial
This commit is contained in:
commit
6c71b13126
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
.pio
|
||||
.pioenvs
|
||||
.piolibdeps
|
||||
.vscode
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
27
Ideas
Normal file
27
Ideas
Normal file
@ -0,0 +1,27 @@
|
||||
Ideas:
|
||||
|
||||
Use it on raspberrypi with the cli
|
||||
|
||||
Build a tool to quickly provision chips...
|
||||
|
||||
run the toolkit on the nanopi neo
|
||||
|
||||
push a button to trigger a banner on a nodejs server thingy
|
||||
|
||||
Change chip to proove that the certificate is the LBS Ca one and not the Infineon CA one =D
|
||||
|
||||
|
||||
Steps:
|
||||
|
||||
script that provisions chips with certs
|
||||
-> Provision 2 chips with different certificates! (Maybe get another one tomorrow? or make this a live demo of the personalisation!)
|
||||
|
||||
NodeMCU uses chip cert to make json object with data and signature to send its status
|
||||
|
||||
Nodejs server that verifies messages and signature with openssl via tcp
|
||||
-> Shows Cert Authority and state with a corner icon of eiter Yes or No
|
||||
|
||||
|
||||
|
||||
|
||||
|
BIN
asnfinal.bin
Normal file
BIN
asnfinal.bin
Normal file
Binary file not shown.
127
convertCert.js
Normal file
127
convertCert.js
Normal file
@ -0,0 +1,127 @@
|
||||
var fs = require('fs');
|
||||
//0x30,0x82,0x01,0xbc,0x30,0x82,0x01,0x62,0xa0,
|
||||
// MyChip
|
||||
let certdata = [
|
||||
0x30,0x82,0x01,0xbc,0x30,0x82,0x01,0x62,0xa0,0x03,0x02,0x01,0x02,0x02,0x04,0x47,
|
||||
0x33,0xda,0x95,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x30,
|
||||
0x72,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x21,
|
||||
0x30,0x1f,0x06,0x03,0x55,0x04,0x0a,0x0c,0x18,0x49,0x6e,0x66,0x69,0x6e,0x65,0x6f,
|
||||
0x6e,0x20,0x54,0x65,0x63,0x68,0x6e,0x6f,0x6c,0x6f,0x67,0x69,0x65,0x73,0x20,0x41,
|
||||
0x47,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0b,0x0c,0x0a,0x4f,0x50,0x54,0x49,
|
||||
0x47,0x41,0x28,0x54,0x4d,0x29,0x31,0x2b,0x30,0x29,0x06,0x03,0x55,0x04,0x03,0x0c,
|
||||
0x22,0x49,0x6e,0x66,0x69,0x6e,0x65,0x6f,0x6e,0x20,0x4f,0x50,0x54,0x49,0x47,0x41,
|
||||
0x28,0x54,0x4d,0x29,0x20,0x54,0x72,0x75,0x73,0x74,0x20,0x58,0x20,0x43,0x41,0x20,
|
||||
0x31,0x30,0x31,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x38,0x33,0x31,0x31,0x32,0x30,
|
||||
0x39,0x33,0x31,0x5a,0x17,0x0d,0x33,0x37,0x30,0x38,0x33,0x31,0x31,0x32,0x30,0x39,
|
||||
0x33,0x31,0x5a,0x30,0x00,0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,
|
||||
0x02,0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,
|
||||
0x07,0x02,0x94,0xd7,0xd6,0xd9,0xec,0xb2,0xff,0x68,0x53,0xe8,0xc4,0xdd,0xfd,0x96,
|
||||
0x53,0x20,0x93,0x8f,0x73,0x33,0xdd,0xac,0x8c,0x2e,0x0e,0x4d,0x79,0x5c,0xa4,0x03,
|
||||
0x4b,0x9b,0x24,0xf6,0xec,0x63,0xcd,0x2a,0xe7,0xa0,0x14,0xd3,0x4b,0xbc,0x32,0x22,
|
||||
0x05,0xb9,0x4e,0x90,0x9f,0x8a,0x21,0x62,0xf2,0xce,0x15,0xcf,0xdf,0xa1,0x20,0x12,
|
||||
0xa3,0x58,0x30,0x56,0x30,0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01,0x01,0xff,0x04,0x04,
|
||||
0x03,0x02,0x00,0x80,0x30,0x0c,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,
|
||||
0x30,0x00,0x30,0x15,0x06,0x03,0x55,0x1d,0x20,0x04,0x0e,0x30,0x0c,0x30,0x0a,0x06,
|
||||
0x08,0x2a,0x82,0x14,0x00,0x44,0x01,0x14,0x01,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,
|
||||
0x04,0x18,0x30,0x16,0x80,0x14,0xca,0x05,0x33,0xd7,0x4f,0xc4,0x7f,0x09,0x49,0xfb,
|
||||
0xdb,0x12,0x25,0xdf,0xd7,0x97,0x9d,0x41,0x1e,0x15,0x30,0x0a,0x06,0x08,0x2a,0x86,
|
||||
0x48,0xce,0x3d,0x04,0x03,0x02,0x03,0x48,0x00,0x30,0x45,0x02,0x20,0x27,0xd0,0xf5,
|
||||
0x36,0xa3,0xc2,0xc9,0xc5,0xb7,0x48,0xa7,0x4f,0x3c,0x23,0x7b,0x9d,0xad,0x1d,0x9e,
|
||||
0xc7,0x7f,0xe0,0xbb,0xe3,0x43,0x03,0x1a,0x3f,0x33,0x6d,0x73,0xa7,0x02,0x21,0x00,
|
||||
0x92,0x86,0x58,0x10,0x18,0xe1,0xdb,0x8c,0xb6,0x52,0xf4,0xc7,0xca,0x82,0xce,0xa5,
|
||||
0x0e,0x28,0xb5,0x71,0x9d,0x71,0x15,0x85,0xdd,0x56,0x85,0x00,0xd4,0xc1,0xda,0xd9];
|
||||
|
||||
// Rezas chip
|
||||
|
||||
certdata = [0x30,0x82,0x01,0xbc,0x30,0x82,0x01,0x62,0xa0,0x03,0x02,0x01,0x02,0x02,0x04,0x3b,
|
||||
0x71,0xec,0xb2,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02,0x30,
|
||||
0x72,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x21,
|
||||
0x30,0x1f,0x06,0x03,0x55,0x04,0x0a,0x0c,0x18,0x49,0x6e,0x66,0x69,0x6e,0x65,0x6f,
|
||||
0x6e,0x20,0x54,0x65,0x63,0x68,0x6e,0x6f,0x6c,0x6f,0x67,0x69,0x65,0x73,0x20,0x41,
|
||||
0x47,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0b,0x0c,0x0a,0x4f,0x50,0x54,0x49,
|
||||
0x47,0x41,0x28,0x54,0x4d,0x29,0x31,0x2b,0x30,0x29,0x06,0x03,0x55,0x04,0x03,0x0c,
|
||||
0x22,0x49,0x6e,0x66,0x69,0x6e,0x65,0x6f,0x6e,0x20,0x4f,0x50,0x54,0x49,0x47,0x41,
|
||||
0x28,0x54,0x4d,0x29,0x20,0x54,0x72,0x75,0x73,0x74,0x20,0x58,0x20,0x43,0x41,0x20,
|
||||
0x31,0x30,0x31,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x38,0x33,0x31,0x31,0x32,0x30,
|
||||
0x39,0x33,0x31,0x5a,0x17,0x0d,0x33,0x37,0x30,0x38,0x33,0x31,0x31,0x32,0x30,0x39,
|
||||
0x33,0x31,0x5a,0x30,0x00,0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,
|
||||
0x02,0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,
|
||||
0xd5,0xf9,0x1c,0xd4,0x2b,0x20,0x10,0x9c,0x05,0x65,0x8b,0xb0,0x29,0xe7,0xfb,0x16,
|
||||
0x62,0xe7,0x00,0xd0,0x6e,0xb1,0x37,0xfa,0x23,0x29,0x2d,0x46,0xb7,0x0e,0xf4,0x1f,
|
||||
0x3d,0xb5,0x37,0x04,0x63,0xa9,0x64,0xd4,0xe5,0x9f,0x8c,0x1d,0x91,0x8d,0x14,0x6a,
|
||||
0xa6,0x42,0xe8,0xc9,0x15,0x90,0x41,0xff,0x04,0xb9,0x47,0x6a,0x36,0x65,0xf6,0x89,
|
||||
0xa3,0x58,0x30,0x56,0x30,0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01,0x01,0xff,0x04,0x04,
|
||||
0x03,0x02,0x00,0x80,0x30,0x0c,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,
|
||||
0x30,0x00,0x30,0x15,0x06,0x03,0x55,0x1d,0x20,0x04,0x0e,0x30,0x0c,0x30,0x0a,0x06,
|
||||
0x08,0x2a,0x82,0x14,0x00,0x44,0x01,0x14,0x01,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,
|
||||
0x04,0x18,0x30,0x16,0x80,0x14,0xca,0x05,0x33,0xd7,0x4f,0xc4,0x7f,0x09,0x49,0xfb,
|
||||
0xdb,0x12,0x25,0xdf,0xd7,0x97,0x9d,0x41,0x1e,0x15,0x30,0x0a,0x06,0x08,0x2a,0x86,
|
||||
0x48,0xce,0x3d,0x04,0x03,0x02,0x03,0x48,0x00,0x30,0x45,0x02,0x21,0x00,0xc3,0xbb,
|
||||
0x21,0xa6,0x07,0xbc,0xb0,0x8a,0x75,0xf4,0x15,0x9d,0x76,0xd1,0xfd,0x72,0x3a,0xef,
|
||||
0xca,0x5a,0x88,0x2a,0xe8,0x03,0xa8,0x01,0xc0,0x02,0xd4,0x56,0x63,0x85,0x02,0x20,
|
||||
0x22,0x64,0x7e,0x20,0x4c,0x33,0x63,0xa1,0x98,0x3e,0xdf,0xc8,0x65,0x74,0x97,0xcc,
|
||||
0x19,0xa2,0xf6,0x49,0xae,0x8b,0x2c,0xe4,0x52,0x97,0xf3,0x34,0xda,0x9c,0x53,0x34 ];
|
||||
// 452
|
||||
/*
|
||||
let sigdata = [
|
||||
0x02,0x20,0x62,0x3a,0xd5,0xe2,0x22,0xe5,0x99,0x3f,0x0f,0xc7,0x22,0x28,0x00,0x51,
|
||||
0x29,0xc0,0xac,0x6a,0xcb,0xa4,0xec,0x63,0x60,0x30,0x09,0xb1,0xb8,0x61,0x65,0x00,
|
||||
0xca,0xae,0x02,0x21,0x00,0xf6,0xab,0xd8,0x35,0x2a,0x75,0xc2,0x51,0xd3,0x79,0xc1,
|
||||
0xf0,0x2f,0x3a,0x1d,0x5d,0xe9,0xff,0xce,0xcc,0x8f,0x9c,0xdd,0x79,0xc0,0x24,0x19,
|
||||
0x8b,0x2e,0x5a,0x76,0x54
|
||||
];
|
||||
|
||||
let sigdata = [0x30,0x45,0x02,0x20,0x02,0x20,0x6b,0x32,0x55,0x46,0x4a,0xe3,0xed,0x50,0x67,0x04,
|
||||
0x29,0x4c,0x49,0xe5,0xc4,0x4d,0xfc,0x36,0x5d,0x3b,0x90,0xb1,0x74,0xf6,0xc2,0xb5,
|
||||
0x83,0x9d,0xf2,0x4c,0x02,0x21,0x00,0x4e,0x35,0x02,0x21,0x00,0xc0,0xdc,0x7f,0xd1,
|
||||
0x89,0xaa,0x4f,0x7e,0xe2,0xdd,0xad,0x0b,0x82,0xde,0x59,0x1d,0x98,0xba,0xd2,0xe3,
|
||||
0xab,0xf6,0xd2,0x4e,0x41,0x49,0x25];
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Signature:
|
||||
0x02,0x20,0x6e,0x4d,0x4c,0x82,0xa7,0xdd,0xb5,0x9c,0x19,0x6b,0x84,0xf5,0xc3,0x69,
|
||||
0x14,0xc9,0x7e,0xd6,0x20,0xb7,0xed,0xc1,0xee,0x94,0x3f,0x92,0xc7,0x71,0xd8,0x23,
|
||||
0x6b,0xe4,0x02,0x20,0x7e,0x35,0x9e,0xa4,0xca,0xfb,0x29,0xe5,0x1f,0x5a,0xec,0x57,
|
||||
0x41,0x73,0xf4,0xc7,0x9e,0x9a,0x30,0x39,0x37,0xab,0x41,0xb3,0xab,0x16,0xd6,0xb4,
|
||||
0x95,0x71,0x73,0x14];
|
||||
Format Signature ... OK
|
||||
Signature Formated Length: 71
|
||||
Signature Formated:
|
||||
let sigdata = [
|
||||
0x30,0x45,0x02,0x20,0x02,0x20,0x6e,0x4d,0x4c,0x82,0xa7,0xdd,0xb5,0x9c,0x19,0x6b,
|
||||
0x84,0xf5,0xc3,0x69,0x14,0xc9,0x7e,0xd6,0x20,0xb7,0xed,0xc1,0xee,0x94,0x3f,0x92,
|
||||
0xc7,0x71,0xd8,0x23,0x02,0x21,0x00,0x6b,0xe4,0x02,0x20,0x7e,0x35,0x9e,0xa4,0xca,
|
||||
0xfb,0x29,0xe5,0x1f,0x5a,0xec,0x57,0x41,0x73,0xf4,0xc7,0x9e,0x9a,0x30,0x39,0x37,
|
||||
0xab,0x41,0xb3,0xab,0x16,0xd6,0xb4];
|
||||
Verify Signature ... OK
|
||||
|
||||
// Press sig no end
|
||||
let sigdata = [
|
||||
0x30,0x44,0x02,0x20,0x02,0x21,0x00,0xd4,0x4c,0x73,0x6e,0x85,0x71,0x17,0xc9,0x02,
|
||||
0xe3,0x11,0xca,0x24,0x72,0xfd,0xbf,0xe1,0x81,0xc2,0x4d,0x3d,0xde,0xca,0x46,0xcd,
|
||||
0x42,0xd3,0x82,0xa3,0x02,0x20,0x37,0x4e,0x09,0x02,0x20,0x07,0x92,0x75,0xa4,0xd1,
|
||||
0x76,0x2d,0xc9,0x5f,0x4b,0x00,0x7a,0xd7,0x7d,0xe6,0x41,0x92,0x4d,0xaa,0x25,0x4f,
|
||||
0x1e,0x65,0x94,0xc5,0x48,0x29
|
||||
];
|
||||
*/
|
||||
|
||||
let sigdata = [
|
||||
0x02,0x20,0x03,0xff,0xc2,0x29,0x7c,0x2e,0xb7,0xad,0xf3,0x2f,0x88,0x42,0x59,0x09,
|
||||
0x70,0xe2,0x62,0x4e,0x5c,0xa2,0x67,0x2c,0x0d,0xe9,0xa8,0x7b,0xaf,0xe1,0xd7,0xed,
|
||||
0xcb,0x37,0x02,0x20,0x76,0x00,0xcd,0x77,0x24,0x2f,0xa4,0xd6,0x5b,0x44,0x47,0xc6,
|
||||
0x08,0x14,0x08,0xaa,0x31,0xf4,0x1b,0x0f,0x02,0x30,0xe4,0x16,0x20,0x7d,0xfb,0x67
|
||||
];
|
||||
|
||||
//let sigdata = [ 5,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
var b = new Buffer.from(certdata);
|
||||
console.log(certdata.length);
|
||||
|
||||
fs.writeFile("pubreza.bin", b, "binary",function(err) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log("The file was saved!");
|
||||
}
|
||||
});
|
39
include/README
Normal file
39
include/README
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
3
key64.pem
Normal file
3
key64.pem
Normal file
@ -0,0 +1,3 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
BAcClNfW2eyy/2hT6MTd/ZZTIJOPczPdrIwuDk15XKQDS5sk9uxjzSrnoBTTS7wyIgW5TpCfiiFi8s4Vz9+hIBI=
|
||||
-----END PUBLIC KEY-----
|
46
lib/README
Normal file
46
lib/README
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
32
localtry/LBs Sign Key.crt
Normal file
32
localtry/LBs Sign Key.crt
Normal file
@ -0,0 +1,32 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFdjCCA14CCQCH0F2k0CH8dTANBgkqhkiG9w0BAQsFADB9MQswCQYDVQQGEwJO
|
||||
TDEVMBMGA1UECAwMWnVpZCBIb2xsYW5kMRIwEAYDVQQHDAlSb3R0ZXJkYW0xGjAY
|
||||
BgNVBAoMEVNwYXJrbGluZyBOZX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t+nj1ww/+3YaBIafRbmOyvXaaCAgKoA/aKb/a
|
||||
4QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQBzCjsc7Nf5obQmg5snmhsL9nrjAcRV
|
||||
L6xYF5AJ+8P+kmOiXwhvm0wZ0jqYhDcuWN7/oZt3i39f7Ei84cYSFAQlMu/FMhZg
|
||||
hzoERnIOMu9sMlKBzgcmKUHuNhFoiZTyhFD+smCrcoEj+1bi4qz4t7GIAPM6Rzm0
|
||||
IJeJb8hL1I2tpuHC6bVjaCwYwS/6VtgoU1xcqvb8B5YRMpvDUCjgM6WN1cGdySTJ
|
||||
byA0u9MqEHQAsb7imW7D2X06Xi8yxH9+jh+BppSvn6EmAAywBwy32B7y7tLMnqZy
|
||||
HY2rks89aHM0fFF07P6pa81RDe+NO6ncNLG09R/1PaCVBVuVCvR0OwUf3jKxYVVM
|
||||
lp9/BlkU+duoRRRhaN4qo30HpEeXDpywETf0zJDstUp6ofDq1FTa6zpuPu0jcDHm
|
||||
a+szEVNRd00LdCsELVeUoVQSqwq1y2oqrpQCCkL5RQ5XfoIzOOXehk/NgDcOlYvr
|
||||
9vB2RQCvsG6c6ur+taNWC6OBBSKLGjAS9oST+Xm1zcu8U4zREBBB5Drxus5DW9Zo
|
||||
xlfL0aNWdV1lkRr6o2vvwA3018hIpsji1kkZd8ZOorBHkXrjVRDqpjey+XpCXJ2k
|
||||
cfugwb18jJ7HuGjeydm1BvnksfuXYYbsoSOoe2A/lGTmL6yf0YUAgUV/yBFLoh2j
|
||||
YsXtCUTRC2HVvg==
|
||||
-----END CERTIFICATE-----
|
52
localtry/LBs Sign Key.key
Normal file
52
localtry/LBs Sign Key.key
Normal file
@ -0,0 +1,52 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDpUHMM+5VAkYHQ
|
||||
/fuQ6+j9sbB1B9gJ3r6FBzz/0E7eKgKU967fa8NHUy14PE7t0E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
|
||||
5sV4KavVjz6wciQK1zujvdUoZ7TF7dNnR8/9yV35dRcvGRJW7PUwv9qYVWN459EV
|
||||
SykFgO0hP10e9Mw7Duf1u0UWfC0unA==
|
||||
-----END PRIVATE KEY-----
|
1
localtry/sign.txt
Normal file
1
localtry/sign.txt
Normal file
@ -0,0 +1 @@
|
||||
Hello, World
|
BIN
localtry/sign.txt.sha256
Normal file
BIN
localtry/sign.txt.sha256
Normal file
Binary file not shown.
1
message.txt
Normal file
1
message.txt
Normal file
@ -0,0 +1 @@
|
||||
press
|
4
osslkey.pem
Normal file
4
osslkey.pem
Normal file
@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBwKU19bZ7LL/aFPoxN39llMgk49z
|
||||
M92sjC4OTXlcpANLmyT27GPNKuegFNNLvDIiBblOkJ+KIWLyzhXP36EgEg==
|
||||
-----END PUBLIC KEY-----
|
18
platformio.ini
Normal file
18
platformio.ini
Normal file
@ -0,0 +1,18 @@
|
||||
;PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:m5stack-core-esp32]
|
||||
framework = arduino
|
||||
platform = espressif32
|
||||
board = m5stack-core-esp32
|
||||
|
||||
build_flags = -fpermissive
|
||||
lib_deps =
|
||||
OPTIGA Trust X@1.0.5
|
1
pubkey.der
Normal file
1
pubkey.der
Normal file
@ -0,0 +1 @@
|
||||
”ЧЦЩмІяhSиДЭэ–S “Џs3Э¬Њ.My\¤K›$цмcН*з УKј2"№NђџЉ!bтОПЯЎ
|
BIN
pubreza.bin
Normal file
BIN
pubreza.bin
Normal file
Binary file not shown.
4
reza.pem
Normal file
4
reza.pem
Normal file
@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1fkc1CsgEJwFZYuwKef7FmLnANBu
|
||||
sTf6IyktRrcO9B89tTcEY6lk1OWfjB2RjRRqpkLoyRWQQf8EuUdqNmX2iQ==
|
||||
-----END PUBLIC KEY-----
|
BIN
sigasn.bin
Normal file
BIN
sigasn.bin
Normal file
Binary file not shown.
1
sigdata64.sig
Normal file
1
sigdata64.sig
Normal file
@ -0,0 +1 @@
|
||||
MEUCIAIgazJVRkrj7VBnBClMSeXETfw2XTuQsXT2wrWDnfJMAiEATjUCIQDA3H/RiapPfuLdrQuC3lkdmLrS46v20k5BSSU=
|
BIN
signormal.bin
Normal file
BIN
signormal.bin
Normal file
Binary file not shown.
156
src/fprint.h
Normal file
156
src/fprint.h
Normal file
@ -0,0 +1,156 @@
|
||||
#ifndef FPRINT_H
|
||||
#define FPRINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#ifndef SUPPRESSCOLLORS
|
||||
#define ANSI_COLOR_RED "\x1b[31m"
|
||||
#define ANSI_COLOR_GREEN "\x1b[32m"
|
||||
#define ANSI_COLOR_YELLOW "\x1b[33m"
|
||||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||||
#define ANSI_COLOR_MAGENTA "\x1b[35m"
|
||||
#define ANSI_COLOR_CYAN "\x1b[36m"
|
||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||
#else
|
||||
#define ANSI_COLOR_RED ""
|
||||
#define ANSI_COLOR_GREEN ""
|
||||
#define ANSI_COLOR_YELLOW ""
|
||||
#define ANSI_COLOR_BLUE ""
|
||||
#define ANSI_COLOR_MAGENTA ""
|
||||
#define ANSI_COLOR_CYAN ""
|
||||
#define ANSI_COLOR_RESET ""
|
||||
#endif
|
||||
|
||||
#define MAXCMD_LEN 255
|
||||
#define HEXDUMP_COLS 16
|
||||
|
||||
#ifndef SUPPRESSHEXDUMP
|
||||
#define SUPPRESSHEXDUMP 0
|
||||
#endif
|
||||
#define HEXDUMP(a, b) (SUPPRESSHEXDUMP == 0) ? __hexdump__(a, b) : (void)0;
|
||||
/**
|
||||
*
|
||||
* This function prints a given input in green
|
||||
* color with a \r\n signs at the end
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
inline void printlnGreen(const char c[]) {
|
||||
char tmp[100];
|
||||
sprintf(tmp, "%s%s%s", ANSI_COLOR_GREEN, c, ANSI_COLOR_RESET);
|
||||
Serial.println(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function prints a given input in red
|
||||
* color with a \r\n signs at the end
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
inline void printlnRed(const char c[]) {
|
||||
char tmp[100];
|
||||
sprintf(tmp, "%s%s%s", ANSI_COLOR_RED, c, ANSI_COLOR_RESET);
|
||||
Serial.println(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function prints a given input in magenta
|
||||
* color with a \r\n signs at the end
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
inline void printlnMagenta(const char c[]) {
|
||||
char tmp[100];
|
||||
sprintf(tmp, "%s%s%s", ANSI_COLOR_MAGENTA, c, ANSI_COLOR_RESET);
|
||||
Serial.println(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function prints a given input in magenta
|
||||
* color without a \r\n signs at the end
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
inline void printMagenta(const char c[]) {
|
||||
char tmp[100];
|
||||
sprintf(tmp, "%s%s%s", ANSI_COLOR_MAGENTA, c, ANSI_COLOR_RESET);
|
||||
Serial.print(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function prints a given input in green
|
||||
* color without a \r\n signs at the end
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
inline void printGreen(const char c[]) {
|
||||
char tmp[100];
|
||||
sprintf(tmp, "%s%s%s", ANSI_COLOR_GREEN, c, ANSI_COLOR_RESET);
|
||||
Serial.print(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Printout data in a standard hex view
|
||||
*
|
||||
* @param[in] p_buf Pointer to data which should be printed out.
|
||||
* @param[in] l_len Length of a data
|
||||
*
|
||||
* @retval None
|
||||
* @example
|
||||
0x000000: 2e 2f 68 65 78 64 75 6d ./hexdum
|
||||
0x000008: 70 00 53 53 48 5f 41 47 p.SSH_AG
|
||||
0x000010: 45 4e 54 5f ENT_
|
||||
*/
|
||||
inline void __hexdump__(const void *p_buf, uint32_t l_len) {
|
||||
unsigned int i, j;
|
||||
char str[MAXCMD_LEN];
|
||||
for (i = 0; i < l_len + ((l_len % HEXDUMP_COLS) ? (HEXDUMP_COLS - l_len % HEXDUMP_COLS) : 0); i++) {
|
||||
/* print offset */
|
||||
if (i % HEXDUMP_COLS == 0) {
|
||||
sprintf(str, "0x%06x: ", i);
|
||||
Serial.print(str);
|
||||
}
|
||||
|
||||
/* print hex data */
|
||||
if (i < l_len) {
|
||||
sprintf(str, "%02x ", 0xFF & ((char *)p_buf)[i]);
|
||||
Serial.print(str);
|
||||
} else /* end of block, just aligning for ASCII dump */
|
||||
{
|
||||
sprintf(str, " ");
|
||||
Serial.print(str);
|
||||
}
|
||||
|
||||
/* print ASCII dump */
|
||||
if (i % HEXDUMP_COLS == (HEXDUMP_COLS - 1)) {
|
||||
for (j = i - (HEXDUMP_COLS - 1); j <= i; j++) {
|
||||
if (j >= l_len) /* end of block, not really printing */
|
||||
{
|
||||
Serial.print(' ');
|
||||
} else if (isprint((int)((char *)p_buf)[j])) /* printable char */
|
||||
{
|
||||
Serial.print(((char *)p_buf)[j]);
|
||||
} else /* other char */
|
||||
{
|
||||
Serial.print('.');
|
||||
}
|
||||
}
|
||||
Serial.print('\r');
|
||||
Serial.print('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
267
src/main.cpp
Normal file
267
src/main.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Infineon Technologies AG
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE
|
||||
*
|
||||
* Demonstrates use of the
|
||||
* Infineon Technologies AG OPTIGA™ Trust X Arduino library
|
||||
*/
|
||||
|
||||
#include "OPTIGATrustX.h"
|
||||
|
||||
#define MAXCMD_LEN 255
|
||||
#define CERT_LENGTH 512
|
||||
#define RND_LENGTH 64
|
||||
#define HASH_LENGTH 32
|
||||
#define SIGN_LENGTH 80
|
||||
#define PUBKEY_LENGTH 70
|
||||
#define UID_LENGTH 27
|
||||
|
||||
#define SUPPRESSCOLLORS
|
||||
#include "fprint.h"
|
||||
#include <WiFi.h>
|
||||
|
||||
bool oldButton = true;
|
||||
#define button 18
|
||||
|
||||
|
||||
const char* ssid = "LBsPhone";
|
||||
const char* password = "simple";
|
||||
|
||||
const char* host = "192.168.0.111";
|
||||
const int port = 8234;
|
||||
|
||||
#define ASSERT(err) if (ret) { printlnRed("Failed"); while (true); }
|
||||
|
||||
/*
|
||||
* Allocating buffers for further use in loop()
|
||||
*/
|
||||
uint8_t *cert = new uint8_t[CERT_LENGTH];
|
||||
uint16_t certLen = CERT_LENGTH;
|
||||
uint8_t *rnd = new uint8_t[RND_LENGTH];
|
||||
uint16_t rndLen = RND_LENGTH;
|
||||
uint8_t *hash = new uint8_t[HASH_LENGTH];
|
||||
uint16_t hashLen = HASH_LENGTH;
|
||||
uint8_t *rawSign = new uint8_t[SIGN_LENGTH];
|
||||
uint8_t *formSign = new uint8_t[SIGN_LENGTH];
|
||||
uint16_t signLen = SIGN_LENGTH;
|
||||
uint8_t *format = new uint8_t[SIGN_LENGTH];
|
||||
uint16_t formatLen = SIGN_LENGTH;
|
||||
uint8_t *pubKey = new uint8_t[PUBKEY_LENGTH];
|
||||
uint16_t pubKeyLen = PUBKEY_LENGTH;
|
||||
uint8_t *uid = new uint8_t[UID_LENGTH];
|
||||
|
||||
|
||||
|
||||
|
||||
static void output_result(char* tag, uint8_t* in, uint16_t in_len)
|
||||
{
|
||||
printlnGreen("OK");
|
||||
printMagenta(tag);
|
||||
printMagenta(" Length: ");
|
||||
Serial.println(in_len);
|
||||
printMagenta(tag);
|
||||
printlnMagenta(":");
|
||||
HEXDUMP(in, in_len);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint8_t cntr = 10;
|
||||
uint8_t ifxPublicKey[68];
|
||||
|
||||
/*
|
||||
* Getting co-processor Unique ID
|
||||
*/
|
||||
printGreen("Get co-processor UID ... ");
|
||||
uint16_t uidLength = UID_LENGTH;
|
||||
ret = trustX.getUniqueID(uid, uidLength);
|
||||
ASSERT(ret);
|
||||
output_result("Co-processor UID", uid, uidLength);
|
||||
|
||||
/*
|
||||
* Getting primary certificate
|
||||
*/
|
||||
printGreen("Reading cert ... ");
|
||||
ret = trustX.getCertificate(cert, certLen);
|
||||
ASSERT(ret);
|
||||
output_result("Certificate", cert, certLen);
|
||||
|
||||
/*
|
||||
* Generate a Keypair
|
||||
*/
|
||||
|
||||
/*
|
||||
printGreen("Generate Key Pair ... ");
|
||||
uint16_t ctx = 0;
|
||||
ret = trustX.generateKeypair(pubKey, pubKeyLen, ctx);
|
||||
ASSERT(ret);
|
||||
output_result("Public key", pubKey, pubKeyLen);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get random value of RND_LENGTH length
|
||||
*/
|
||||
/*
|
||||
printGreen("Get random value ... ");
|
||||
ret = trustX.getRandom(RND_LENGTH, rnd);
|
||||
ASSERT(ret);
|
||||
output_result("Random", rnd, RND_LENGTH);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Calculate SHA256 value
|
||||
*/
|
||||
|
||||
char cmd[6] = "press\n";
|
||||
|
||||
output_result("PRESS", cmd, 6);
|
||||
|
||||
|
||||
printGreen("Calculate Hash ... ");
|
||||
ret = trustX.sha256(cmd, 6, hash);
|
||||
hashLen = 32;
|
||||
ASSERT(ret);
|
||||
output_result("SHA256", hash, hashLen);
|
||||
|
||||
|
||||
/*
|
||||
* Generate a signature NIST-P256
|
||||
*/
|
||||
printGreen("Generate Signature ... ");
|
||||
ret = trustX.calculateSignature(hash, hashLen, eFIRST_DEVICE_PRIKEY_1, formSign, signLen);
|
||||
Serial.printf("Code: %u\n", ret);
|
||||
ASSERT(ret);
|
||||
output_result("Signature", formSign, signLen);
|
||||
|
||||
printGreen("Format Signature ... ");
|
||||
ret = trustX.formatSignature(formSign, signLen, format, formatLen);
|
||||
ASSERT(ret);
|
||||
output_result("Signature Formated", format, formatLen);
|
||||
|
||||
/*
|
||||
* Verify just geberated signature
|
||||
*/
|
||||
trustX.getPublicKey(ifxPublicKey);
|
||||
|
||||
printGreen("Verify Signature ... ");
|
||||
ret = trustX.verifySignature(hash, hashLen, formSign, signLen);
|
||||
ASSERT(ret);
|
||||
printlnGreen("OK");
|
||||
|
||||
// init wifi
|
||||
// connect to server and send
|
||||
|
||||
/*
|
||||
* Count down 10 seconds and restart the application
|
||||
*/
|
||||
while(cntr) {
|
||||
Serial.print(cntr);
|
||||
Serial.println(" seconds untill restart.");
|
||||
delay(1000);
|
||||
cntr--;
|
||||
}
|
||||
}
|
||||
|
||||
void initWifi(){
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected with IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void sendData(uint8_t* data, uint16_t len) {
|
||||
Serial.print("connecting to ");
|
||||
Serial.println(host);
|
||||
// Use WiFiClient class to create TCP connections
|
||||
WiFiClient client;
|
||||
|
||||
if (!client.connect(host, port)) {
|
||||
Serial.println("connection failed");
|
||||
return;
|
||||
}
|
||||
// This will send the data to the server
|
||||
client.print("hello world");
|
||||
client.stop();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/*
|
||||
* Initialise serial output
|
||||
*/
|
||||
Serial.begin(38400);
|
||||
Serial.println("Initializing ... ");
|
||||
|
||||
/*
|
||||
* Initialise OPTIGA™ Trust X
|
||||
*/
|
||||
printGreen("Begin Trust ... ");
|
||||
ret = trustX.begin();
|
||||
ASSERT(ret);
|
||||
printlnGreen("OK");
|
||||
|
||||
/*
|
||||
* Speed up the chip (min is 6ma, maximum is 15ma)
|
||||
*/
|
||||
printGreen("Setting Current Limit... ");
|
||||
ret = trustX.setCurrentLimit(15);
|
||||
ASSERT(ret);
|
||||
printlnGreen("OK");
|
||||
|
||||
/*
|
||||
* Check the return value which we just set
|
||||
*/
|
||||
printGreen("Checking Power Limit... ");
|
||||
uint8_t current_lim = 0;
|
||||
ret = trustX.getCurrentLimit(current_lim);
|
||||
ASSERT(ret);
|
||||
if (current_lim == 15) {
|
||||
printlnGreen("OK");
|
||||
} else {
|
||||
printlnRed("Failed");
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkButton(){
|
||||
if(digitalRead(button) != oldButton){
|
||||
delay(5);
|
||||
if(digitalRead(button) != oldButton){
|
||||
if (oldButton == HIGH) {
|
||||
// Presed down
|
||||
} else {
|
||||
// pressed up
|
||||
}
|
||||
oldButton = digitalRead(button);
|
||||
}
|
||||
}
|
||||
}
|
BIN
staticdata.sig
Normal file
BIN
staticdata.sig
Normal file
Binary file not shown.
1
staticdata2.bin
Normal file
1
staticdata2.bin
Normal file
@ -0,0 +1 @@
|
||||
nML‚§<E2809A>µ<EFBFBD>k„ץֳiֹ~ײ ·םֱמ”?’ַq״#kה ~5<>₪ֺ<E282AA>)וZלWAsפַ<D7A4><D6B7>097«A³«ײ´•qs
|
11
test/README
Normal file
11
test/README
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
Loading…
Reference in New Issue
Block a user