libosmogsm 1.13.1.1-afb4 Osmocom GSM library

Macros | Functions | Variables
tuak.c File Reference
`#include <stdint.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <osmocom/core/utils.h>`
`#include "KeccakP-1600-3gpp.h"`

## Macros
#define | PUSH_DATA(buf, idx, input, nbytes)

## Functions
void | tuak_set_keccak_iterations (unsigned int i)
void | memcpy_reverse (uint8_t *dst, const uint8_t *src, size_t len)
static void | tuak_core (uint8_t buf[200], const uint8_t *opc, uint8_t instance, const uint8_t *_rand, const uint8_t *amf, const uint8_t *sqn, const uint8_t *k, uint8_t k_len_bytes, unsigned int keccac_iterations)
int | tuak_f1 (const uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *_rand, const uint8_t *sqn, const uint8_t *amf, uint8_t *mac_a, uint8_t mac_a_len_bytes, unsigned int keccac_iterations)
| tuak_f1 - TUAK f1 algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128-bit or 256-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_a: Buffer for MAC-A = 64/128/256-bit network authentication code Returns: 0 on success, -1 on failure More...
int | tuak_f1star (const uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *_rand, const uint8_t *sqn, const uint8_t *amf, uint8_t *mac_s, uint8_t mac_s_len_bytes, unsigned int keccac_iterations)
| tuak_f1star - TUAK f1* algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128-bit or 256-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_s: Buffer for MAC-S = 64/128/256-bit resync authentication code Returns: 0 on success, -1 on failure More...
int | tuak_f2345 (const uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *_rand, uint8_t *res, uint8_t res_len_bytes, uint8_t *ck, uint8_t ck_len_bytes, uint8_t *ik, uint8_t ik_len_bytes, uint8_t *ak, unsigned int keccac_iterations)
| tuak_f2345 - TUAK f2, f3, f4, f5, algorithms @opc: OPc = 256-bit value derived from OP and K @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @res: Buffer for RES = 32/64/128/256-bit signed response (f2), or NULL @ck: Buffer for CK = 128/256-bit confidentiality key (f3), or NULL @ik: Buffer for IK = 128/256-bit integrity key (f4), or NULL @ak: Buffer for AK = 48-bit anonymity key (f5), or NULL Returns: 0 on success, -1 on failure More...
int | tuak_f5star (const uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *_rand, uint8_t *ak, unsigned int keccac_iterations)
| tuak_f5star - TUAK f5* algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @ak: Buffer for AK = 48-bit anonymity key (f5) Returns: 0 on success, -1 on failure More...
void | tuak_generate (const uint8_t *opc, const uint8_t *amf, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *sqn, const uint8_t *_rand, uint8_t *autn, uint8_t *ik, uint8_t *ck, uint8_t *res, size_t *res_len)
| tuak_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 256-bit operator variant algorithm configuration field (encr.) @amf: AMF = 16-bit authentication management field @k: K = 128/256-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: Buffer for AUTN = 128-bit authentication token @ik: Buffer for IK = 128/256-bit integrity key (f4), or NULL @ck: Buffer for CK = 128/256-bit confidentiality key (f3), or NULL @res: Buffer for RES = 32/64/128-bit signed response (f2), or NULL @res_len: Max length for res; set to used length or 0 on failure More...
int | tuak_auts (const uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *_rand, const uint8_t *auts, uint8_t *sqn)
| tuak_auts - Milenage AUTS validation @opc: OPc = 256-bit operator variant algorithm configuration field (encr.) @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @auts: AUTS = 112-bit authentication token from client @sqn: Buffer for SQN = 48-bit sequence number Returns: 0 = success (sqn filled), -1 on failure More...
int | tuak_opc_gen (uint8_t *opc, const uint8_t *k, uint8_t k_len_bytes, const uint8_t *op)

## Variables
static unsigned int | g_keccak_iterations = 1
static const char | algoname [] = "TUAK1.0"
const uint8_t | zero16 [16] = { 0, }

## Macro Definition Documentation

## ◆ PUSH_DATA

#define PUSH_DATA | ( |  | buf,
|  |  | idx,
|  |  | input,
|  |  | nbytes
| ) |  |

Value:
for (int i = nbytes-1; i >= 0; i--) { \
buf[idx++] = input[i]; \
}

## Function Documentation

## ◆ memcpy_reverse()

void memcpy_reverse | ( | uint8_t * | dst,
|  | const uint8_t * | src,
|  | size_t | len
| ) |  |

References len.

Referenced by tuak_f1(), tuak_f1star(), tuak_f2345(), tuak_f5star(), and tuak_opc_gen().

## ◆ tuak_auts()

int tuak_auts | ( | const uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | _rand,
|  | const uint8_t * | auts,
|  | uint8_t * | sqn
| ) |  |

tuak_auts - Milenage AUTS validation @opc: OPc = 256-bit operator variant algorithm configuration field (encr.) @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @auts: AUTS = 112-bit authentication token from client @sqn: Buffer for SQN = 48-bit sequence number Returns: 0 = success (sqn filled), -1 on failure

References g_keccak_iterations, tuak_f1star(), and tuak_f5star().

Referenced by tuak_gen_vec_auts().

## ◆ tuak_core()

