libosmogsm 1.13.1.1-afb4 Osmocom GSM library

a5.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
3 *
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#pragma once
18
19#include <stdint.h>
20
21#include <osmocom/core/defs.h>
22#include <osmocom/core/bits.h>
23
32 static inline uint32_t
33 osmo_a5_fn_count(uint32_t fn)
34{
35 int t1 = fn / (26 * 51);
36 int t2 = fn % 26;
37 int t3 = fn % 51;
38 return (t1 << 11) | (t3 << 5) | t2;
39}
40
41 /* Notes:
42 * - key must be 8 or 16 (for a5/4) bytes long (or NULL for A5/0)
43 * - the dl and ul pointer must be either NULL or 114 bits long
44 * - fn is the _real_ GSM frame number.
45 * (converted internally to fn_count)
46 */
47 int osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul);
48 void osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) OSMO_DEPRECATED("Use generic osmo_a5() instead");
49 void osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) OSMO_DEPRECATED("Use generic osmo_a5() instead");
50
bits.h
defs.h
osmo_a5_fn_count
static uint32_t osmo_a5_fn_count(uint32_t fn)
Converts a frame number into the 22 bit number used in A5/x.
Definition: a5.h:33
osmo_a5_2
void osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) OSMO_DEPRECATED("Use generic osmo_a5() instead")
Definition: a5.c:390
osmo_a5
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.
Definition: a5.c:407
osmo_a5_1
void osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) OSMO_DEPRECATED("Use generic osmo_a5() instead")
Definition: a5.c:262
ubit_t
uint8_t ubit_t
n
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write Write running configuration to or terminal n Write to terminal n
OSMO_DEPRECATED
#define OSMO_DEPRECATED(text)