aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2016-07-21 15:03:48 +0200
committerJoakim Bech <joakim.bech@linaro.org>2016-07-21 15:03:48 +0200
commit9ecf0b05385e0e4f4df2fe6eba1763fcefff9422 (patch)
treedf33df967de3439008b3eee3688e770a20388d9b
parent06b9b9392217cee9e91b452271e32732f6c6f8c1 (diff)
Dummy commit in the middle of some investigation
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
-rw-r--r--source/main.c47
-rw-r--r--test_files/blinky/0.5.0/blinky_signed_0.5.0.zipbin0 -> 3799 bytes
-rw-r--r--test_files/blinky/0.5.0/init_databin0 -> 52 bytes
-rw-r--r--test_files/blinky/0.5.0/init_data_signed.derbin0 -> 71 bytes
-rw-r--r--test_files/blinky/0.5.0/init_data_signed_forget.derbin0 -> 72 bytes
-rw-r--r--test_files/blinky/0.5.0/manifest.json21
-rw-r--r--test_files/blinky/0.5.0/nrf52832_xxaa_s132.binbin0 -> 2524 bytes
-rw-r--r--test_files/blinky/0.5.0/nrf52832_xxaa_s132.datbin0 -> 116 bytes
-rw-r--r--test_files/blinky/0.5.0/pub_from_openssl.pem4
-rw-r--r--test_files/blinky/1.0.0/blinky_signed_1.0.0.zipbin0 -> 3188 bytes
-rw-r--r--test_files/blinky/1.0.0/manifest.json8
-rw-r--r--test_files/blinky/1.0.0/nrf52832_xxaa_s132.binbin0 -> 2524 bytes
-rw-r--r--test_files/blinky/1.0.0/nrf52832_xxaa_s132.datbin0 -> 139 bytes
-rw-r--r--test_files/blinky/key_0.5.0.pem5
-rw-r--r--test_files/manifest.json21
-rw-r--r--test_files/s132_pca10040.binbin0 -> 23516 bytes
-rw-r--r--test_files/s132_pca10040.datbin0 -> 116 bytes
17 files changed, 99 insertions, 7 deletions
diff --git a/source/main.c b/source/main.c
index 4ade279..a9eb79e 100644
--- a/source/main.c
+++ b/source/main.c
@@ -376,14 +376,32 @@ static uint8_t m_extended_packet_length; //< Length o
#define DFU_INIT_PACKET_USES_ECDS (2)
/** @snippet [DFU BLE Signing public key curve points] */
-static uint8_t Qx[] = { 0x39, 0xb0, 0x58, 0x3d, 0x27, 0x07, 0x91, 0x38, 0x6a, 0xa3, 0x36, 0x0f, 0xa2, 0xb5, 0x86, 0x7e, 0xae, 0xba, 0xf7, 0xa3, 0xf4, 0x81, 0x5f, 0x78, 0x02, 0xf2, 0xa1, 0x21, 0xd5, 0x21, 0x84, 0x12 };
-static uint8_t Qy[] = { 0x4a, 0x0d, 0xfe, 0xa4, 0x77, 0x50, 0xb1, 0xb5, 0x26, 0xc0, 0x9d, 0xdd, 0xf0, 0x24, 0x90, 0x57, 0x6c, 0x64, 0x3b, 0xd3, 0xdf, 0x92, 0x3b, 0xb3, 0x47, 0x97, 0x83, 0xd4, 0xfc, 0x76, 0xf5, 0x9d };
+static uint8_t Qx[] = { 0x65, 0x8d, 0xa2, 0xed, 0xdb, 0x98, 0x1f, 0x69, 0x7d, 0xae, 0x72, 0x20, 0xd6, 0x82, 0x17, 0xab, 0xed, 0x3f, 0xb8, 0x70, 0x05, 0xec, 0x8a, 0x05, 0xb9, 0xb5, 0x6b, 0xbb, 0xaa, 0x17, 0xf4, 0x60 };
+static uint8_t Qy[] = { 0x90, 0x9b, 0xae, 0xcd, 0xad, 0x72, 0x26, 0xc2, 0x04, 0xb6, 0x12, 0xb6, 0x62, 0xff, 0x4f, 0xcc, 0xbd, 0x1b, 0x0c, 0x90, 0x84, 0x10, 0x90, 0xd8, 0x3a, 0x59, 0xcd, 0xad, 0x6c, 0x98, 0x1d, 0x4c };
+
/** @snippet [DFU BLE Signing public key curve points] */
+static nrf_sec_ecc_point_t Q = {.p_x = Qx,
+ .x_len = sizeof(Qx),
+ .p_y = Qy,
+ .y_len = sizeof(Qy)};
+
-static nrf_sec_ecc_point_t Q = {.p_x = Qx,
- .x_len = sizeof(Qx),
- .p_y = Qy,
- .y_len = sizeof(Qy)};
+static uint8_t openssl_r[] = { 0x89, 0xFF, 0xEC, 0x79, 0x2B, 0x04, 0x6F, 0x97,
+ 0x09, 0xC9, 0xD8, 0x47, 0x0D, 0xA8, 0x9B, 0x72, 0x68, 0xCE, 0x83, 0xBD,
+ 0x79, 0xD7, 0x6E, 0xFB, 0x1A, 0x1A, 0x59, 0x7F, 0x49, 0xE2, 0xD1, 0x7D
+};
+static uint8_t openssl_s[] = {
+ 0x2D, 0x42, 0x30, 0x09, 0xC4, 0x13, 0xD9, 0xC6, 0x9D, 0x25, 0x39, 0x09, 0xFF, 0xDF, 0x1F, 0x77, 0xD2, 0xF7, 0xF9, 0x90, 0x6E, 0x31, 0x6B, 0x82, 0xA0, 0xD2, 0xE5, 0xDE, 0x91, 0x74, 0x42, 0xE5
+};
+
+static uint8_t sig[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xfe, 0xff,
+ 0x02, 0x00, 0x00, 0x00, 0xdc, 0x09, 0x00, 0x00, 0x61, 0xde, 0x20, 0x9d,
+ 0xdc, 0xce, 0xc5, 0x8b, 0xea, 0x1d, 0xbc, 0x25, 0xfa, 0x85, 0x34, 0x15,
+ 0x09, 0xf8, 0x41, 0x5c, 0x55, 0xeb, 0x14, 0x2b, 0x23, 0x66, 0xc5, 0x6b,
+ 0xcf, 0x9c, 0xc7, 0x67
+};
+static unsigned int sig_len = 52;
static uint8_t m_init_packet[128];
@@ -503,10 +521,25 @@ uint32_t dfu_init_prevalidate(uint8_t *p_init_data, uint32_t init_data_len)
if (ecdsa_verify(&pub, (uint32_t *)digest, r, s) != TC_SUCCESS)
perror("Verification failed\n");
+ /*
+ * FIXME: Remove this, just to check that we have the correct key
+ * format.
+ */
+ fs_write_public_key("nrd_test_pub.key", &pub, sizeof(pub));
+
+ memset(r, 0, sizeof(r));
+ memset(s, 0, sizeof(s));
+ ecc_bytes2native(r, openssl_r);
+ ecc_bytes2native(s, openssl_s);
+
+ if (ecdsa_verify(&pub, (uint32_t *)digest, r, s) != TC_SUCCESS)
+ perror("Failed!\n");
+ else
+ printf("OK\n");
+
return err_code;
}
-
static void print_usage(char *program)
{
printf("Usage: %s [OPTIONS]\n", program);
diff --git a/test_files/blinky/0.5.0/blinky_signed_0.5.0.zip b/test_files/blinky/0.5.0/blinky_signed_0.5.0.zip
new file mode 100644
index 0000000..745af0f
--- /dev/null
+++ b/test_files/blinky/0.5.0/blinky_signed_0.5.0.zip
Binary files differ
diff --git a/test_files/blinky/0.5.0/init_data b/test_files/blinky/0.5.0/init_data
new file mode 100644
index 0000000..2ec71c8
--- /dev/null
+++ b/test_files/blinky/0.5.0/init_data
Binary files differ
diff --git a/test_files/blinky/0.5.0/init_data_signed.der b/test_files/blinky/0.5.0/init_data_signed.der
new file mode 100644
index 0000000..0059d6c
--- /dev/null
+++ b/test_files/blinky/0.5.0/init_data_signed.der
Binary files differ
diff --git a/test_files/blinky/0.5.0/init_data_signed_forget.der b/test_files/blinky/0.5.0/init_data_signed_forget.der
new file mode 100644
index 0000000..75cfbaa
--- /dev/null
+++ b/test_files/blinky/0.5.0/init_data_signed_forget.der
Binary files differ
diff --git a/test_files/blinky/0.5.0/manifest.json b/test_files/blinky/0.5.0/manifest.json
new file mode 100644
index 0000000..3c25331
--- /dev/null
+++ b/test_files/blinky/0.5.0/manifest.json
@@ -0,0 +1,21 @@
+{
+ "manifest": {
+ "application": {
+ "bin_file": "nrf52832_xxaa_s132.bin",
+ "dat_file": "nrf52832_xxaa_s132.dat",
+ "init_packet_data": {
+ "application_version": 4294967295,
+ "device_revision": 65535,
+ "device_type": 65535,
+ "ext_packet_id": 2,
+ "firmware_hash": "61de209ddccec58bea1dbc25fa85341509f8415c55eb142b2366c56bcf9cc767",
+ "firmware_length": 2524,
+ "init_packet_ecds": "08f22a3d4a7e401c878c56b91e89f30f8a69357baa50d962829cb236a485793f61f9aea0796d878a50776128b0364ad58fdaff71cab11fb35a4ed083f2689d7f",
+ "softdevice_req": [
+ 65534
+ ]
+ }
+ },
+ "dfu_version": 0.8
+ }
+} \ No newline at end of file
diff --git a/test_files/blinky/0.5.0/nrf52832_xxaa_s132.bin b/test_files/blinky/0.5.0/nrf52832_xxaa_s132.bin
new file mode 100644
index 0000000..ac3b09d
--- /dev/null
+++ b/test_files/blinky/0.5.0/nrf52832_xxaa_s132.bin
Binary files differ
diff --git a/test_files/blinky/0.5.0/nrf52832_xxaa_s132.dat b/test_files/blinky/0.5.0/nrf52832_xxaa_s132.dat
new file mode 100644
index 0000000..9b3859f
--- /dev/null
+++ b/test_files/blinky/0.5.0/nrf52832_xxaa_s132.dat
Binary files differ
diff --git a/test_files/blinky/0.5.0/pub_from_openssl.pem b/test_files/blinky/0.5.0/pub_from_openssl.pem
new file mode 100644
index 0000000..34cb636
--- /dev/null
+++ b/test_files/blinky/0.5.0/pub_from_openssl.pem
@@ -0,0 +1,4 @@
+-----BEGIN PUBLIC KEY-----
+MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZY2i7duYH2l9rnIg1oIXq+0/uHAF
+7IoFubVru6oX9GCQm67NrXImwgS2ErZi/0/MvRsMkIQQkNg6Wc2tbJgdTA==
+-----END PUBLIC KEY-----
diff --git a/test_files/blinky/1.0.0/blinky_signed_1.0.0.zip b/test_files/blinky/1.0.0/blinky_signed_1.0.0.zip
new file mode 100644
index 0000000..f6e014e
--- /dev/null
+++ b/test_files/blinky/1.0.0/blinky_signed_1.0.0.zip
Binary files differ
diff --git a/test_files/blinky/1.0.0/manifest.json b/test_files/blinky/1.0.0/manifest.json
new file mode 100644
index 0000000..471c18a
--- /dev/null
+++ b/test_files/blinky/1.0.0/manifest.json
@@ -0,0 +1,8 @@
+{
+ "manifest": {
+ "application": {
+ "bin_file": "nrf52832_xxaa_s132.bin",
+ "dat_file": "nrf52832_xxaa_s132.dat"
+ }
+ }
+} \ No newline at end of file
diff --git a/test_files/blinky/1.0.0/nrf52832_xxaa_s132.bin b/test_files/blinky/1.0.0/nrf52832_xxaa_s132.bin
new file mode 100644
index 0000000..ac3b09d
--- /dev/null
+++ b/test_files/blinky/1.0.0/nrf52832_xxaa_s132.bin
Binary files differ
diff --git a/test_files/blinky/1.0.0/nrf52832_xxaa_s132.dat b/test_files/blinky/1.0.0/nrf52832_xxaa_s132.dat
new file mode 100644
index 0000000..adf5b5d
--- /dev/null
+++ b/test_files/blinky/1.0.0/nrf52832_xxaa_s132.dat
Binary files differ
diff --git a/test_files/blinky/key_0.5.0.pem b/test_files/blinky/key_0.5.0.pem
new file mode 100644
index 0000000..84fdffc
--- /dev/null
+++ b/test_files/blinky/key_0.5.0.pem
@@ -0,0 +1,5 @@
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEID2WUBCe/4kLhl5ekJ+O8PtprcahUNFE3RIm5htQzDedoAoGCCqGSM49
+AwEHoUQDQgAEZY2i7duYH2l9rnIg1oIXq+0/uHAF7IoFubVru6oX9GCQm67NrXIm
+wgS2ErZi/0/MvRsMkIQQkNg6Wc2tbJgdTA==
+-----END EC PRIVATE KEY-----
diff --git a/test_files/manifest.json b/test_files/manifest.json
new file mode 100644
index 0000000..d38a85c
--- /dev/null
+++ b/test_files/manifest.json
@@ -0,0 +1,21 @@
+{
+ "manifest": {
+ "application": {
+ "bin_file": "s132_pca10040.bin",
+ "dat_file": "s132_pca10040.dat",
+ "init_packet_data": {
+ "application_version": 4294967295,
+ "device_revision": 65535,
+ "device_type": 65535,
+ "ext_packet_id": 2,
+ "firmware_hash": "fcdf9d67d6397ca578fcc09ed070f0ff91483b33cc2b5c62cc4ea9b76fe7b5cd",
+ "firmware_length": 23516,
+ "init_packet_ecds": "8953339a15b4e06221adc22ef1a68dcfefe9313a3f5ef5247bd93dd5c893d9582f9d794b63b8b94cf9fb61385d8a8dc92e8399440412fbf76d3b3b911f7f3805",
+ "softdevice_req": [
+ 65534
+ ]
+ }
+ },
+ "dfu_version": 0.8
+ }
+} \ No newline at end of file
diff --git a/test_files/s132_pca10040.bin b/test_files/s132_pca10040.bin
new file mode 100644
index 0000000..0803f3a
--- /dev/null
+++ b/test_files/s132_pca10040.bin
Binary files differ
diff --git a/test_files/s132_pca10040.dat b/test_files/s132_pca10040.dat
new file mode 100644
index 0000000..a84ae5e
--- /dev/null
+++ b/test_files/s132_pca10040.dat
Binary files differ