static void tuak_core | ( | uint8_t | buf[200],
|  | const uint8_t * | opc,
|  | uint8_t | instance,
|  | const uint8_t * | _rand,
|  | const uint8_t * | amf,
|  | const uint8_t * | sqn,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | unsigned int | keccac_iterations
| ) |  |
| static

References algoname, Keccak_f_64(), OSMO_ASSERT, and PUSH_DATA.

Referenced by tuak_f1(), tuak_f1star(), tuak_f2345(), tuak_f5star(), and tuak_opc_gen().

## ◆ tuak_f1()

int tuak_f1 | ( | const uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | _rand,
|  | const uint8_t * | sqn,
|  | const uint8_t * | amf,
|  | uint8_t * | mac_a,
|  | uint8_t | mac_a_len_bytes,
|  | unsigned int | keccac_iterations
| ) |  |

tuak_f1 - TUAK f1 algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128-bit or 256-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_a: Buffer for MAC-A = 64/128/256-bit network authentication code Returns: 0 on success, -1 on failure

References memcpy_reverse(), and tuak_core().

Referenced by tuak_generate().

## ◆ tuak_f1star()

int tuak_f1star | ( | const uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | _rand,
|  | const uint8_t * | sqn,
|  | const uint8_t * | amf,
|  | uint8_t * | mac_s,
|  | uint8_t | mac_s_len_bytes,
|  | unsigned int | keccac_iterations
| ) |  |

tuak_f1star - TUAK f1* algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128-bit or 256-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_s: Buffer for MAC-S = 64/128/256-bit resync authentication code Returns: 0 on success, -1 on failure

References memcpy_reverse(), and tuak_core().

Referenced by tuak_auts().

## ◆ tuak_f2345()

int tuak_f2345 | ( | const uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | _rand,
|  | uint8_t * | res,
|  | uint8_t | res_len_bytes,
|  | uint8_t * | ck,
|  | uint8_t | ck_len_bytes,
|  | uint8_t * | ik,
|  | uint8_t | ik_len_bytes,
|  | uint8_t * | ak,
|  | unsigned int | keccac_iterations
| ) |  |

tuak_f2345 - TUAK f2, f3, f4, f5, algorithms @opc: OPc = 256-bit value derived from OP and K @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @res: Buffer for RES = 32/64/128/256-bit signed response (f2), or NULL @ck: Buffer for CK = 128/256-bit confidentiality key (f3), or NULL @ik: Buffer for IK = 128/256-bit integrity key (f4), or NULL @ak: Buffer for AK = 48-bit anonymity key (f5), or NULL Returns: 0 on success, -1 on failure

References memcpy_reverse(), res, tuak_core(), and zero16.

Referenced by tuak_generate().

## ◆ tuak_f5star()

int tuak_f5star | ( | const uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | _rand,
|  | uint8_t * | ak,
|  | unsigned int | keccac_iterations
| ) |  |

tuak_f5star - TUAK f5* algorithm @opc: OPc = 256-bit value derived from OP and K @k: K = 128/256-bit subscriber key @_rand: RAND = 128-bit random challenge @ak: Buffer for AK = 48-bit anonymity key (f5) Returns: 0 on success, -1 on failure

References memcpy_reverse(), tuak_core(), and zero16.

Referenced by tuak_auts().

## ◆ tuak_generate()

void tuak_generate | ( | const uint8_t * | opc,
|  | const uint8_t * | amf,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | sqn,
|  | const uint8_t * | _rand,
|  | uint8_t * | autn,
|  | uint8_t * | ik,
|  | uint8_t * | ck,
|  | uint8_t * | res,
|  | size_t * | res_len
| ) |  |

tuak_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 256-bit operator variant algorithm configuration field (encr.) @amf: AMF = 16-bit authentication management field @k: K = 128/256-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: Buffer for AUTN = 128-bit authentication token @ik: Buffer for IK = 128/256-bit integrity key (f4), or NULL @ck: Buffer for CK = 128/256-bit confidentiality key (f3), or NULL @res: Buffer for RES = 32/64/128-bit signed response (f2), or NULL @res_len: Max length for res; set to used length or 0 on failure

References g_keccak_iterations, res, tuak_f1(), and tuak_f2345().

Referenced by tuak_gen_vec().

## ◆ tuak_opc_gen()

int tuak_opc_gen | ( | uint8_t * | opc,
|  | const uint8_t * | k,
|  | uint8_t | k_len_bytes,
|  | const uint8_t * | op
| ) |  |

References g_keccak_iterations, memcpy_reverse(), tuak_core(), and zero16.

Referenced by gen_opc_if_needed().

## ◆ tuak_set_keccak_iterations()

void tuak_set_keccak_iterations | ( | unsigned int | i | ) |

References g_keccak_iterations.

## Variable Documentation

## ◆ algoname

const char algoname[] = "TUAK1.0"
| static

Referenced by tuak_core().

## ◆ g_keccak_iterations

unsigned int g_keccak_iterations = 1
| static

Referenced by tuak_auts(), tuak_generate(), tuak_opc_gen(), and tuak_set_keccak_iterations().

## ◆ zero16

const uint8_t zero16[16] = { 0, }

Referenced by tuak_f2345(), tuak_f5star(), and tuak_opc_gen().