Skip to content

Commit 7681f0d

Browse files
committed
Readd patches nRFCrypto library
1 parent b58f1cc commit 7681f0d

File tree

108 files changed

+14524
-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.

108 files changed

+14524
-0
lines changed

libraries/Adafruit_nRFCrypto/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Adafruit Industries
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.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Adafruit nRFCrypto
2+
3+
Adafruit Arduino Cryptography Library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Bluefruit. CryptoCell CC310 is only available on nRF52840 therefore nRF52832 is not supported by this library.
4+
5+
Although this library license is MIT, it uses ARM precompiled static library, which has its own [licence here](src/cortex-m4/license.txt). Please make sure you understand all the license term for files you use in your project.

libraries/Adafruit_nRFCrypto/examples/hash/.feather52832.test.skip

Whitespace-only changes.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include "Adafruit_nRFCrypto.h"
2+
#include <Adafruit_TinyUSB.h> // for Serial
3+
4+
/* Input data for testing
5+
* Same data is stored in input_data.bin file, to verify the result, run hash sum on your PC
6+
* and compare the result with this sketch
7+
*
8+
* $ sha1sum input_data.bin
9+
* 9f9da10ec23735930089a8f89b34f7b5d267903e
10+
*
11+
* $ sha224sum input_data.bin
12+
* 68abe34d09a758be6b2fb3a7a997983a639687099d35406f927a5cc5
13+
*
14+
* $ sha256sum input_data.bin
15+
* 75cfb39b62c474921e2aad979c210f8b69180a9d58e9f296a4b9904ae6e7aa40
16+
*
17+
* $ sha512sum input_data.bin
18+
* e3979c6296e282af04619992f71addfefd118be26626cedd715edced36b87058f868b316e725b24e1e7f661ce2935e44ba4deea62afa3e13188071403a2f1463
19+
*/
20+
uint8_t input_data[] =
21+
{
22+
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
23+
0x65, 0xa2, 0x32, 0xd6, 0xbc, 0xd0, 0xf9, 0x39, 0xed, 0x1f, 0xe1, 0x28, 0xc1, 0x3b, 0x0e, 0x1b
24+
};
25+
26+
nRFCrypto_Hash hash;
27+
28+
// the setup function runs once when you press reset or power the board
29+
void setup()
30+
{
31+
// initialize digital pin LED_BUILTIN as an output.
32+
pinMode(LED_BUILTIN, OUTPUT);
33+
34+
while( !Serial) delay(10);
35+
Serial.println("nRFCrypto Hash example");
36+
37+
nRFCrypto.begin();
38+
39+
test_hash(CRYS_HASH_SHA1_mode , "SHA-1");
40+
test_hash(CRYS_HASH_SHA224_mode , "SHA-224");
41+
test_hash(CRYS_HASH_SHA256_mode , "SHA-256");
42+
test_hash(CRYS_HASH_SHA512_mode , "SHA-512");
43+
44+
// Note: SHA384 and MD5 currently cause hardfault
45+
// test_hash(CRYS_HASH_SHA384_mode , "SHA384");
46+
// test_hash(CRYS_HASH_MD5_mode , "MD5");
47+
48+
nRFCrypto.end();
49+
50+
}
51+
52+
void test_hash(uint32_t mode, const char* modestr)
53+
{
54+
uint32_t result[16];
55+
uint8_t result_len; // depending on Hash mode
56+
57+
hash.begin(mode);
58+
hash.update(input_data, sizeof(input_data));
59+
result_len = hash.end(result);
60+
61+
Serial.print(" ");
62+
Serial.flush();
63+
Serial.println(modestr);
64+
65+
Serial.printBuffer( (uint8_t*) result, result_len, ' ', 16);
66+
67+
Serial.println();
68+
Serial.println();
69+
70+
Serial.flush();
71+
}
72+
73+
void loop()
74+
{
75+
digitalToggle(LED_BUILTIN);
76+
delay(1000);
77+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
k���.@���=~s�*e�2ּ��9��(�;

libraries/Adafruit_nRFCrypto/examples/random/.feather52832.test.skip

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "Adafruit_nRFCrypto.h"
2+
#include <Adafruit_TinyUSB.h> // for Serial
3+
4+
// Bufer to hold randomized data
5+
uint8_t buffer[32];
6+
7+
// the setup function runs once when you press reset or power the board
8+
void setup()
9+
{
10+
// initialize digital pin LED_BUILTIN as an output.
11+
pinMode(LED_BUILTIN, OUTPUT);
12+
13+
// while(!Serial) delay(10);
14+
Serial.println("nRFCrypto Random example");
15+
delay(10);
16+
17+
nRFCrypto.begin();
18+
}
19+
20+
void loop()
21+
{
22+
// Generate new random 32 bytes every 1 second
23+
nRFCrypto.Random.generate(buffer, sizeof(buffer));
24+
25+
// Print to Serial
26+
Serial.printBuffer(buffer, sizeof(buffer));
27+
Serial.println();
28+
29+
digitalToggle(LED_BUILTIN);
30+
delay(1000);
31+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
3+
env = DefaultEnvironment()
4+
5+
# An extra script is required to properly handle extra link flags set in
6+
# the `library.properties` file
7+
if env.BoardConfig().get("build.mcu", "").startswith("nrf5284"):
8+
env.Append(
9+
LIBPATH=[os.path.realpath("src/cortex-m4/fpv4-sp-d16-hard")],
10+
LIBS=["nrf_cc310_0.9.13-no-interrupts"]
11+
)
12+
env.Append(
13+
CPPDEFINES=[("NRF_CRYPTOCELL", "((NRF_CRYPTOCELL_Type*) NRF_CRYPTOCELL_BASE)")],
14+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "Adafruit nRFCrypto",
3+
"build": {
4+
"extraScript": "extra_script.py"
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name=Adafruit nRFCrypto
2+
version=0.0.5
3+
author=Adafruit
4+
maintainer=Adafruit <[email protected]>
5+
sentence=Arduino Cryptography library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Adafruit Bluefruit LE modules
6+
paragraph=Arduino Cryptography library using hardware-accelerated ARM CryptoCell CC310 on nRF52-based Adafruit Bluefruit LE modules
7+
category=Data Processing
8+
url=https://github.com/adafruit/Adafruit_nRFCrypto
9+
architectures=*
10+
includes=Adafruit_nRFCrypto.h
11+
precompiled=true
12+
ldflags=-lnrf_cc310_0.9.13-no-interrupts

0 commit comments

Comments
 (0)