GNU Radio's GSM Package
auth.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*! \defgroup auth GSM/GPRS/3G Authentication
4  * @{
5  * \file auth.h */
6 
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 
15 /*! Authentication Type (GSM/UMTS) */
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)
24 { return get_value_string(osmo_sub_auth_type_names, val); }
25 */
26 
27 /*! Authentication Algorithm.
28  * See also osmo_auth_alg_name() and osmo_auth_alg_parse(). */
37 };
38 
39 /*! permanent (secret) subscriber auth data */
42  enum osmo_auth_algo algo;
43  union {
44  struct {
45  uint8_t opc[16]; /*!< operator invariant value */
46  uint8_t k[16]; /*!< secret key of the subscriber */
47  uint8_t amf[2];
48  uint64_t sqn; /*!< sequence number (in: prev sqn; out: used sqn) */
49  int opc_is_op; /*!< is the OPC field OPC (0) or OP (1) ? */
50  unsigned int ind_bitlen; /*!< nr of bits not in SEQ, only SQN */
51  unsigned int ind; /*!< which IND slot to use an SQN from */
52  uint64_t sqn_ms; /*!< sqn from AUTS (output value only) */
53  } umts;
54  struct {
55  uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< secret key */
56  } gsm;
57  } u;
58 };
59 
60 /* data structure describing a computed auth vector, generated by AuC */
62  uint8_t rand[16]; /*!< random challenge */
63  uint8_t autn[16]; /*!< authentication nonce */
64  uint8_t ck[16]; /*!< ciphering key */
65  uint8_t ik[16]; /*!< integrity key */
66  uint8_t res[16]; /*!< authentication result */
67  uint8_t res_len; /*!< length (in bytes) of res */
68  uint8_t kc[8]; /*!< Kc for GSM encryption (A5) */
69  uint8_t sres[4]; /*!< authentication result for GSM */
70  uint32_t auth_types; /*!< bitmask of OSMO_AUTH_TYPE_* */
71 };
72 
73 /* An implementation of an authentication algorithm */
75  struct llist_head list;
76  enum osmo_auth_algo algo; /*!< algorithm we implement */
77  const char *name; /*!< name of the implementation */
78  unsigned int priority; /*!< priority value (resp. othe implementations */
79 
80  /*! callback for generate authentication vectors */
81  int (*gen_vec)(struct osmo_auth_vector *vec,
82  struct osmo_sub_auth_data *aud,
83  const uint8_t *_rand);
84 
85  /* callback for generationg auth vectors + re-sync */
86  int (*gen_vec_auts)(struct osmo_auth_vector *vec,
87  struct osmo_sub_auth_data *aud,
88  const uint8_t *auts, const uint8_t *rand_auts,
89  const uint8_t *_rand);
90 };
91 
93  struct osmo_sub_auth_data *aud, const uint8_t *_rand);
94 
96  struct osmo_sub_auth_data *aud,
97  const uint8_t *auts, const uint8_t *rand_auts,
98  const uint8_t *_rand);
99 
101 
102 int osmo_auth_load(const char *path);
103 
105 void osmo_c4(uint8_t *ck, const uint8_t *kc);
106 const char *osmo_auth_alg_name(enum osmo_auth_algo alg);
107 //enum osmo_auth_algo osmo_auth_alg_parse(const char *name);
108 
109 void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]);
110 
111 /* @} */
osmo_sub_auth_data::umts
struct osmo_sub_auth_data::@0::@1 umts
osmo_auth_supported
int osmo_auth_supported(enum osmo_auth_algo algo)
osmo_auth_register
int osmo_auth_register(struct osmo_auth_impl *impl)
OSMO_AUTH_ALG_COMP128v1
@ OSMO_AUTH_ALG_COMP128v1
Definition: auth.h:31
osmo_auth_vector::kc
uint8_t kc[8]
Definition: auth.h:68
osmo_auth_vector::auth_types
uint32_t auth_types
Definition: auth.h:70
osmo_auth_vector::sres
uint8_t sres[4]
Definition: auth.h:69
osmo_auth_algo
osmo_auth_algo
Definition: auth.h:29
osmo_auth_load
int osmo_auth_load(const char *path)
osmo_sub_auth_data::k
uint8_t k[16]
Definition: auth.h:46
osmo_sub_auth_data::@0::@1::opc_is_op
int opc_is_op
Definition: auth.h:49
osmo_c4
void osmo_c4(uint8_t *ck, const uint8_t *kc)
osmo_auth_impl::algo
enum osmo_auth_algo algo
Definition: auth.h:76
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)
osmo_auth_vector::res_len
uint8_t res_len
Definition: auth.h:67
osmo_auth_impl::name
const char * name
Definition: auth.h:77
osmo_auth_impl
Definition: auth.h:74
osmo_sub_auth_data::gsm
struct osmo_sub_auth_data::@0::@2 gsm
OSMO_A5_MAX_KEY_LEN_BYTES
#define OSMO_A5_MAX_KEY_LEN_BYTES
Definition: auth.h:12
OSMO_AUTH_TYPE_GSM
@ OSMO_AUTH_TYPE_GSM
Definition: auth.h:18
osmo_sub_auth_data::ki
uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]
Definition: auth.h:55
OSMO_AUTH_ALG_XOR
@ OSMO_AUTH_ALG_XOR
Definition: auth.h:34
osmo_auth_vector::autn
uint8_t autn[16]
Definition: auth.h:63
osmo_sub_auth_data::@0::@1::sqn_ms
uint64_t sqn_ms
Definition: auth.h:52
osmo_auth_vector::res
uint8_t res[16]
Definition: auth.h:66
utils.h
osmo_sub_auth_type_names
const struct value_string osmo_sub_auth_type_names[]
osmo_auth_c3
void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[])
osmo_auth_vector::ik
uint8_t ik[16]
Definition: auth.h:65
osmo_auth_vector
Definition: auth.h:61
OSMO_AUTH_ALG_COMP128v2
@ OSMO_AUTH_ALG_COMP128v2
Definition: auth.h:32
osmo_auth_vector::rand
uint8_t rand[16]
Definition: auth.h:62
osmo_auth_gen_vec
int osmo_auth_gen_vec(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand)
osmo_sub_auth_data::opc
uint8_t opc[16]
Definition: auth.h:45
osmo_sub_auth_data::amf
uint8_t amf[2]
Definition: auth.h:47
llist_head
Definition: linuxlist.h:54
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:86
OSMO_AUTH_TYPE_NONE
@ OSMO_AUTH_TYPE_NONE
Definition: auth.h:17
_OSMO_AUTH_ALG_NUM
@ _OSMO_AUTH_ALG_NUM
Definition: auth.h:36
value_string
Definition: utils.h:43
osmo_sub_auth_data::type
enum osmo_sub_auth_type type
Definition: auth.h:41
osmo_auth_impl::gen_vec
int(* gen_vec)(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand)
Definition: auth.h:81
osmo_sub_auth_data::@0::@1::ind
unsigned int ind
Definition: auth.h:51
osmo_sub_auth_data::@0::@1::ind_bitlen
unsigned int ind_bitlen
Definition: auth.h:50
osmo_sub_auth_type
osmo_sub_auth_type
Definition: auth.h:16
OSMO_AUTH_ALG_MILENAGE
@ OSMO_AUTH_ALG_MILENAGE
Definition: auth.h:35
OSMO_AUTH_ALG_NONE
@ OSMO_AUTH_ALG_NONE
Definition: auth.h:30
osmo_sub_auth_data::@0::@1::sqn
uint64_t sqn
Definition: auth.h:48
osmo_auth_vector::ck
uint8_t ck[16]
Definition: auth.h:64
linuxlist.h
osmo_auth_impl::list
struct llist_head list
Definition: auth.h:75
osmo_auth_impl::priority
unsigned int priority
Definition: auth.h:78
OSMO_AUTH_ALG_COMP128v3
@ OSMO_AUTH_ALG_COMP128v3
Definition: auth.h:33
osmo_sub_auth_data::algo
enum osmo_auth_algo algo
Definition: auth.h:42
OSMO_AUTH_TYPE_UMTS
@ OSMO_AUTH_TYPE_UMTS
Definition: auth.h:19
osmo_sub_auth_data
Definition: auth.h:40
osmo_auth_alg_name
const char * osmo_auth_alg_name(enum osmo_auth_algo alg)
osmo_sub_auth_data::u
union osmo_sub_auth_data::@0 u