\doxysection{src/gsm/milenage/milenage.h File Reference}
\label{milenage_8h}\index{src/gsm/milenage/milenage.h@{src/gsm/milenage/milenage.h}}


UMTS AKA -\/ Milenage algorithm (3GPP TS 35.\+205, .206, .207, .208).  


\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ milenage\+\_\+generate} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$amf, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$sqn, const \textbf{ u8} $\ast$\+\_\+rand, \textbf{ u8} $\ast$autn, \textbf{ u8} $\ast$ik, \textbf{ u8} $\ast$ck, \textbf{ u8} $\ast$\textbf{ res}, size\+\_\+t $\ast$res\+\_\+len)
\begin{DoxyCompactList}\small\item\em milenage\+\_\+generate -\/ Generate AKA AUTN,IK,CK,RES @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @amf\+: AMF = 16-\/bit authentication management field @k\+: K = 128-\/bit subscriber key @sqn\+: SQN = 48-\/bit sequence number @\+\_\+rand\+: RAND = 128-\/bit random challenge @autn\+: Buffer for AUTN = 128-\/bit authentication token @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @res\+\_\+len\+: Max length for res; set to used length or 0 on failure \end{DoxyCompactList}\item 
int \textbf{ milenage\+\_\+auts} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$\+\_\+rand, const \textbf{ u8} $\ast$auts, \textbf{ u8} $\ast$sqn)
\begin{DoxyCompactList}\small\item\em milenage\+\_\+auts -\/ Milenage AUTS validation @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @auts\+: AUTS = 112-\/bit authentication token from client @sqn\+: Buffer for SQN = 48-\/bit sequence number Returns\+: 0 = success (sqn filled), -\/1 on failure \end{DoxyCompactList}\item 
int \textbf{ gsm\+\_\+milenage} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$\+\_\+rand, \textbf{ u8} $\ast$\textbf{ sres}, \textbf{ u8} $\ast$kc)
\begin{DoxyCompactList}\small\item\em gsm\+\_\+milenage -\/ Generate GSM-\/\+Milenage (3GPP TS 55.\+205) authentication triplet @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @sres\+: Buffer for SRES = 32-\/bit SRES @kc\+: Buffer for Kc = 64-\/bit Kc Returns\+: 0 on success, -\/1 on failure \end{DoxyCompactList}\item 
int \textbf{ milenage\+\_\+check} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$sqn, const \textbf{ u8} $\ast$\+\_\+rand, const \textbf{ u8} $\ast$autn, \textbf{ u8} $\ast$ik, \textbf{ u8} $\ast$ck, \textbf{ u8} $\ast$\textbf{ res}, size\+\_\+t $\ast$res\+\_\+len, \textbf{ u8} $\ast$auts)
\begin{DoxyCompactList}\small\item\em milenage\+\_\+generate -\/ Generate AKA AUTN,IK,CK,RES @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @sqn\+: SQN = 48-\/bit sequence number @\+\_\+rand\+: RAND = 128-\/bit random challenge @autn\+: AUTN = 128-\/bit authentication token @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @res\+\_\+len\+: Variable that will be set to RES length @auts\+: 112-\/bit buffer for AUTS Returns\+: 0 on success, -\/1 on failure, or -\/2 on synchronization failure \end{DoxyCompactList}\item 
int \textbf{ milenage\+\_\+f1} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$\+\_\+rand, const \textbf{ u8} $\ast$sqn, const \textbf{ u8} $\ast$amf, \textbf{ u8} $\ast$mac\+\_\+a, \textbf{ u8} $\ast$mac\+\_\+s)
\begin{DoxyCompactList}\small\item\em milenage\+\_\+f1 -\/ Milenage f1 and f1$\ast$ algorithms @opc\+: OPc = 128-\/bit value derived from OP and K @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @sqn\+: SQN = 48-\/bit sequence number @amf\+: AMF = 16-\/bit authentication management field @mac\+\_\+a\+: Buffer for MAC-\/A = 64-\/bit network authentication code, or NULL @mac\+\_\+s\+: Buffer for MAC-\/S = 64-\/bit resync authentication code, or NULL Returns\+: 0 on success, -\/1 on failure \end{DoxyCompactList}\item 
int \textbf{ milenage\+\_\+f2345} (const \textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$\+\_\+rand, \textbf{ u8} $\ast$\textbf{ res}, \textbf{ u8} $\ast$ck, \textbf{ u8} $\ast$ik, \textbf{ u8} $\ast$ak, \textbf{ u8} $\ast$akstar)
\begin{DoxyCompactList}\small\item\em milenage\+\_\+f2345 -\/ Milenage f2, f3, f4, f5, f5$\ast$ algorithms @opc\+: OPc = 128-\/bit value derived from OP and K @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ak\+: Buffer for AK = 48-\/bit anonymity key (f5), or NULL @akstar\+: Buffer for AK = 48-\/bit anonymity key (f5$\ast$), or NULL Returns\+: 0 on success, -\/1 on failure \end{DoxyCompactList}\item 
int \textbf{ milenage\+\_\+opc\+\_\+gen} (\textbf{ u8} $\ast$opc, const \textbf{ u8} $\ast$k, const \textbf{ u8} $\ast$op)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
UMTS AKA -\/ Milenage algorithm (3GPP TS 35.\+205, .206, .207, .208). 



