\doxysection{src/gsm/kasumi.c File Reference}
\label{kasumi_8c}\index{src/gsm/kasumi.c@{src/gsm/kasumi.c}}


Kasumi cipher and KGcore functions.  


{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/bits.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/kasumi.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static uint16\+\_\+t \textbf{ kasumi\+\_\+\+FI} (uint16\+\_\+t I, uint16\+\_\+t skey)
\item 
static uint32\+\_\+t \textbf{ kasumi\+\_\+\+FO} (uint32\+\_\+t I, const uint16\+\_\+t $\ast$KOi1, const uint16\+\_\+t $\ast$KOi2, const uint16\+\_\+t $\ast$KOi3, const uint16\+\_\+t $\ast$KIi1, const uint16\+\_\+t $\ast$KIi2, const uint16\+\_\+t $\ast$KIi3, unsigned i)
\item 
static uint32\+\_\+t \textbf{ kasumi\+\_\+\+FL} (uint32\+\_\+t I, const uint16\+\_\+t $\ast$KLi1, const uint16\+\_\+t $\ast$KLi2, unsigned i)
\item 
uint64\+\_\+t \textbf{ \+\_\+kasumi} (uint64\+\_\+t P, const uint16\+\_\+t $\ast$KLi1, const uint16\+\_\+t $\ast$KLi2, const uint16\+\_\+t $\ast$KOi1, const uint16\+\_\+t $\ast$KOi2, const uint16\+\_\+t $\ast$KOi3, const uint16\+\_\+t $\ast$KIi1, const uint16\+\_\+t $\ast$KIi2, const uint16\+\_\+t $\ast$KIi3)
\begin{DoxyCompactList}\small\item\em Single iteration of KASUMI cipher. \end{DoxyCompactList}\item 
void \textbf{ \+\_\+kasumi\+\_\+key\+\_\+expand} (const uint8\+\_\+t $\ast$key, uint16\+\_\+t $\ast$KLi1, uint16\+\_\+t $\ast$KLi2, uint16\+\_\+t $\ast$KOi1, uint16\+\_\+t $\ast$KOi2, uint16\+\_\+t $\ast$KOi3, uint16\+\_\+t $\ast$KIi1, uint16\+\_\+t $\ast$KIi2, uint16\+\_\+t $\ast$KIi3)
\begin{DoxyCompactList}\small\item\em Expand key into set of subkeys -\/ see TS 135 202 for details. \end{DoxyCompactList}\item 
void \textbf{ \+\_\+kasumi\+\_\+kgcore} (uint8\+\_\+t CA, uint8\+\_\+t cb, uint32\+\_\+t cc, uint8\+\_\+t cd, const uint8\+\_\+t $\ast$ck, uint8\+\_\+t $\ast$co, uint16\+\_\+t cl)
\begin{DoxyCompactList}\small\item\em Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Kasumi cipher and KGcore functions. 



\doxysubsection{Function Documentation}
\mbox{\label{kasumi_8c_a2906bf96a99f461b77b059e26ff99e51}} 
\index{kasumi.c@{kasumi.c}!\_kasumi@{\_kasumi}}
\index{\_kasumi@{\_kasumi}!kasumi.c@{kasumi.c}}
\doxysubsubsection{\_kasumi()}
{\footnotesize\ttfamily uint64\+\_\+t \+\_\+kasumi (\begin{DoxyParamCaption}\item[{uint64\+\_\+t}]{P,  }\item[{const uint16\+\_\+t $\ast$}]{KLi1,  }\item[{const uint16\+\_\+t $\ast$}]{KLi2,  }\item[{const uint16\+\_\+t $\ast$}]{KOi1,  }\item[{const uint16\+\_\+t $\ast$}]{KOi2,  }\item[{const uint16\+\_\+t $\ast$}]{KOi3,  }\item[{const uint16\+\_\+t $\ast$}]{KIi1,  }\item[{const uint16\+\_\+t $\ast$}]{KIi2,  }\item[{const uint16\+\_\+t $\ast$}]{KIi3 }\end{DoxyParamCaption})}



Single iteration of KASUMI cipher. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em P} & Block, 64 bits to be processed in this round \\
\hline
\mbox{\texttt{ in}}  & {\em KLi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KLi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KOi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KOi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KOi3} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KIi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KIi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ in}}  & {\em KIi3} & Expanded subkeys \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
processed block of 64 bits 
\end{DoxyReturn}


References \textbf{ kasumi\+\_\+\+FL()}, \textbf{ kasumi\+\_\+\+FO()}, \textbf{ L}, and \textbf{ R}.



Referenced by \textbf{ \+\_\+kasumi\+\_\+kgcore()}.

\mbox{\label{kasumi_8c_a079092d857712a160578b4a31deb1fb0}} 
\index{kasumi.c@{kasumi.c}!\_kasumi\_key\_expand@{\_kasumi\_key\_expand}}
\index{\_kasumi\_key\_expand@{\_kasumi\_key\_expand}!kasumi.c@{kasumi.c}}
\doxysubsubsection{\_kasumi\_key\_expand()}
{\footnotesize\ttfamily void \+\_\+kasumi\+\_\+key\+\_\+expand (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{key,  }\item[{uint16\+\_\+t $\ast$}]{KLi1,  }\item[{uint16\+\_\+t $\ast$}]{KLi2,  }\item[{uint16\+\_\+t $\ast$}]{KOi1,  }\item[{uint16\+\_\+t $\ast$}]{KOi2,  }\item[{uint16\+\_\+t $\ast$}]{KOi3,  }\item[{uint16\+\_\+t $\ast$}]{KIi1,  }\item[{uint16\+\_\+t $\ast$}]{KIi2,  }\item[{uint16\+\_\+t $\ast$}]{KIi3 }\end{DoxyParamCaption})}



