\doxysection{src/gsm/a5.c File Reference}
\label{a5_8c}\index{src/gsm/a5.c@{src/gsm/a5.c}}
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/a5.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/kasumi.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/crypt/auth.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ ENOTSUP}~EINVAL
\item 
\#define \textbf{ A5\+\_\+\+R1\+\_\+\+LEN}~19
\item 
\#define \textbf{ A5\+\_\+\+R2\+\_\+\+LEN}~22
\item 
\#define \textbf{ A5\+\_\+\+R3\+\_\+\+LEN}~23
\item 
\#define \textbf{ A5\+\_\+\+R4\+\_\+\+LEN}~17 /$\ast$ A5/2 only $\ast$/
\item 
\#define \textbf{ A5\+\_\+\+R1\+\_\+\+MASK}~((1$<$$<$\textbf{ A5\+\_\+\+R1\+\_\+\+LEN})-\/1)
\item 
\#define \textbf{ A5\+\_\+\+R2\+\_\+\+MASK}~((1$<$$<$\textbf{ A5\+\_\+\+R2\+\_\+\+LEN})-\/1)
\item 
\#define \textbf{ A5\+\_\+\+R3\+\_\+\+MASK}~((1$<$$<$\textbf{ A5\+\_\+\+R3\+\_\+\+LEN})-\/1)
\item 
\#define \textbf{ A5\+\_\+\+R4\+\_\+\+MASK}~((1$<$$<$\textbf{ A5\+\_\+\+R4\+\_\+\+LEN})-\/1)
\item 
\#define \textbf{ A5\+\_\+\+R1\+\_\+\+TAPS}~0x072000 /$\ast$ \textbf{ x}$^\wedge$19 + \textbf{ x}$^\wedge$18 + \textbf{ x}$^\wedge$17 + \textbf{ x}$^\wedge$14 + 1 $\ast$/
\item 
\#define \textbf{ A5\+\_\+\+R2\+\_\+\+TAPS}~0x300000 /$\ast$ \textbf{ x}$^\wedge$22 + \textbf{ x}$^\wedge$21 + 1 $\ast$/
\item 
\#define \textbf{ A5\+\_\+\+R3\+\_\+\+TAPS}~0x700080 /$\ast$ \textbf{ x}$^\wedge$23 + \textbf{ x}$^\wedge$22 + \textbf{ x}$^\wedge$21 + \textbf{ x}$^\wedge$8 + 1 $\ast$/
\item 
\#define \textbf{ A5\+\_\+\+R4\+\_\+\+TAPS}~0x010800 /$\ast$ \textbf{ x}$^\wedge$17 + \textbf{ x}$^\wedge$12 + 1 $\ast$/
\item 
\#define \textbf{ A51\+\_\+\+R1\+\_\+\+CLKBIT}~0x000100
\item 
\#define \textbf{ A51\+\_\+\+R2\+\_\+\+CLKBIT}~0x000400
\item 
\#define \textbf{ A51\+\_\+\+R3\+\_\+\+CLKBIT}~0x000400
\item 
\#define \textbf{ A52\+\_\+\+R4\+\_\+\+CLKBIT0}~0x000400
\item 
\#define \textbf{ A52\+\_\+\+R4\+\_\+\+CLKBIT1}~0x000008
\item 
\#define \textbf{ A52\+\_\+\+R4\+\_\+\+CLKBIT2}~0x000080
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ \+\_\+a5\+\_\+4} (const uint8\+\_\+t $\ast$ck, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul, bool fn\+\_\+correct)
\begin{DoxyCompactList}\small\item\em Generate a GSM A5/4 cipher stream. \end{DoxyCompactList}\item 
void \textbf{ \+\_\+a5\+\_\+3} (const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul, bool fn\+\_\+correct)
\begin{DoxyCompactList}\small\item\em Generate a GSM A5/3 cipher stream. \end{DoxyCompactList}\item 
static uint32\+\_\+t \textbf{ \+\_\+a5\+\_\+12\+\_\+parity} (uint32\+\_\+t \textbf{ x})
\begin{DoxyCompactList}\small\item\em Computes parity of a 32-\/bit word. \end{DoxyCompactList}\item 
static uint32\+\_\+t \textbf{ \+\_\+a5\+\_\+12\+\_\+majority} (uint32\+\_\+t v1, uint32\+\_\+t v2, uint32\+\_\+t v3)
\begin{DoxyCompactList}\small\item\em Compute majority bit from 3 taps. \end{DoxyCompactList}\item 
static uint32\+\_\+t \textbf{ \+\_\+a5\+\_\+12\+\_\+clock} (uint32\+\_\+t r, uint32\+\_\+t mask, uint32\+\_\+t taps)
\begin{DoxyCompactList}\small\item\em Compute the next LFSR state. \end{DoxyCompactList}\item 
static void \textbf{ \+\_\+a5\+\_\+1\+\_\+clock} (uint32\+\_\+t r[$\,$], int force)
\begin{DoxyCompactList}\small\item\em GSM A5/1 Clocking function. \end{DoxyCompactList}\item 
static uint8\+\_\+t \textbf{ \+\_\+a5\+\_\+1\+\_\+get\+\_\+output} (uint32\+\_\+t r[$\,$])
\begin{DoxyCompactList}\small\item\em GSM A5/1 Output function. \end{DoxyCompactList}\item 
void \textbf{ \+\_\+a5\+\_\+1} (const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul)
\begin{DoxyCompactList}\small\item\em Generate a GSM A5/1 cipher stream. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+a5\+\_\+1} (const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul) \textbf{ OSMO\+\_\+\+DEPRECATED}(\char`\"{}Use generic \textbf{ osmo\+\_\+a5}() \textbf{ instead}\char`\"{})
\item 
static void \textbf{ \+\_\+a5\+\_\+2\+\_\+clock} (uint32\+\_\+t r[$\,$], int force)
\begin{DoxyCompactList}\small\item\em GSM A5/2 Clocking function. \end{DoxyCompactList}\item 
static uint8\+\_\+t \textbf{ \+\_\+a5\+\_\+2\+\_\+get\+\_\+output} (uint32\+\_\+t r[$\,$])
\begin{DoxyCompactList}\small\item\em GSM A5/2 Output function. \end{DoxyCompactList}\item 
void \textbf{ \+\_\+a5\+\_\+2} (const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul)
\begin{DoxyCompactList}\small\item\em Generate a GSM A5/1 cipher stream. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+a5\+\_\+2} (const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul) \textbf{ OSMO\+\_\+\+DEPRECATED}(\char`\"{}Use generic \textbf{ osmo\+\_\+a5}() \textbf{ instead}\char`\"{})
\item 
int \textbf{ osmo\+\_\+a5} (int \textbf{ n}, const uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul)
\begin{DoxyCompactList}\small\item\em Main method to generate a A5/x cipher stream. \end{DoxyCompactList}\end{DoxyCompactItemize}