\doxysubsection{Function Documentation}
\mbox{\label{milenage_8h_a68993729d0b2a650c8ef0c54e47cbb8b}} 
\index{milenage.h@{milenage.h}!gsm\_milenage@{gsm\_milenage}}
\index{gsm\_milenage@{gsm\_milenage}!milenage.h@{milenage.h}}
\doxysubsubsection{gsm\_milenage()}
{\footnotesize\ttfamily int gsm\+\_\+milenage (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{\textbf{ u8} $\ast$}]{sres,  }\item[{\textbf{ u8} $\ast$}]{kc }\end{DoxyParamCaption})}



gsm\+\_\+milenage -\/ Generate GSM-\/\+Milenage (3GPP TS 55.\+205) authentication triplet @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @sres\+: Buffer for SRES = 32-\/bit SRES @kc\+: Buffer for Kc = 64-\/bit Kc Returns\+: 0 on success, -\/1 on failure 



References \textbf{ milenage\+\_\+f2345()}, \textbf{ osmo\+\_\+auth\+\_\+c2()}, \textbf{ osmo\+\_\+auth\+\_\+c3()}, \textbf{ res}, and \textbf{ sres}.

\mbox{\label{milenage_8h_a12163d88a32831bdbf69a9ef78817ab3}} 
\index{milenage.h@{milenage.h}!milenage\_auts@{milenage\_auts}}
\index{milenage\_auts@{milenage\_auts}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_auts()}
{\footnotesize\ttfamily int milenage\+\_\+auts (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{const \textbf{ u8} $\ast$}]{auts,  }\item[{\textbf{ u8} $\ast$}]{sqn }\end{DoxyParamCaption})}



milenage\+\_\+auts -\/ Milenage AUTS validation @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @auts\+: AUTS = 112-\/bit authentication token from client @sqn\+: Buffer for SQN = 48-\/bit sequence number Returns\+: 0 = success (sqn filled), -\/1 on failure 



References \textbf{ milenage\+\_\+f1()}, and \textbf{ milenage\+\_\+f2345()}.



Referenced by \textbf{ milenage\+\_\+gen\+\_\+vec\+\_\+auts()}.

\mbox{\label{milenage_8h_a7f165c839581ff45a720bb359e4b938a}} 
\index{milenage.h@{milenage.h}!milenage\_check@{milenage\_check}}
\index{milenage\_check@{milenage\_check}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_check()}
{\footnotesize\ttfamily int milenage\+\_\+check (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{sqn,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{const \textbf{ u8} $\ast$}]{autn,  }\item[{\textbf{ u8} $\ast$}]{ik,  }\item[{\textbf{ u8} $\ast$}]{ck,  }\item[{\textbf{ u8} $\ast$}]{res,  }\item[{size\+\_\+t $\ast$}]{res\+\_\+len,  }\item[{\textbf{ u8} $\ast$}]{auts }\end{DoxyParamCaption})}



milenage\+\_\+generate -\/ Generate AKA AUTN,IK,CK,RES @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @k\+: K = 128-\/bit subscriber key @sqn\+: SQN = 48-\/bit sequence number @\+\_\+rand\+: RAND = 128-\/bit random challenge @autn\+: AUTN = 128-\/bit authentication token @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @res\+\_\+len\+: Variable that will be set to RES length @auts\+: 112-\/bit buffer for AUTS Returns\+: 0 on success, -\/1 on failure, or -\/2 on synchronization failure 



References \textbf{ milenage\+\_\+f1()}, \textbf{ milenage\+\_\+f2345()}, \textbf{ MSG\+\_\+\+DEBUG}, \textbf{ os\+\_\+memcmp}, \textbf{ res}, \textbf{ wpa\+\_\+hexdump}, \textbf{ wpa\+\_\+hexdump\+\_\+key}, and \textbf{ wpa\+\_\+printf}.

\mbox{\label{milenage_8h_aff05a02488109d4b714bae767ab4be99}} 
\index{milenage.h@{milenage.h}!milenage\_f1@{milenage\_f1}}
\index{milenage\_f1@{milenage\_f1}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_f1()}
{\footnotesize\ttfamily int milenage\+\_\+f1 (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{const \textbf{ u8} $\ast$}]{sqn,  }\item[{const \textbf{ u8} $\ast$}]{amf,  }\item[{\textbf{ u8} $\ast$}]{mac\+\_\+a,  }\item[{\textbf{ u8} $\ast$}]{mac\+\_\+s }\end{DoxyParamCaption})}



