You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2023/01/31 10:04:29 UTC

[mynewt-nimble] branch master updated (f740c39b -> 2f984a3c)

This is an automated email from the ASF dual-hosted git repository.

andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


    from f740c39b targets: Restore example targets
     new 0bc085e1 nimble/ll/test: Add unit test for BIG/BIS aa
     new 84f50834 nimble/ll/test: Add crypto unit tests
     new 2f984a3c nimble/ll/test: Cleanup tests

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/controller/include/controller/ble_ll_test.h |  35 -----
 nimble/controller/test/src/ble_ll_aa_test.c        | 103 +++++++++++++++
 nimble/controller/test/src/ble_ll_crypto_test.c    | 147 +++++++++++++++++++++
 nimble/controller/test/src/ble_ll_csa2_test.c      |  11 +-
 nimble/controller/test/src/ble_ll_csa2_test.h      |  27 ----
 nimble/controller/test/src/ble_ll_test.c           |  15 ++-
 6 files changed, 263 insertions(+), 75 deletions(-)
 delete mode 100644 nimble/controller/include/controller/ble_ll_test.h
 create mode 100644 nimble/controller/test/src/ble_ll_aa_test.c
 create mode 100644 nimble/controller/test/src/ble_ll_crypto_test.c
 delete mode 100644 nimble/controller/test/src/ble_ll_csa2_test.h


[mynewt-nimble] 03/03: nimble/ll/test: Cleanup tests

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2f984a3c3ec388a5e511179ff2c0e40db1a63368
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 27 20:25:11 2023 +0100

    nimble/ll/test: Cleanup tests
---
 nimble/controller/include/controller/ble_ll_test.h | 35 ----------------------
 nimble/controller/test/src/ble_ll_csa2_test.c      | 11 +++----
 nimble/controller/test/src/ble_ll_csa2_test.h      | 27 -----------------
 nimble/controller/test/src/ble_ll_test.c           | 10 +++----
 4 files changed, 8 insertions(+), 75 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_test.h b/nimble/controller/include/controller/ble_ll_test.h
