summaryrefslogtreecommitdiffstats
path: root/tests/gsm0808
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-03-29 15:50:05 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-08 07:44:46 +0000
commitb478dd38d29b0dfdf9d9c4d6f22ec4a24e4c8fcd (patch)
tree74f3d450b5d58906e05efe9d2349d4b47cd20191 /tests/gsm0808
parent783047e86ec64677f3894bd22576315eee631275 (diff)
gsm0808: Add create functions for CIPHER MODE COMMAND
gsm0808.h/c lacks functionality to generate CIPHER MODE COMMAND messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_cipher() function, that generates an A/AoiP CIPHER MODE COMMAND message. Change-Id: I8eb1c357860c3e740b0f5d17e1c256bc87920958
Diffstat (limited to 'tests/gsm0808')
-rw-r--r--tests/gsm0808/gsm0808_test.c41
-rw-r--r--tests/gsm0808/gsm0808_test.ok1
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index af457b4d..f33e0bd1 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -144,6 +144,46 @@ static void test_create_clear_complete()
msgb_free(msg);
}
+static void test_create_cipher()
+{
+ static const uint8_t res[] =
+ { 0x00, 0x0c, 0x53, 0x0a, 0x09, 0x03, 0xaa,
+ 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42 };
+ static const uint8_t res2[] =
+ { 0x00, 0x0e, 0x53, 0x0a, 0x09, 0x03, 0xaa,
+ 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x23, 0x42,
+ GSM0808_IE_CIPHER_RESPONSE_MODE, 0x01 };
+ struct msgb *msg;
+ struct gsm0808_encrypt_info ei;
+ uint8_t include_imeisv;
+
+ memset(&ei, 0, sizeof(ei));
+ ei.perm_algo[0] = GSM0808_ALG_ID_A5_0;
+ ei.perm_algo[1] = GSM0808_ALG_ID_A5_1;
+ ei.perm_algo_len = 2;
+ ei.key[0] = 0xaa;
+ ei.key[1] = 0xbb;
+ ei.key[2] = 0xcc;
+ ei.key[3] = 0xdd;
+ ei.key[4] = 0xee;
+ ei.key[5] = 0xff;
+ ei.key[6] = 0x23;
+ ei.key[7] = 0x42;
+ ei.key_len = 8;
+ include_imeisv = 1;
+
+ printf("Testing creating Chipher Mode Command\n");
+ msg = gsm0808_create_cipher(&ei, NULL);
+ OSMO_ASSERT(msg);
+ VERIFY(msg, res, ARRAY_SIZE(res));
+ msgb_free(msg);
+
+ msg = gsm0808_create_cipher(&ei, &include_imeisv);
+ OSMO_ASSERT(msg);
+ VERIFY(msg, res2, ARRAY_SIZE(res2));
+ msgb_free(msg);
+}
+
static void test_create_cipher_complete()
{
static const uint8_t res1[] = {
@@ -700,6 +740,7 @@ int main(int argc, char **argv)
test_create_reset();
test_create_clear_command();
test_create_clear_complete();
+ test_create_cipher();
test_create_cipher_complete();
test_create_cipher_reject();
test_create_cm_u();
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index f406551c..8e2087d8 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -4,6 +4,7 @@ Testing creating Layer3 (AoIP)
Testing creating Reset
Testing creating Clear Command
Testing creating Clear Complete
+Testing creating Chipher Mode Command
Testing creating Cipher Complete
Testing creating Cipher Reject
Testing creating CM U