blob: 30e16e824c117b28bc99b9405cb3ad1603b1b667 [file] [log] [blame]
Harald Welted82e0eb2011-12-06 21:53:42 +01001#ifndef _OSMOCRYPTO_AUTH_H
2#define _OSMOCRYPTO_AUTH_H
3
4#include <stdint.h>
5
6#include <osmocom/core/linuxlist.h>
7
8/*! \brief Authentication Type */
9enum osmo_sub_auth_type {
10 OSMO_AUTH_TYPE_NONE = 0x00,
11 OSMO_AUTH_TYPE_GSM = 0x01,
12 OSMO_AUTH_TYPE_UMTS = 0x02,
13};
14
15/*! \brief Authentication Algorithm */
16enum osmo_auth_algo {
17 OSMO_AUTH_ALG_NONE,
18 OSMO_AUTH_ALG_COMP128v1,
19 OSMO_AUTH_ALG_COMP128v2,
20 OSMO_AUTH_ALG_COMP128v3,
21 OSMO_AUTH_ALG_XOR,
22 OSMO_AUTH_ALG_MILENAGE,
23 _OSMO_AUTH_ALG_NUM,
24};
25
26/*! \brief permanent (secret) subscriber auth data */
27struct osmo_sub_auth_data {
28 enum osmo_sub_auth_type type;
29 enum osmo_auth_algo algo;
30 union {
31 struct {
32 uint8_t opc[16];
33 uint8_t k[16];
34 uint8_t amf[2];
35 uint64_t sqn;
36 } umts;
37 struct {
38 uint8_t ki[16];
39 } gsm;
Harald Welteaae23622011-12-07 11:35:02 +010040 } u;
Harald Welted82e0eb2011-12-06 21:53:42 +010041};
42
43/* data structure describing a computed auth vector, generated by AuC */
44struct osmo_auth_vector {
45 uint8_t rand[16];
46 uint8_t autn[16];
47 uint8_t ck[16];
48 uint8_t ik[16];
49 uint8_t res[16];
50 uint8_t res_len;
51 uint8_t kc[8];
52 uint8_t sres[4];
53 uint32_t auth_types; /*!< bitmask of OSMO_AUTH_TYPE_* */
54};
55
56/* \brief An implementation of an authentication algorithm */
57struct osmo_auth_impl {
58 struct llist_head list;
59 enum osmo_auth_algo algo;
60 const char *name;
61 unsigned int priority;
62
63 int (*gen_vec)(struct osmo_auth_vector *vec,
64 struct osmo_sub_auth_data *aud,
65 const uint8_t *_rand);
66
67 int (*gen_vec_auts)(struct osmo_auth_vector *vec,
68 struct osmo_sub_auth_data *aud,
69 const uint8_t *rand_auts, const uint8_t *auts,
70 const uint8_t *_rand);
71};
72
73int osmo_auth_gen_vec(struct osmo_auth_vector *vec,
74 struct osmo_sub_auth_data *aud, const uint8_t *_rand);
75
76int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec,
77 struct osmo_sub_auth_data *aud,
78 const uint8_t *rand_auts, const uint8_t *auts,
79 const uint8_t *_rand);
80
81int osmo_auth_register(struct osmo_auth_impl *impl);
82
83int osmo_auth_load(const char *path);
84
85int osmo_auth_supported(enum osmo_auth_algo algo);
86
Harald Weltea5ab1622011-12-07 02:33:11 +010087const char *osmo_auth_alg_name(enum osmo_auth_algo alg);
88enum osmo_auth_algo osmo_auth_alg_parse(const char *name);
89
Harald Welted82e0eb2011-12-06 21:53:42 +010090#endif /* _OSMOCRYPTO_AUTH_H */