milenage\+\_\+f1 -\/ Milenage f1 and f1$\ast$ algorithms @opc\+: OPc = 128-\/bit value derived from OP and K @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @sqn\+: SQN = 48-\/bit sequence number @amf\+: AMF = 16-\/bit authentication management field @mac\+\_\+a\+: Buffer for MAC-\/A = 64-\/bit network authentication code, or NULL @mac\+\_\+s\+: Buffer for MAC-\/S = 64-\/bit resync authentication code, or NULL Returns\+: 0 on success, -\/1 on failure 



References \textbf{ aes\+\_\+128\+\_\+encrypt\+\_\+block()}, and \textbf{ os\+\_\+memcpy}.



Referenced by \textbf{ milenage\+\_\+auts()}, \textbf{ milenage\+\_\+check()}, and \textbf{ milenage\+\_\+generate()}.

\mbox{\label{milenage_8h_adebf82372f4034b859838db1eba31020}} 
\index{milenage.h@{milenage.h}!milenage\_f2345@{milenage\_f2345}}
\index{milenage\_f2345@{milenage\_f2345}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_f2345()}
{\footnotesize\ttfamily int milenage\+\_\+f2345 (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{\textbf{ u8} $\ast$}]{res,  }\item[{\textbf{ u8} $\ast$}]{ck,  }\item[{\textbf{ u8} $\ast$}]{ik,  }\item[{\textbf{ u8} $\ast$}]{ak,  }\item[{\textbf{ u8} $\ast$}]{akstar }\end{DoxyParamCaption})}



milenage\+\_\+f2345 -\/ Milenage f2, f3, f4, f5, f5$\ast$ algorithms @opc\+: OPc = 128-\/bit value derived from OP and K @k\+: K = 128-\/bit subscriber key @\+\_\+rand\+: RAND = 128-\/bit random challenge @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ak\+: Buffer for AK = 48-\/bit anonymity key (f5), or NULL @akstar\+: Buffer for AK = 48-\/bit anonymity key (f5$\ast$), or NULL Returns\+: 0 on success, -\/1 on failure 



References \textbf{ aes\+\_\+128\+\_\+encrypt\+\_\+block()}, \textbf{ os\+\_\+memcpy}, and \textbf{ res}.



Referenced by \textbf{ gsm\+\_\+milenage()}, \textbf{ milenage\+\_\+auts()}, \textbf{ milenage\+\_\+check()}, and \textbf{ milenage\+\_\+generate()}.

\mbox{\label{milenage_8h_a07a349067ed32a96a2cd48d5261df987}} 
\index{milenage.h@{milenage.h}!milenage\_generate@{milenage\_generate}}
\index{milenage\_generate@{milenage\_generate}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_generate()}
{\footnotesize\ttfamily void milenage\+\_\+generate (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{amf,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{sqn,  }\item[{const \textbf{ u8} $\ast$}]{\+\_\+rand,  }\item[{\textbf{ u8} $\ast$}]{autn,  }\item[{\textbf{ u8} $\ast$}]{ik,  }\item[{\textbf{ u8} $\ast$}]{ck,  }\item[{\textbf{ u8} $\ast$}]{res,  }\item[{size\+\_\+t $\ast$}]{res\+\_\+len }\end{DoxyParamCaption})}



milenage\+\_\+generate -\/ Generate AKA AUTN,IK,CK,RES @opc\+: OPc = 128-\/bit operator variant algorithm configuration field (encr.) @amf\+: AMF = 16-\/bit authentication management field @k\+: K = 128-\/bit subscriber key @sqn\+: SQN = 48-\/bit sequence number @\+\_\+rand\+: RAND = 128-\/bit random challenge @autn\+: Buffer for AUTN = 128-\/bit authentication token @ik\+: Buffer for IK = 128-\/bit integrity key (f4), or NULL @ck\+: Buffer for CK = 128-\/bit confidentiality key (f3), or NULL @res\+: Buffer for RES = 64-\/bit signed response (f2), or NULL @res\+\_\+len\+: Max length for res; set to used length or 0 on failure 



References \textbf{ milenage\+\_\+f1()}, \textbf{ milenage\+\_\+f2345()}, \textbf{ os\+\_\+memcpy}, and \textbf{ res}.



Referenced by \textbf{ milenage\+\_\+gen\+\_\+vec()}.

\mbox{\label{milenage_8h_a5eac59bcbf395d509aa086a6262dda2a}} 
\index{milenage.h@{milenage.h}!milenage\_opc\_gen@{milenage\_opc\_gen}}
\index{milenage\_opc\_gen@{milenage\_opc\_gen}!milenage.h@{milenage.h}}
\doxysubsubsection{milenage\_opc\_gen()}
{\footnotesize\ttfamily int milenage\+\_\+opc\+\_\+gen (\begin{DoxyParamCaption}\item[{\textbf{ u8} $\ast$}]{opc,  }\item[{const \textbf{ u8} $\ast$}]{k,  }\item[{const \textbf{ u8} $\ast$}]{op }\end{DoxyParamCaption})}



References \textbf{ aes\+\_\+128\+\_\+encrypt\+\_\+block()}.



Referenced by \textbf{ gen\+\_\+opc\+\_\+if\+\_\+needed()}.

