libosmogsm
0.6.3
Osmocom GSM library
|
Files | |
file | a5.h |
Osmocom GSM A5 ciphering algorithm header. | |
file | a5.c |
Osmocom GSM A5 ciphering algorithm implementation. |
Functions | |
static uint32_t | osmo_a5_fn_count (uint32_t fn) |
Converts a frame number into the 22 bit number used in A5/x. | |
int | osmo_a5 (int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) |
Main method to generate a A5/x cipher stream. | |
void | osmo_a5_1 (const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) |
Generate a GSM A5/1 cipher stream. | |
void | osmo_a5_2 (const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) |
Generate a GSM A5/1 cipher stream. | |
static uint32_t | _a5_12_parity (uint32_t x) |
Computes parity of a 32-bit word. | |
static uint32_t | _a5_12_majority (uint32_t v1, uint32_t v2, uint32_t v3) |
Compute majority bit from 3 taps. | |
static uint32_t | _a5_12_clock (uint32_t r, uint32_t mask, uint32_t taps) |
Compute the next LFSR state. | |
static void | _a5_1_clock (uint32_t r[], int force) |
GSM A5/1 Clocking function. | |
static uint8_t | _a5_1_get_output (uint32_t r[]) |
GSM A5/1 Output function. | |
static void | _a5_2_clock (uint32_t r[], int force) |
GSM A5/2 Clocking function. | |
static uint8_t | _a5_2_get_output (uint32_t r[]) |
GSM A5/2 Output function. |
|
inlinestatic |
Compute the next LFSR state.
[in] | r | Current state |
[in] | mask | LFSR mask |
[in] | taps | LFSR taps |
References _a5_12_parity().
Referenced by _a5_1_clock(), and _a5_2_clock().
|
inlinestatic |
Compute majority bit from 3 taps.
[in] | v1 | LFSR state ANDed with tap-bit |
[in] | v2 | LFSR state ANDed with tap-bit |
[in] | v3 | LFSR state ANDed with tap-bit |
Referenced by _a5_1_clock(), and _a5_2_get_output().
|
inlinestatic |
Computes parity of a 32-bit word.
[in] | x | 32 bit word |
Referenced by _a5_12_clock().
|
inlinestatic |
GSM A5/1 Clocking function.
[in] | r | Register state |
[in] | force | Non-zero value disable conditional clocking |
References _a5_12_clock(), and _a5_12_majority().
Referenced by osmo_a5_1().
|
inlinestatic |
GSM A5/1 Output function.
[in] | r | Register state |
Referenced by osmo_a5_1().
|
inlinestatic |
GSM A5/2 Clocking function.
[in] | r | Register state |
[in] | force | Non-zero value disable conditional clocking |
References _a5_12_clock().
Referenced by osmo_a5_2().
|
inlinestatic |
GSM A5/2 Output function.
[in] | r | Register state |
References _a5_12_majority().
Referenced by osmo_a5_2().
int osmo_a5 | ( | int | n, |
const uint8_t * | key, | ||
uint32_t | fn, | ||
ubit_t * | dl, | ||
ubit_t * | ul | ||
) |
Main method to generate a A5/x cipher stream.
[in] | n | Which A5/x method to use |
[in] | key | 8 byte array for the key (as received from the SIM) |
[in] | fn | Frame number |
[out] | dl | Pointer to array of ubits to return Downlink cipher stream |
[out] | ul | Pointer to array of ubits to return Uplink cipher stream |
Currently A5/[0-2] are supported. Either (or both) of dl/ul can be NULL if not needed.
References osmo_a5_1(), and osmo_a5_2().
void osmo_a5_1 | ( | const uint8_t * | key, |
uint32_t | fn, | ||
ubit_t * | dl, | ||
ubit_t * | ul | ||
) |
Generate a GSM A5/1 cipher stream.
[in] | key | 8 byte array for the key (as received from the SIM) |
[in] | fn | Frame number |
[out] | dl | Pointer to array of ubits to return Downlink cipher stream |
[out] | ul | Pointer to array of ubits to return Uplink cipher stream |
Either (or both) of dl/ul can be NULL if not needed.
References _a5_1_clock(), _a5_1_get_output(), and osmo_a5_fn_count().
Referenced by osmo_a5().
void osmo_a5_2 | ( | const uint8_t * | key, |
uint32_t | fn, | ||
ubit_t * | dl, | ||
ubit_t * | ul | ||
) |
Generate a GSM A5/1 cipher stream.
[in] | key | 8 byte array for the key (as received from the SIM) |
[in] | fn | Frame number |
[out] | dl | Pointer to array of ubits to return Downlink cipher stream |
[out] | ul | Pointer to array of ubits to return Uplink cipher stream |
Either (or both) of dl/ul can be NULL if not needed.
References _a5_2_clock(), _a5_2_get_output(), and osmo_a5_fn_count().
Referenced by osmo_a5().
|
inlinestatic |
Converts a frame number into the 22 bit number used in A5/x.
[in] | fn | The true framenumber |
Referenced by osmo_a5_1(), and osmo_a5_2().