Expand key into set of subkeys -\/ see TS 135 202 for details. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em key} & (128 bits) as array of bytes \\
\hline
\mbox{\texttt{ out}}  & {\em KLi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KLi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KOi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KOi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KOi3} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KIi1} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KIi2} & Expanded subkeys \\
\hline
\mbox{\texttt{ out}}  & {\em KIi3} & Expanded subkeys \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+rol16()}.



Referenced by \textbf{ \+\_\+kasumi\+\_\+kgcore()}.

\mbox{\label{kasumi_8c_a998653393498a3aa3f4f8f624468741f}} 
\index{kasumi.c@{kasumi.c}!\_kasumi\_kgcore@{\_kasumi\_kgcore}}
\index{\_kasumi\_kgcore@{\_kasumi\_kgcore}!kasumi.c@{kasumi.c}}
\doxysubsubsection{\_kasumi\_kgcore()}
{\footnotesize\ttfamily void \+\_\+kasumi\+\_\+kgcore (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{CA,  }\item[{uint8\+\_\+t}]{cb,  }\item[{uint32\+\_\+t}]{cc,  }\item[{uint8\+\_\+t}]{cd,  }\item[{const uint8\+\_\+t $\ast$}]{ck,  }\item[{uint8\+\_\+t $\ast$}]{co,  }\item[{uint16\+\_\+t}]{cl }\end{DoxyParamCaption})}



Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em CA} & \\
\hline
\mbox{\texttt{ in}}  & {\em cb} & \\
\hline
\mbox{\texttt{ in}}  & {\em cc} & \\
\hline
\mbox{\texttt{ in}}  & {\em cd} & \\
\hline
\mbox{\texttt{ in}}  & {\em ck} & 8-\/bytes long key \\
\hline
\mbox{\texttt{ out}}  & {\em co} & cl-\/dependent \\
\hline
\mbox{\texttt{ in}}  & {\em cl} & \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+kasumi()}, and \textbf{ \+\_\+kasumi\+\_\+key\+\_\+expand()}.



Referenced by \textbf{ \+\_\+a5\+\_\+4()}, and \textbf{ gea4()}.

\mbox{\label{kasumi_8c_a95c2164517b3de83be2a060049bd8e64}} 
\index{kasumi.c@{kasumi.c}!kasumi\_FI@{kasumi\_FI}}
\index{kasumi\_FI@{kasumi\_FI}!kasumi.c@{kasumi.c}}
\doxysubsubsection{kasumi\_FI()}
{\footnotesize\ttfamily static uint16\+\_\+t kasumi\+\_\+\+FI (\begin{DoxyParamCaption}\item[{uint16\+\_\+t}]{I,  }\item[{uint16\+\_\+t}]{skey }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ L}, and \textbf{ R}.



Referenced by \textbf{ kasumi\+\_\+\+FO()}.

\mbox{\label{kasumi_8c_a9a964a9fcd2371f28c121ef5ebb3b444}} 
\index{kasumi.c@{kasumi.c}!kasumi\_FL@{kasumi\_FL}}
\index{kasumi\_FL@{kasumi\_FL}!kasumi.c@{kasumi.c}}
\doxysubsubsection{kasumi\_FL()}
{\footnotesize\ttfamily static uint32\+\_\+t kasumi\+\_\+\+FL (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{I,  }\item[{const uint16\+\_\+t $\ast$}]{KLi1,  }\item[{const uint16\+\_\+t $\ast$}]{KLi2,  }\item[{unsigned}]{i }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ L}, \textbf{ osmo\+\_\+rol16()}, and \textbf{ R}.



Referenced by \textbf{ \+\_\+kasumi()}.

\mbox{\label{kasumi_8c_a4ddfcb4c95d37f5a2840fd3720cb58cc}} 
\index{kasumi.c@{kasumi.c}!kasumi\_FO@{kasumi\_FO}}
\index{kasumi\_FO@{kasumi\_FO}!kasumi.c@{kasumi.c}}
\doxysubsubsection{kasumi\_FO()}
{\footnotesize\ttfamily static uint32\+\_\+t kasumi\+\_\+\+FO (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{I,  }\item[{const uint16\+\_\+t $\ast$}]{KOi1,  }\item[{const uint16\+\_\+t $\ast$}]{KOi2,  }\item[{const uint16\+\_\+t $\ast$}]{KOi3,  }\item[{const uint16\+\_\+t $\ast$}]{KIi1,  }\item[{const uint16\+\_\+t $\ast$}]{KIi2,  }\item[{const uint16\+\_\+t $\ast$}]{KIi3,  }\item[{unsigned}]{i }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ kasumi\+\_\+\+FI()}, \textbf{ L}, and \textbf{ R}.



Referenced by \textbf{ \+\_\+kasumi()}.

