libosmogsm  1.6.0.113-b17c
Osmocom GSM library
auth.h
Go to the documentation of this file.
1 #pragma once
2 
7 #include <stdint.h>
8 
10 #include <osmocom/core/utils.h>
11 
12 #define OSMO_A5_MAX_KEY_LEN_BYTES (128/8)
13 #define OSMO_MILENAGE_IND_BITLEN_MAX 28
14 
20 };
21 
22 extern const struct value_string osmo_sub_auth_type_names[];
23 static inline const char *osmo_sub_auth_type_name(enum osmo_sub_auth_type val)
25 
36 };
37 
41  enum osmo_auth_algo algo;
42  union {
43  struct {
44  uint8_t opc[16];
46  uint8_t amf[2];
47  uint64_t sqn;
48  int opc_is_op;
49  unsigned int ind_bitlen;
50  unsigned int ind;
51  uint64_t sqn_ms;
52  } umts;
53  struct {
55  } gsm;
56  } u;
57 };
58 
59 /* data structure describing a computed auth vector, generated by AuC */
61  uint8_t rand[16];
62  uint8_t autn[16];
65  uint8_t res[16];
66  uint8_t res_len;
67  uint8_t kc[8];
68  uint8_t sres[4];
69  uint32_t auth_types;
70 };
71 
72 /* An implementation of an authentication algorithm */
74  struct llist_head list;
75  enum osmo_auth_algo algo;
76  const char *name;
77  unsigned int priority;
80  int (*gen_vec)(struct osmo_auth_vector *vec,
81  struct osmo_sub_auth_data *aud,
82  const uint8_t *_rand);
83 
84  /* callback for generationg auth vectors + re-sync */
85  int (*gen_vec_auts)(struct osmo_auth_vector *vec,
86  struct osmo_sub_auth_data *aud,
87  const uint8_t *auts, const uint8_t *rand_auts,
88  const uint8_t *_rand);
89 };
90 
91 int osmo_auth_gen_vec(struct osmo_auth_vector *vec,
92  struct osmo_sub_auth_data *aud, const uint8_t *_rand);
93 
95  struct osmo_sub_auth_data *aud,
96  const uint8_t *auts, const uint8_t *rand_auts,
97  const uint8_t *_rand);
98 
99 int osmo_auth_register(struct osmo_auth_impl *impl);
100 
101 int osmo_auth_load(const char *path);
102 
104 void osmo_c4(uint8_t *ck, const uint8_t *kc);
105 const char *osmo_auth_alg_name(enum osmo_auth_algo alg);
106 enum osmo_auth_algo osmo_auth_alg_parse(const char *name);
107 
108 void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]);
109 
110 /* @} */
osmo_auth_supported
int osmo_auth_supported(enum osmo_auth_algo algo)
Determine if a given authentication algorithm is supported.
Definition: auth_core.c:86
osmo_auth_register
int osmo_auth_register(struct osmo_auth_impl *impl)
Register an authentication algorithm implementation with the core.
Definition: auth_core.c:48
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
osmo_sub_auth_data::@111::@112::ind
unsigned int ind
which IND slot to use an SQN from
Definition: auth.h:50
OSMO_AUTH_ALG_COMP128v1
@ OSMO_AUTH_ALG_COMP128v1
Definition: auth.h:30
osmo_auth_vector::kc
uint8_t kc[8]
Kc for GSM encryption (A5)
Definition: auth.h:67
osmo_auth_vector::auth_types
uint32_t auth_types
bitmask of OSMO_AUTH_TYPE_*
Definition: auth.h:69
osmo_auth_vector::sres
uint8_t sres[4]
authentication result for GSM
Definition: auth.h:68
utils.h
osmo_auth_algo
osmo_auth_algo
Authentication Algorithm.
Definition: auth.h:28
osmo_auth_load
int osmo_auth_load(const char *path)
Load all available authentication plugins from the given path.
Definition: auth_core.c:69
osmo_c4
void osmo_c4(uint8_t *ck, const uint8_t *kc)
Definition: auth_core.c:110
osmo_auth_impl::algo
enum osmo_auth_algo algo
algorithm we implement
Definition: auth.h:75
osmo_sub_auth_data::@111::@112::ind_bitlen
unsigned int ind_bitlen
nr of bits not in SEQ, only SQN
Definition: auth.h:49
osmo_auth_gen_vec_auts
int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand)
Generate authentication vector and re-sync sequence.
Definition: auth_core.c:186
osmo_sub_auth_data::u
union osmo_sub_auth_data::@111 u
osmo_auth_vector::res_len
uint8_t res_len
length (in bytes) of res
Definition: auth.h:66
osmo_auth_impl::name
const char * name
name of the implementation
Definition: auth.h:76
osmo_auth_impl
Definition: auth.h:73
OSMO_A5_MAX_KEY_LEN_BYTES
#define OSMO_A5_MAX_KEY_LEN_BYTES
Definition: auth.h:12
osmo_sub_auth_data::gsm
struct osmo_sub_auth_data::@111::@113 gsm
OSMO_AUTH_TYPE_GSM
@ OSMO_AUTH_TYPE_GSM
Definition: auth.h:18
osmo_sub_auth_data::umts
struct osmo_sub_auth_data::@111::@112 umts
osmo_sub_auth_data::ki
uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]
secret key
Definition: auth.h:54
OSMO_AUTH_ALG_XOR
@ OSMO_AUTH_ALG_XOR
Definition: auth.h:33
osmo_auth_vector::autn
uint8_t autn[16]
authentication nonce
Definition: auth.h:62
osmo_sub_auth_data::@111::@112::sqn_ms
uint64_t sqn_ms
sqn from AUTS (output value only)
Definition: auth.h:51
osmo_auth_vector::res
uint8_t res[16]
authentication result
Definition: auth.h:65
osmo_sub_auth_type_names
const struct value_string osmo_sub_auth_type_names[]
Definition: auth_core.c:228
osmo_sub_auth_data::@111::@112::sqn
uint64_t sqn
sequence number (in: prev sqn; out: used sqn)
Definition: auth.h:47
osmo_auth_c3
void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[])
Definition: auth_core.c:241
osmo_auth_vector::ik
uint8_t ik[OSMO_A5_MAX_KEY_LEN_BYTES]
integrity key
Definition: auth.h:64
osmo_auth_vector
Definition: auth.h:60
OSMO_AUTH_ALG_COMP128v2
@ OSMO_AUTH_ALG_COMP128v2
Definition: auth.h:31
osmo_auth_alg_name
const char * osmo_auth_alg_name(enum osmo_auth_algo alg)
Get human-readable name of authentication algorithm.
Definition: auth_core.c:217
osmo_auth_vector::rand
uint8_t rand[16]
random challenge
Definition: auth.h:61
osmo_auth_gen_vec
int osmo_auth_gen_vec(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand)
Generate authentication vector.
Definition: auth_core.c:152
osmo_sub_auth_data::opc
uint8_t opc[16]
operator invariant value
Definition: auth.h:44
osmo_sub_auth_data::amf
uint8_t amf[2]
Definition: auth.h:46
osmo_sub_auth_data::@111::@112::opc_is_op
int opc_is_op
is the OPC field OPC (0) or OP (1) ?
Definition: auth.h:48
name
const char * name
osmo_sub_auth_type_name
static const char * osmo_sub_auth_type_name(enum osmo_sub_auth_type val)
Definition: auth.h:23
llist_head
osmo_auth_impl::gen_vec_auts
int(* gen_vec_auts)(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand)
Definition: auth.h:85
OSMO_AUTH_TYPE_NONE
@ OSMO_AUTH_TYPE_NONE
Definition: auth.h:17
_OSMO_AUTH_ALG_NUM
@ _OSMO_AUTH_ALG_NUM
Definition: auth.h:35
value_string
linuxlist.h
osmo_sub_auth_data::type
enum osmo_sub_auth_type type
Definition: auth.h:40
osmo_auth_vector::ck
uint8_t ck[OSMO_A5_MAX_KEY_LEN_BYTES]
ciphering key
Definition: auth.h:63
osmo_auth_impl::gen_vec
int(* gen_vec)(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand)
callback for generate authentication vectors
Definition: auth.h:80
osmo_sub_auth_type
osmo_sub_auth_type
Authentication Type (GSM/UMTS)
Definition: auth.h:16
OSMO_AUTH_ALG_MILENAGE
@ OSMO_AUTH_ALG_MILENAGE
Definition: auth.h:34
OSMO_AUTH_ALG_NONE
@ OSMO_AUTH_ALG_NONE
Definition: auth.h:29
osmo_sub_auth_data::k
uint8_t k[OSMO_A5_MAX_KEY_LEN_BYTES]
secret key of the subscriber
Definition: auth.h:45
osmo_auth_impl::list
struct llist_head list
Definition: auth.h:74
osmo_auth_impl::priority
unsigned int priority
priority value (resp.
Definition: auth.h:77
OSMO_AUTH_ALG_COMP128v3
@ OSMO_AUTH_ALG_COMP128v3
Definition: auth.h:32
osmo_sub_auth_data::algo
enum osmo_auth_algo algo
Definition: auth.h:41
OSMO_AUTH_TYPE_UMTS
@ OSMO_AUTH_TYPE_UMTS
Definition: auth.h:19
osmo_sub_auth_data
permanent (secret) subscriber auth data
Definition: auth.h:39
osmo_auth_alg_parse
enum osmo_auth_algo osmo_auth_alg_parse(const char *name)
Parse human-readable name of authentication algorithm.
Definition: auth_core.c:223