\doxysection{A5 ciphering algorithm}
\label{group__a5}\index{A5 ciphering algorithm@{A5 ciphering algorithm}}
\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ a5.\+h}
\begin{DoxyCompactList}\small\item\em Osmocom GMR-\/1 A5 ciphering algorithm header. \end{DoxyCompactList}\item 
file \textbf{ a5.\+c}
\begin{DoxyCompactList}\small\item\em Osmocom GMR-\/1 A5 ciphering algorithm implementation. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__a5_gae3fe6f4e45fc1c65745622eda3a5ae0c}} 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+LEN}~19
\item 
\mbox{\label{group__a5_gacd357aebde0cc7aea246beea194131e1}} 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+LEN}~22
\item 
\mbox{\label{group__a5_ga70107262276fd1712eb4fd5b798ca090}} 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+LEN}~23
\item 
\mbox{\label{group__a5_ga35521a46acbeed2a5e058091ade82915}} 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+LEN}~17
\item 
\mbox{\label{group__a5_ga0eee24706edde91f4b45b5fd91e0267d}} 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R1\+\_\+\+LEN)-\/1)
\item 
\mbox{\label{group__a5_ga6fa169f4192fb13e8da75f98157ee415}} 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R2\+\_\+\+LEN)-\/1)
\item 
\mbox{\label{group__a5_ga770485ca8c6ff88aadd96b6bf8b743ab}} 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R3\+\_\+\+LEN)-\/1)
\item 
\mbox{\label{group__a5_gaded8c7d7a756c5fa8bef92fe11703fcb}} 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R4\+\_\+\+LEN)-\/1)
\item 
\mbox{\label{group__a5_ga8063353a3e4668ce39cce2c423703831}} 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+TAPS}~0x072000 /$\ast$ \textbf{ x}$^\wedge$19 + \textbf{ x}$^\wedge$18 + \textbf{ x}$^\wedge$17 + \textbf{ x}$^\wedge$14 + 1 $\ast$/
\item 
\mbox{\label{group__a5_ga1fee5732343b63bcc53ff074447cdc45}} 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+TAPS}~0x311000 /$\ast$ \textbf{ x}$^\wedge$22 + \textbf{ x}$^\wedge$21 + \textbf{ x}$^\wedge$17 + \textbf{ x}$^\wedge$13 + 1 $\ast$/
\item 
\mbox{\label{group__a5_gaf496100fbf1e9f771efa2c973b46cd9f}} 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+TAPS}~0x660000 /$\ast$ \textbf{ x}$^\wedge$23 + \textbf{ x}$^\wedge$22 + \textbf{ x}$^\wedge$19 + \textbf{ x}$^\wedge$18 + 1 $\ast$/
\item 
\mbox{\label{group__a5_ga6799005106ce765f5c107a6529dd59d7}} 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+TAPS}~0x013100 /$\ast$ \textbf{ x}$^\wedge$17 + \textbf{ x}$^\wedge$14 + \textbf{ x}$^\wedge$13 + \textbf{ x}$^\wedge$9 + 1 $\ast$/
\item 
\mbox{\label{group__a5_ga9c2882fb71223a73b3ed3dcddb27a29d}} 
\#define {\bfseries A51\+\_\+\+BIT}(r,  n)~(1 $<$$<$ n)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ gmr1\+\_\+a5} (int n, uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, int nbits, \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}\item 
void \textbf{ gmr1\+\_\+a5\+\_\+1} (uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, int nbits, \textbf{ ubit\+\_\+t} $\ast$dl, \textbf{ ubit\+\_\+t} $\ast$ul)
\begin{DoxyCompactList}\small\item\em Generate a GMR-\/1 A5/1 cipher stream. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}


\doxysubsection{Function Documentation}
\mbox{\label{group__a5_gaddb4e3e6e4a5b5f91fe9308250a70375}} 
\index{A5 ciphering algorithm@{A5 ciphering algorithm}!gmr1\_a5@{gmr1\_a5}}
\index{gmr1\_a5@{gmr1\_a5}!A5 ciphering algorithm@{A5 ciphering algorithm}}
\doxysubsubsection{gmr1\_a5()}
{\footnotesize\ttfamily void gmr1\+\_\+a5 (\begin{DoxyParamCaption}\item[{int}]{n,  }\item[{uint8\+\_\+t $\ast$}]{key,  }\item[{uint32\+\_\+t}]{fn,  }\item[{int}]{nbits,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{dl,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{ul }\end{DoxyParamCaption})}



Main method to generate a A5/x cipher stream. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Which A5/x method to use \\
\hline
\mbox{\texttt{ in}}  & {\em key} & 8 byte array for the key (as received from the SIM) \\
\hline
\mbox{\texttt{ in}}  & {\em fn} & Frame number \\
\hline
\mbox{\texttt{ in}}  & {\em nbits} & How many bits to generate \\
\hline
\mbox{\texttt{ out}}  & {\em dl} & Pointer to array of ubits to return Downlink cipher stream \\
\hline
\mbox{\texttt{ out}}  & {\em ul} & Pointer to array of ubits to return Uplink cipher stream\\
\hline
\end{DoxyParams}
Currently only A5/0 and A5/1. Either (or both) of dl/ul can be NULL if not needed. 

References \textbf{ gmr1\+\_\+a5\+\_\+1()}.

\mbox{\label{group__a5_gad385682d03d182ea6e3d0e99fa4ca04e}} 
\index{A5 ciphering algorithm@{A5 ciphering algorithm}!gmr1\_a5\_1@{gmr1\_a5\_1}}
\index{gmr1\_a5\_1@{gmr1\_a5\_1}!A5 ciphering algorithm@{A5 ciphering algorithm}}
\doxysubsubsection{gmr1\_a5\_1()}
{\footnotesize\ttfamily void gmr1\+\_\+a5\+\_\+1 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{key,  }\item[{uint32\+\_\+t}]{fn,  }\item[{int}]{nbits,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{dl,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{ul }\end{DoxyParamCaption})}



Generate a GMR-\/1 A5/1 cipher stream. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em key} & 8 byte array for the key (as received from the SIM) \\
\hline
\mbox{\texttt{ in}}  & {\em fn} & Frame number \\
\hline
\mbox{\texttt{ in}}  & {\em nbits} & How many bits to generate \\
\hline
\mbox{\texttt{ out}}  & {\em dl} & Pointer to array of ubits to return Downlink cipher stream \\
\hline
\mbox{\texttt{ out}}  & {\em ul} & Pointer to array of ubits to return Uplink cipher stream\\
\hline
\end{DoxyParams}
Either (or both) of dl/ul can be NULL if not needed. 

Referenced by \textbf{ gmr1\+\_\+a5()}.

