1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#include <stdbool.h>
#include <osmocom/core/application.h>
#include <osmocom/core/logging.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/auth.h>
#define min(A,B) ((A)>(B)? (B) : (A))
#if 0
static char *auth_tuple_str(struct gsm_auth_tuple *atuple)
{
static char buf[256];
char *pos = buf;
int len = sizeof(buf);
int l;
#define print2buf(FMT, args...) do {\
l = snprintf(pos, len, FMT, ## args); \
pos += l;\
len -= l;\
} while (0)
print2buf("gsm_auth_tuple {\n");
print2buf(" .use_count = %d\n", atuple->use_count);
print2buf(" .key_seq = %d\n", atuple->key_seq);
print2buf(" .rand = %s\n", osmo_hexdump(atuple->vec.rand, sizeof(atuple->vec.rand)));
print2buf(" .sres = %s\n", osmo_hexdump(atuple->vec.sres, sizeof(atuple->vec.sres)));
print2buf(" .kc = %s\n", osmo_hexdump(atuple->vec.kc, sizeof(atuple->vec.kc)));
print2buf("}\n");
#undef print2buf
return buf;
}
static bool auth_tuple_is(struct gsm_auth_tuple *atuple,
const char *expect_str)
{
int l, l1, l2;
int i;
char *tuple_str = auth_tuple_str(atuple);
bool same = (strcmp(expect_str, tuple_str) == 0);
if (!same) {
l1 = strlen(expect_str);
l2 = strlen(tuple_str);
printf("Expected %d:\n%s\nGot %d:\n%s\n",
l1, expect_str, l2, tuple_str);
l = min(l1, l2);
for (i = 0; i < l; i++) {
if (expect_str[i] != tuple_str[i]) {
printf("Difference at pos %d"
" (%c 0x%0x != %c 0x%0x)\n",
i, expect_str[i], expect_str[i],
tuple_str[i], tuple_str[i]);
break;
}
}
}
return same;
}
#endif
int test_get_authinfo_rc = 0;
struct gsm_auth_info test_auth_info = {0};
struct gsm_auth_info default_auth_info = {
.auth_algo = AUTH_ALGO_COMP128v1,
.a3a8_ki_len = 16,
.a3a8_ki = { 0 }
};
int main(void)
{
osmo_init_logging(&log_info);
log_set_log_level(osmo_stderr_target, LOGL_INFO);
printf("Nothing being tested!\n");
/* TODO auth_get_tuple_for_subscr() no longer exists ... test auth somehow?? */
return 0;
}
|