libosmogsm  1.8.0.79-b394d
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 
37 };
38 /* Backwards-compatibility. We used to call XOR-3G just "XOR" which became ambiguous when
39  * we started to add XOR-2G support. */
40 #define OSMO_AUTH_ALG_XOR OSMO_AUTH_ALG_XOR_3G
41 
45  enum osmo_auth_algo algo;
46  union {
47  struct {
48  uint8_t opc[16];
50  uint8_t amf[2];
51  uint64_t sqn;
52  int opc_is_op;
53  unsigned int ind_bitlen;
54  unsigned int ind;
55  uint64_t sqn_ms;
56  } umts;
57  struct {
59  } gsm;
60  } u;
61 };
62 
63 /* data structure describing a computed auth vector, generated by AuC */
65  uint8_t rand[16];
66  uint8_t autn[16];
69  uint8_t res[16];
70  uint8_t res_len;
71  uint8_t kc[8];
72  uint8_t sres[4];
73  uint32_t auth_types;
74 };
75 
76 /* An implementation of an authentication algorithm */
78  struct llist_head list;
79  enum osmo_auth_algo algo;
80  const char *name;
81  unsigned int priority;
84  int (*gen_vec)(struct osmo_auth_vector *vec,
85  struct osmo_sub_auth_data *aud,
86  const uint8_t *_rand);
87 
88  /* callback for generationg auth vectors + re-sync */
89  int (*gen_vec_auts)(struct osmo_auth_vector *vec,
90  struct osmo_sub_auth_data *aud,
91  const uint8_t *auts, const uint8_t *rand_auts,
92  const uint8_t *_rand);
93 };
94 
95 int osmo_auth_gen_vec(struct osmo_auth_vector *vec,
96  struct osmo_sub_auth_data *aud, const uint8_t *_rand);
97 
99  struct osmo_sub_auth_data *aud,
100  const uint8_t *auts, const uint8_t *rand_auts,
101  const uint8_t *_rand);
102 
103 int osmo_auth_register(struct osmo_auth_impl *impl);
104 
105 int osmo_auth_load(const char *path);
106 
108 void osmo_c4(uint8_t *ck, const uint8_t *kc);
109 const char *osmo_auth_alg_name(enum osmo_auth_algo alg);
110 enum osmo_auth_algo osmo_auth_alg_parse(const char *name);
111 
112 void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]);
113 
114 /* @} */
enum osmo_auth_algo algo
algorithm we implement
Definition: auth.h:79
int osmo_auth_register(struct osmo_auth_impl *impl)
Register an authentication algorithm implementation with the core.
Definition: auth_core.c:48
int osmo_auth_supported(enum osmo_auth_algo algo)
Determine if a given authentication algorithm is supported.
Definition: auth_core.c:86
struct llist_head list
Definition: auth.h:78
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
union osmo_sub_auth_data::@108 u
uint8_t amf[2]
Definition: auth.h:50
enum osmo_auth_algo osmo_auth_alg_parse(const char *name)
Parse human-readable name of authentication algorithm.
Definition: auth_core.c:224
void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[])
Definition: auth_core.c:242
unsigned int priority
priority value (resp.
Definition: auth.h:81
uint8_t opc[16]
operator invariant value
Definition: auth.h:48
osmo_auth_algo
Authentication Algorithm.
Definition: auth.h:28
static const char * osmo_sub_auth_type_name(enum osmo_sub_auth_type val)
Definition: auth.h:23
unsigned int ind
which IND slot to use an SQN from
Definition: auth.h:54
uint8_t kc[8]
Kc for GSM encryption (A5)
Definition: auth.h:71
int opc_is_op
is the OPC field OPC (0) or OP (1) ?
Definition: auth.h:52
int osmo_auth_load(const char *path)
Load all available authentication plugins from the given path.
Definition: auth_core.c:69
uint64_t sqn
sequence number (in: prev sqn; out: used sqn)
Definition: auth.h:51
enum osmo_sub_auth_type type
Definition: auth.h:44
#define OSMO_A5_MAX_KEY_LEN_BYTES
Definition: auth.h:12
const char * name
name of the implementation
Definition: auth.h:80
const struct value_string osmo_sub_auth_type_names[]
Definition: auth_core.c:229
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:84
const char * osmo_auth_alg_name(enum osmo_auth_algo alg)
Get human-readable name of authentication algorithm.
Definition: auth_core.c:218
uint8_t sres[4]
authentication result for GSM
Definition: auth.h:72
uint8_t res[16]
authentication result
Definition: auth.h:69
void osmo_c4(uint8_t *ck, const uint8_t *kc)
Definition: auth_core.c:110
osmo_sub_auth_type
Authentication Type (GSM/UMTS)
Definition: auth.h:16
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
uint8_t ik[OSMO_A5_MAX_KEY_LEN_BYTES]
integrity key
Definition: auth.h:68
uint8_t res_len
length (in bytes) of res
Definition: auth.h:70
uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]
secret key
Definition: auth.h:58
uint64_t sqn_ms
sqn from AUTS (output value only)
Definition: auth.h:55
struct osmo_sub_auth_data::@108::@109 umts
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:89
uint8_t k[OSMO_A5_MAX_KEY_LEN_BYTES]
secret key of the subscriber
Definition: auth.h:49
uint8_t rand[16]
random challenge
Definition: auth.h:65
unsigned int ind_bitlen
nr of bits not in SEQ, only SQN
Definition: auth.h:53
uint32_t auth_types
bitmask of OSMO_AUTH_TYPE_*
Definition: auth.h:73
uint8_t ck[OSMO_A5_MAX_KEY_LEN_BYTES]
ciphering key
Definition: auth.h:67
struct osmo_sub_auth_data::@108::@110 gsm
enum osmo_auth_algo algo
Definition: auth.h:45
uint8_t autn[16]
authentication nonce
Definition: auth.h:66
@ OSMO_AUTH_ALG_COMP128v2
Definition: auth.h:31
@ OSMO_AUTH_ALG_NONE
Definition: auth.h:29
@ OSMO_AUTH_ALG_COMP128v1
Definition: auth.h:30
@ OSMO_AUTH_ALG_XOR_3G
Definition: auth.h:33
@ OSMO_AUTH_ALG_COMP128v3
Definition: auth.h:32
@ OSMO_AUTH_ALG_XOR_2G
Definition: auth.h:35
@ _OSMO_AUTH_ALG_NUM
Definition: auth.h:36
@ OSMO_AUTH_ALG_MILENAGE
Definition: auth.h:34
@ OSMO_AUTH_TYPE_UMTS
Definition: auth.h:19
@ OSMO_AUTH_TYPE_GSM
Definition: auth.h:18
@ OSMO_AUTH_TYPE_NONE
Definition: auth.h:17
const char * name
const char * get_value_string(const struct value_string *vs, uint32_t val)
Definition: auth.h:77
Definition: auth.h:64
permanent (secret) subscriber auth data
Definition: auth.h:43