deleted file mode 100644
index 32984c6b..00000000
--- a/nimble/controller/include/controller/ble_ll_test.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_LL_TEST_
-#define H_LL_TEST_
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int ble_ll_csa2_test_all(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/nimble/controller/test/src/ble_ll_csa2_test.c b/nimble/controller/test/src/ble_ll_csa2_test.c
index 566500e3..ae8f8897 100644
--- a/nimble/controller/test/src/ble_ll_csa2_test.c
+++ b/nimble/controller/test/src/ble_ll_csa2_test.c
@@ -17,13 +17,10 @@
  * under the License.
  */
 
-#include <stddef.h>
-#include <string.h>
-#include "testutil/testutil.h"
-#include "controller/ble_ll_test.h"
-#include "controller/ble_ll_conn.h"
-#include "controller/ble_ll_utils.h"
-#include "ble_ll_csa2_test.h"
+#include <stdint.h>
+#include <controller/ble_ll_conn.h>
+#include <controller/ble_ll_utils.h>
+#include <testutil/testutil.h>
 
 TEST_CASE_SELF(ble_ll_csa2_test_1)
 {
diff --git a/nimble/controller/test/src/ble_ll_csa2_test.h b/nimble/controller/test/src/ble_ll_csa2_test.h
deleted file mode 100644
index 5bcc142b..00000000
--- a/nimble/controller/test/src/ble_ll_csa2_test.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_BLE_LL_CSA2_TEST_
-#define H_BLE_LL_CSA2_TEST_
-
-#include "testutil/testutil.h"
-
-TEST_SUITE_DECL(ble_ll_csa2_test_suite);
-
-#endif
diff --git a/nimble/controller/test/src/ble_ll_test.c b/nimble/controller/test/src/ble_ll_test.c
index e496e15f..2b36cb1f 100644
--- a/nimble/controller/test/src/ble_ll_test.c
+++ b/nimble/controller/test/src/ble_ll_test.c
@@ -17,17 +17,14 @@
  * under the License.
  */
 
-#include "sysinit/sysinit.h"
-#include "syscfg/syscfg.h"
-#include "controller/ble_ll_test.h"
-#include "os/os.h"
-#include "testutil/testutil.h"
-#include "ble_ll_csa2_test.h"
+#include <syscfg/syscfg.h>
+#include <testutil/testutil.h>
 
 #if MYNEWT_VAL(SELFTEST)
 
 TEST_SUITE_DECL(ble_ll_aa_test_suite);
 TEST_SUITE_DECL(ble_ll_crypto_test_suite);
+TEST_SUITE_DECL(ble_ll_csa2_test_suite);
 
 int
 main(int argc, char **argv)
@@ -35,6 +32,7 @@ main(int argc, char **argv)
     ble_ll_aa_test_suite();
     ble_ll_crypto_test_suite();
     ble_ll_csa2_test_suite();
+
     return tu_any_failed;
 }
 


[mynewt-nimble] 02/03: nimble/ll/test: Add crypto unit tests

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 84f50834807d61b382070420cdc732af63f053ee
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 27 20:39:23 2023 +0100

    nimble/ll/test: Add crypto unit tests
---
 nimble/controller/test/src/ble_ll_crypto_test.c | 147 ++++++++++++++++++++++++
 nimble/controller/test/src/ble_ll_test.c        |   2 +
 2 files changed, 149 insertions(+)

diff --git a/nimble/controller/test/src/ble_ll_crypto_test.c b/nimble/controller/test/src/ble_ll_crypto_test.c
new file mode 100644
index 00000000..a2e727a0
--- /dev/null
+++ b/nimble/controller/test/src/ble_ll_crypto_test.c
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdint.h>
+#include <controller/ble_ll_crypto.h>
+#include <testutil/testutil.h>
+
+TEST_CASE_SELF(ble_ll_crypto_test_h6) {
+    const uint8_t w[] = {
+        0xec, 0x02, 0x34, 0xa3, 0x57, 0xc8, 0xad, 0x05,
+        0x34, 0x10, 0x10, 0xa6, 0x0a, 0x39, 0x7d, 0x9b
+    };
+    const uint8_t key_id[] = { 0x6c, 0x65, 0x62, 0x72 };
+    const uint8_t ok[] = {
+        0x2d, 0x9a, 0xe1, 0x02, 0xe7, 0x6d, 0xc9, 0x1c,
+        0xe8, 0xd3, 0xa9, 0xe2, 0x80, 0xb1, 0x63, 0x99
+    };
+    uint8_t out[16];
+    int rc;
+
+    rc = ble_ll_crypto_h6(w, key_id, out);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(out, ok, 16);
+    TEST_ASSERT(rc == 0);
+}
+
+TEST_CASE_SELF(ble_ll_crypto_test_h7) {
+    const uint8_t salt[] = {
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x74, 0x6D, 0x70, 0x31
+    };
+    const uint8_t w[] = {
+        0xec, 0x02, 0x34, 0xa3, 0x57, 0xc8, 0xad, 0x05,
+        0x34, 0x10, 0x10, 0xa6, 0x0a, 0x39, 0x7d, 0x9b
+    };
+    const uint8_t ok[] = {
+        0xfb, 0x17, 0x35, 0x97, 0xc6, 0xa3, 0xc0, 0xec,
+        0xd2, 0x99, 0x8c, 0x2a, 0x75, 0xa5, 0x70, 0x11
+    };
+    uint8_t out[16];
+    int rc;
+
+    rc = ble_ll_crypto_h7(salt, w, out);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(out, ok, 16);
+    TEST_ASSERT(rc == 0);
+}
+
+TEST_CASE_SELF(ble_ll_crypto_test_h8) {
+    const uint8_t k[] = {
+        0xec, 0x02, 0x34, 0xa3, 0x57, 0xc8, 0xad, 0x05,
+        0x34, 0x10, 0x10, 0xa6, 0x0a, 0x39, 0x7d, 0x9b
+    };
+    const uint8_t s[] = {
+        0x15, 0x36, 0xd1, 0x8d, 0xe3, 0xd2, 0x0d, 0xf9,
+        0x9b, 0x70, 0x44, 0xc1, 0x2f, 0x9e, 0xd5, 0xba
+    };
+    const uint8_t key_id[] = { 0xcc, 0x03, 0x01, 0x48 };
+    const uint8_t ok[] = {
+        0xe5, 0xe5, 0xbe, 0xba, 0xae, 0x72, 0x28, 0xe7,
+        0x22, 0xa3, 0x89, 0x04, 0xed, 0x35, 0x0f, 0x6d
+    };
+    uint8_t out[16];
+    int rc;
+
+    rc = ble_ll_crypto_h8(k, s, key_id, out);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(out, ok, 16);
+    TEST_ASSERT(rc == 0);
+}
+
+TEST_CASE_SELF(ble_ll_crypto_test_gskd) {
+    const uint8_t broadcast_code[] = {
+        0x00, 0x00, 0x00, 0x00, 0x65, 0x73, 0x75, 0x6f,
+        0x48, 0x20, 0x65, 0x6e, 0x72, 0xb8, 0xc3, 0x42
+    };
+    const uint8_t gskd[] = {
+        0x55, 0x18, 0x8b, 0x3d, 0x32, 0xf6, 0xbb, 0x9a,
+        0x90, 0x0a, 0xfc, 0xfb, 0xee, 0xd4, 0xe7, 0x2a
+    };
+    const uint8_t big1[] = {
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x42, 0x49, 0x47, 0x31
+    };
+    const uint8_t big2[] = { 0x42, 0x49, 0x47, 0x32 };
+    const uint8_t big3[] = { 0x42, 0x49, 0x47, 0x33 };
+    const uint8_t ok_igltk[] = {
+        0x4c, 0x0d, 0xd7, 0x4c, 0x2b, 0x19, 0xaa, 0x95,
+        0xd8, 0x98, 0x23, 0x85, 0x5f, 0x10, 0x01, 0xb8
+    };
+    const uint8_t ok_gltk[] = {
+        0xc4, 0xcd, 0x4b, 0x83, 0x49, 0xb5, 0xa1, 0x8a,
+        0x02, 0xde, 0x66, 0x20, 0x90, 0x17, 0xae, 0xd3
+    };
+    const uint8_t ok_gsk[] = {
+        0xbe, 0x2a, 0x16, 0xfc, 0x7a, 0xc4, 0x64, 0xe7,
+        0x52, 0x30, 0x1b, 0xcc, 0xc8, 0x18, 0x81, 0x2c
+    };
+    uint8_t igltk[16];
+    uint8_t gltk[16];
+    uint8_t gsk[16];
+    int rc;
+
+    rc = ble_ll_crypto_h7(big1, broadcast_code, igltk);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(igltk, ok_igltk, 16);
+    TEST_ASSERT(rc == 0);
+
+    rc = ble_ll_crypto_h6(igltk, big2, gltk);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(gltk, ok_gltk, 16);
+    TEST_ASSERT(rc == 0);
+
+    rc = ble_ll_crypto_h8(gltk, gskd, big3, gsk);
+    TEST_ASSERT(rc == 0);
+
+    rc = memcmp(gsk, ok_gsk, 16);
+    TEST_ASSERT(rc == 0);
+}
+
+TEST_SUITE(ble_ll_crypto_test_suite) {
+    ble_ll_crypto_test_h6();
+    ble_ll_crypto_test_h7();
+    ble_ll_crypto_test_h8();
+    ble_ll_crypto_test_gskd();
+}
diff --git a/nimble/controller/test/src/ble_ll_test.c b/nimble/controller/test/src/ble_ll_test.c
index efb9bf00..e496e15f 100644
--- a/nimble/controller/test/src/ble_ll_test.c
+++ b/nimble/controller/test/src/ble_ll_test.c
@@ -27,11 +27,13 @@
 #if MYNEWT_VAL(SELFTEST)
 
 TEST_SUITE_DECL(ble_ll_aa_test_suite);
+TEST_SUITE_DECL(ble_ll_crypto_test_suite);
 
 int
 main(int argc, char **argv)
 {
     ble_ll_aa_test_suite();
+    ble_ll_crypto_test_suite();
     ble_ll_csa2_test_suite();
     return tu_any_failed;
 }


[mynewt-nimble] 01/03: nimble/ll/test: Add unit test for BIG/BIS aa

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 0bc085e16562a5ed9668831c086c093623a5e95a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 27 20:23:19 2023 +0100

    nimble/ll/test: Add unit test for BIG/BIS aa
---
 nimble/controller/test/src/ble_ll_aa_test.c | 103 ++++++++++++++++++++++++++++
 nimble/controller/test/src/ble_ll_test.c    |   3 +
 2 files changed, 106 insertions(+)

diff --git a/nimble/controller/test/src/ble_ll_aa_test.c b/nimble/controller/test/src/ble_ll_aa_test.c
new file mode 100644
index 00000000..4d64d87a
--- /dev/null
+++ b/nimble/controller/test/src/ble_ll_aa_test.c
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdint.h>
+#include <controller/ble_ll_utils.h>
+#include <testutil/testutil.h>
+
+TEST_CASE_SELF(ble_ll_aa_test_1)
+{
+    uint32_t seed_aa;
+    uint32_t aa;
+
+    seed_aa = 0x78e52493;
+
+    /* BIG Control */
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 0);
+    TEST_ASSERT(aa == 0x7a412493);
+
+    /* BISes */
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 1);
+    TEST_ASSERT(aa == 0x85e32493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 2);
+    TEST_ASSERT(aa == 0x79d52493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 3);
+    TEST_ASSERT(aa == 0x86752493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 4);
+    TEST_ASSERT(aa == 0x7a572493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 5);
+    TEST_ASSERT(aa == 0x85f12493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 6);
+    TEST_ASSERT(aa == 0x79d32493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 7);
+    TEST_ASSERT(aa == 0x86732493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 8);
+    TEST_ASSERT(aa == 0x7b652493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 9);
+    TEST_ASSERT(aa == 0x85c72493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 10);
+    TEST_ASSERT(aa == 0x78e12493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 11);
+    TEST_ASSERT(aa == 0x86412493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 12);
+    TEST_ASSERT(aa == 0x7b632493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 13);
+    TEST_ASSERT(aa == 0x85d52493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 14);
+    TEST_ASSERT(aa == 0x78f72493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 15);
+    TEST_ASSERT(aa == 0x86572493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 16);
+    TEST_ASSERT(aa == 0x7b712493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 17);
+    TEST_ASSERT(aa == 0x85d32493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 18);
+    TEST_ASSERT(aa == 0x78c52493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 19);
+    TEST_ASSERT(aa == 0x87652493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 20);
+    TEST_ASSERT(aa == 0x7b472493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 21);
+    TEST_ASSERT(aa == 0x84e12493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 22);
+    TEST_ASSERT(aa == 0x78c32493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 23);
+    TEST_ASSERT(aa == 0x87632493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 24);
+    TEST_ASSERT(aa == 0x7b552493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 25);
+    TEST_ASSERT(aa == 0x84f72493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 26);
+    TEST_ASSERT(aa == 0x78d12493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 27);
+    TEST_ASSERT(aa == 0x87712493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 28);
+    TEST_ASSERT(aa == 0x7b532493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 29);
+    TEST_ASSERT(aa == 0x84c52493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 30);
+    TEST_ASSERT(aa == 0x79e72493);
+    aa = ble_ll_utils_calc_big_aa(seed_aa, 31);
+    TEST_ASSERT(aa == 0x87472493);
+}
+
+TEST_SUITE(ble_ll_aa_test_suite)
+{
+    ble_ll_aa_test_1();
+}
diff --git a/nimble/controller/test/src/ble_ll_test.c b/nimble/controller/test/src/ble_ll_test.c
index ee089afe..efb9bf00 100644
--- a/nimble/controller/test/src/ble_ll_test.c
+++ b/nimble/controller/test/src/ble_ll_test.c
@@ -26,9 +26,12 @@
 
 #if MYNEWT_VAL(SELFTEST)
 
+TEST_SUITE_DECL(ble_ll_aa_test_suite);
+
 int
 main(int argc, char **argv)
 {
+    ble_ll_aa_test_suite();
     ble_ll_csa2_test_suite();
     return tu_any_failed;
 }