From b5b11e31fbe23466129b39d37d47b91ae7c42366 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 22 Feb 2017 01:42:43 +0100 Subject: auc_compute_vectors(): fix AUTS resync for multiple vectors Fix bug where AUTS was fed to each vector generation and thus each vector was generated with the same SQN. In auc_3g_test, adjust the bug indicating test expectations to now expect the proper results. Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4 Change-Id: I425a1d92c85896227341f565f5361c0d830ce866 --- src/auc.c | 4 +++- tests/auc/auc_3g_test.c | 46 +--------------------------------------------- tests/auc/auc_3g_test.err | 14 ++++---------- 3 files changed, 8 insertions(+), 56 deletions(-) diff --git a/src/auc.c b/src/auc.c index f4d19a0..9c20db2 100644 --- a/src/auc.c +++ b/src/auc.c @@ -113,7 +113,9 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec, if (aud3g) { /* 3G or 3G + 2G case */ - if (auts) { + /* Do AUTS only for the first vector or we would use + * the same SQN for each following key. */ + if ((i == 0) && auts) { DBGP("vector [%u]: resync: auts = %s\n", i, hex(auts, 14)); DBGP("vector [%u]: resync: rand_auts = %s\n", diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c index 51184c5..7b12358 100644 --- a/tests/auc/auc_3g_test.c +++ b/tests/auc/auc_3g_test.c @@ -239,48 +239,6 @@ static void test_gen_vectors_2g_plus_3g(void) comment_end(); } -void _test_gen_vectors_3g_only__expect_vecs__WRONG(struct osmo_auth_vector vecs[3]) -{ - fprintf(stderr, "THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED\n"); - fprintf(stderr, "The SQN should increment with each new vector.\n"); - fprintf(stderr, "[0]: "); - VEC_IS(&vecs[0], - " rand: 897210a0f7de278f0b8213098e098a3f\n" - " autn: c6b9790dad4b00000cf322869ea6a481\n" - " ck: e9922bd036718ed9e40bd1d02c3b81a5\n" - " ik: f19c20ca863137f8892326d959ec5e01\n" - " res: 9af5a557902d2db80000000000000000\n" - " res_len: 08\n" - " kc: 7526fc13c5976685\n" - " sres: 0ad888ef\n" - " auth_types: 03000000\n" - ); - fprintf(stderr, "[1]: "); - VEC_IS(&vecs[1], - " rand: 9a8321b108ef38a01c93241a9f1a9b50\n" - " autn: 79a5113eb0900000f7e138537aa0962b\n" - " ck: 3686f05df057d1899c66ae4eb18cf941\n" - " ik: 79f21ed53bcb47787de57d136ff803a5\n" - " res: 43023475cb29292c0000000000000000\n" - " res_len: 08\n" - " kc: aef73dd515e86c15\n" - " sres: 882b1d59\n" - " auth_types: 03000000\n" - ); - fprintf(stderr, "[2]: "); - VEC_IS(&vecs[2], - " rand: ab9432c2190049b12da4352bb02bac61\n" - " autn: 24b018d46c390000d88e11730d0367ac\n" - " ck: d86c3191a36fc0602e48202ef2080964\n" - " ik: 648dab72016181406243420649e63dc9\n" - " res: 010cab11cc63a6e40000000000000000\n" - " res_len: 08\n" - " kc: f0eaf8cb19e0758d\n" - " sres: cd6f0df5\n" - " auth_types: 03000000\n" - ); -} - void _test_gen_vectors_3g_only__expect_vecs(struct osmo_auth_vector vecs[3]) { fprintf(stderr, "[0]: "); @@ -487,9 +445,7 @@ static void test_gen_vectors_3g_only(void) next_rand("897210a0f7de278f0b8213098e098a3f", false); rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, rand_auts, auts); - /* THIS IS WRONG AND WILL BE FIXED IN A SUBSEQUENT COMMIT: - should be _test_gen_vectors_3g_only__expect_vecs() instead */ - _test_gen_vectors_3g_only__expect_vecs__WRONG(vecs); + _test_gen_vectors_3g_only__expect_vecs(vecs); comment_end(); } diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err index e8e6f03..aff96c9 100644 --- a/tests/auc/auc_3g_test.err +++ b/tests/auc/auc_3g_test.err @@ -176,10 +176,8 @@ DAUC vector [0]: kc = 7526fc13c5976685 DAUC vector [0]: sres = 0ad888ef DAUC vector [0]: auth_types = 0x3 DAUC vector [1]: rand = 9a8321b108ef38a01c93241a9f1a9b50 -DAUC vector [1]: resync: auts = 979498b1f72d3e28c59fa2e72f9c -DAUC vector [1]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC vector [1]: resync: sqn = 24 -DAUC vector [1]: autn = 79a5113eb0900000f7e138537aa0962b +DAUC vector [1]: sqn = 25 +DAUC vector [1]: autn = 79a5113eb0910000be6020540503ffc5 DAUC vector [1]: ck = 3686f05df057d1899c66ae4eb18cf941 DAUC vector [1]: ik = 79f21ed53bcb47787de57d136ff803a5 DAUC vector [1]: res = 43023475cb29292c0000000000000000 @@ -188,10 +186,8 @@ DAUC vector [1]: kc = aef73dd515e86c15 DAUC vector [1]: sres = 882b1d59 DAUC vector [1]: auth_types = 0x3 DAUC vector [2]: rand = ab9432c2190049b12da4352bb02bac61 -DAUC vector [2]: resync: auts = 979498b1f72d3e28c59fa2e72f9c -DAUC vector [2]: resync: rand_auts = 39fa2f4e3d523d8619a73b4f65c3e14d -DAUC vector [2]: resync: sqn = 24 -DAUC vector [2]: autn = 24b018d46c390000d88e11730d0367ac +DAUC vector [2]: sqn = 26 +DAUC vector [2]: autn = 24b018d46c3b00009c7e1b47f3a19b2b DAUC vector [2]: ck = d86c3191a36fc0602e48202ef2080964 DAUC vector [2]: ik = 648dab72016181406243420649e63dc9 DAUC vector [2]: res = 010cab11cc63a6e40000000000000000 @@ -199,8 +195,6 @@ DAUC vector [2]: res_len = 8 DAUC vector [2]: kc = f0eaf8cb19e0758d DAUC vector [2]: sres = cd6f0df5 DAUC vector [2]: auth_types = 0x3 -THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED -The SQN should increment with each new vector. [0]: vector matches expectations [1]: vector matches expectations [2]: vector matches expectations -- cgit v1.2.3