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 */
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 
92 int osmo_auth_gen_vec(struct osmo_auth_vector *vec,
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 
100 int osmo_auth_register(struct osmo_auth_impl *impl);
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 /* @} */
const char * name
Definition: auth.h:77
enum osmo_sub_auth_type type
Definition: auth.h:41
void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[])
Definition: auth.h:31
Definition: auth.h:40
uint64_t sqn_ms
Definition: auth.h:52
#define OSMO_A5_MAX_KEY_LEN_BYTES
Definition: auth.h:12
Definition: utils.h:43
unsigned int ind_bitlen
Definition: auth.h:50
Definition: auth.h:34
struct osmo_sub_auth_data::@0::@1 umts
unsigned int priority
Definition: auth.h:78
Definition: auth.h:18
int osmo_auth_gen_vec(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand)
uint8_t res_len
Definition: auth.h:67
osmo_auth_algo
Definition: auth.h:29
void osmo_c4(uint8_t *ck, const uint8_t *kc)
uint8_t k[16]
Definition: auth.h:46
uint8_t opc[16]
Definition: auth.h:45
uint32_t auth_types
Definition: auth.h:70
unsigned int ind
Definition: auth.h:51
union osmo_sub_auth_data::@0 u
uint8_t rand[16]
Definition: gsm_04_08.h:51
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)
Definition: linuxlist.h:54
Definition: auth.h:17
uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]
Definition: auth.h:55
const char * osmo_auth_alg_name(enum osmo_auth_algo alg)
Definition: auth.h:74
Definition: auth.h:32
Definition: auth.h:35
int osmo_auth_load(const char *path)
uint8_t amf[2]
Definition: auth.h:47
Definition: auth.h:30
uint8_t sres[4]
Definition: gsm_04_08.h:49
Definition: auth.h:19
uint64_t sqn
Definition: auth.h:48
int opc_is_op
Definition: auth.h:49
Definition: auth.h:36
Definition: auth.h:33
struct osmo_sub_auth_data::@0::@2 gsm
enum osmo_auth_algo algo
Definition: auth.h:42
Definition: auth.h:61
osmo_sub_auth_type
Definition: auth.h:16
int osmo_auth_supported(enum osmo_auth_algo algo)
const struct value_string osmo_sub_auth_type_names[]
int osmo_auth_register(struct osmo_auth_impl *impl)