\doxysection{src/l1/a5.c File Reference}
\label{a5_8c}\index{src/l1/a5.c@{src/l1/a5.c}}


Osmocom GMR-\/1 A5 ciphering algorithm implementation.  


{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/bits.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gmr1/l1/a5.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+LEN}~19
\item 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+LEN}~22
\item 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+LEN}~23
\item 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+LEN}~17
\item 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R1\+\_\+\+LEN)-\/1)
\item 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R2\+\_\+\+LEN)-\/1)
\item 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R3\+\_\+\+LEN)-\/1)
\item 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+MASK}~((1$<$$<$A51\+\_\+\+R4\+\_\+\+LEN)-\/1)
\item 
\#define {\bfseries A51\+\_\+\+R1\+\_\+\+TAPS}~0x072000 /$\ast$ x$^\wedge$19 + x$^\wedge$18 + x$^\wedge$17 + x$^\wedge$14 + 1 $\ast$/
\item 
\#define {\bfseries A51\+\_\+\+R2\+\_\+\+TAPS}~0x311000 /$\ast$ x$^\wedge$22 + x$^\wedge$21 + x$^\wedge$17 + x$^\wedge$13 + 1 $\ast$/
\item 
\#define {\bfseries A51\+\_\+\+R3\+\_\+\+TAPS}~0x660000 /$\ast$ x$^\wedge$23 + x$^\wedge$22 + x$^\wedge$19 + x$^\wedge$18 + 1 $\ast$/
\item 
\#define {\bfseries A51\+\_\+\+R4\+\_\+\+TAPS}~0x013100 /$\ast$ x$^\wedge$17 + x$^\wedge$14 + x$^\wedge$13 + x$^\wedge$9 + 1 $\ast$/
\item 
\#define {\bfseries A51\+\_\+\+BIT}(r,  n)~(1 $<$$<$ n)
\item 
\#define \textbf{ MAJ}(rnum,  rname,  a,  b,  c)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ gmr1\+\_\+a5} (int n, uint8\+\_\+t $\ast$key, uint32\+\_\+t fn, int nbits, ubit\+\_\+t $\ast$dl, 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, ubit\+\_\+t $\ast$dl, ubit\+\_\+t $\ast$ul)
\begin{DoxyCompactList}\small\item\em Generate a GMR-\/1 A5/1 cipher stream. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Osmocom GMR-\/1 A5 ciphering algorithm implementation. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{a5_8c_a7d6896e2125732468a6bc4b0798e8a39}} 
\index{a5.c@{a5.c}!MAJ@{MAJ}}
\index{MAJ@{MAJ}!a5.c@{a5.c}}
\doxysubsubsection{MAJ}
{\footnotesize\ttfamily \#define MAJ(\begin{DoxyParamCaption}\item[{}]{rnum,  }\item[{}]{rname,  }\item[{}]{a,  }\item[{}]{b,  }\item[{}]{c }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{                m[rnum] = \_a5\_majority(                 \(\backslash\)}
\DoxyCodeLine{                        r[rnum] \& A51\_BIT(rname, a),    \(\backslash\)}
\DoxyCodeLine{                        r[rnum] \& A51\_BIT(rname, b),    \(\backslash\)}
\DoxyCodeLine{                        r[rnum] \& A51\_BIT(rname, c)     \(\backslash\)}
\DoxyCodeLine{                );}

\end{DoxyCode}
