\doxysection{src/gsm/kdf/sha1-\/internal.c File Reference}
\label{sha1-internal_8c}\index{src/gsm/kdf/sha1-\/internal.c@{src/gsm/kdf/sha1-\/internal.c}}
{\ttfamily \#include \char`\"{}common.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}sha1.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}sha1\+\_\+i.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}crypto.\+h\char`\"{}}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ SHA1\+HANDSOFF}
\item 
\#define \textbf{ rol}(value,  bits)~(((value) $<$$<$ (bits)) $\vert$ ((value) $>$$>$ (32 -\/ (bits))))
\item 
\#define \textbf{ blk0}(i)
\item 
\#define \textbf{ blk}(i)
\item 
\#define \textbf{ R0}(v,  w,  x,  y,  z,  i)
\item 
\#define \textbf{ R1}(v,  w,  x,  y,  z,  i)
\item 
\#define \textbf{ R2}(v,  w,  x,  y,  z,  i)~ z += (w $^\wedge$ x $^\wedge$ y) + \textbf{ blk}(i) + 0x6\+ED9\+EBA1 + \textbf{ rol}(v, 5); w = \textbf{ rol}(w, 30);
\item 
\#define \textbf{ R3}(v,  w,  x,  y,  z,  i)
\item 
\#define \textbf{ R4}(v,  w,  x,  y,  z,  i)
\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct \textbf{ SHA1\+Context} \textbf{ SHA1\+\_\+\+CTX}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ SHA1\+Transform} (\textbf{ u32} state[5], const unsigned char \textbf{ buffer}[64])
\item 
int \textbf{ sha1\+\_\+vector} (size\+\_\+t num\+\_\+elem, const \textbf{ u8} $\ast$addr[$\,$], const size\+\_\+t $\ast$\textbf{ len}, \textbf{ u8} $\ast$mac)
\begin{DoxyCompactList}\small\item\em sha1\+\_\+vector -\/ SHA-\/1 hash for data vector @num\+\_\+elem\+: Number of elements in the data vector @addr\+: Pointers to the data areas @len\+: Lengths of the data blocks @mac\+: Buffer for the hash Returns\+: 0 on success, -\/1 of failure \end{DoxyCompactList}\item 
void \textbf{ SHA1\+Init} (\textbf{ SHA1\+\_\+\+CTX} $\ast$context)
\item 
void \textbf{ SHA1\+Update} (\textbf{ SHA1\+\_\+\+CTX} $\ast$context, const void $\ast$\+\_\+data, \textbf{ u32} \textbf{ len})
\item 
void \textbf{ SHA1\+Final} (unsigned char digest[20], \textbf{ SHA1\+\_\+\+CTX} $\ast$context)
\end{DoxyCompactItemize}


\doxysubsection{Macro Definition Documentation}
\mbox{\label{sha1-internal_8c_abd06ff24e9f6f5f0a9c32a1cba4b0f9c}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!blk@{blk}}
\index{blk@{blk}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{blk}
{\footnotesize\ttfamily \#define blk(\begin{DoxyParamCaption}\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        (block-\/>l[i \& 15] = rol(block-\/>l[(i + 13) \& 15] \string^ \(\backslash\)}
\DoxyCodeLine{        block-\/>l[(i + 8) \& 15] \string^ block-\/>l[(i + 2) \& 15] \string^ block-\/>l[i \& 15], 1))}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_a1a75de24d0277c5319098c218efaef2d}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!blk0@{blk0}}
\index{blk0@{blk0}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{blk0}
{\footnotesize\ttfamily \#define blk0(\begin{DoxyParamCaption}\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        (block-\/>l[i] = (rol(block-\/>l[i], 24) \& 0xFF00FF00) | \(\backslash\)}
\DoxyCodeLine{        (rol(block-\/>l[i], 8) \& 0x00FF00FF))}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_a8ac24a09e1273548828d3cc9436f9bc7}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!R0@{R0}}
\index{R0@{R0}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{R0}
{\footnotesize\ttfamily \#define R0(\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{w,  }\item[{}]{x,  }\item[{}]{y,  }\item[{}]{z,  }\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        z += ((w \& (x \string^ y)) \string^ y) + blk0(i) + 0x5A827999 + rol(v, 5); \(\backslash\)}
\DoxyCodeLine{        w = rol(w, 30);}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_a2628f8af7bf67ca052200537279f855a}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!R1@{R1}}
\index{R1@{R1}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{R1}
{\footnotesize\ttfamily \#define R1(\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{w,  }\item[{}]{x,  }\item[{}]{y,  }\item[{}]{z,  }\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        z += ((w \& (x \string^ y)) \string^ y) + blk(i) + 0x5A827999 + rol(v, 5); \(\backslash\)}
\DoxyCodeLine{        w = rol(w, 30);}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_a774229b80509be0e9e0a1d9819580224}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!R2@{R2}}
\index{R2@{R2}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{R2}
{\footnotesize\ttfamily \#define R2(\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{w,  }\item[{}]{x,  }\item[{}]{y,  }\item[{}]{z,  }\item[{}]{i }\end{DoxyParamCaption})~ z += (w $^\wedge$ x $^\wedge$ y) + \textbf{ blk}(i) + 0x6\+ED9\+EBA1 + \textbf{ rol}(v, 5); w = \textbf{ rol}(w, 30);}

\mbox{\label{sha1-internal_8c_ac0b8b342432d17717ff1020d10cf0eea}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!R3@{R3}}
\index{R3@{R3}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{R3}
{\footnotesize\ttfamily \#define R3(\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{w,  }\item[{}]{x,  }\item[{}]{y,  }\item[{}]{z,  }\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        z += (((w | x) \& y) | (w \& x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); \(\backslash\)}
\DoxyCodeLine{        w = rol(w, 30);}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_af77ddc8894422d2af2adbd4e71e55d1f}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!R4@{R4}}
\index{R4@{R4}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{R4}
{\footnotesize\ttfamily \#define R4(\begin{DoxyParamCaption}\item[{}]{v,  }\item[{}]{w,  }\item[{}]{x,  }\item[{}]{y,  }\item[{}]{z,  }\item[{}]{i }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        z += (w \string^ x \string^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \(\backslash\)}
\DoxyCodeLine{        w=rol(w, 30);}

\end{DoxyCode}
\mbox{\label{sha1-internal_8c_af1373930110e4f86cb1f4bc6d44a66ee}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!rol@{rol}}
\index{rol@{rol}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{rol}
{\footnotesize\ttfamily \#define rol(\begin{DoxyParamCaption}\item[{}]{value,  }\item[{}]{bits }\end{DoxyParamCaption})~(((value) $<$$<$ (bits)) $\vert$ ((value) $>$$>$ (32 -\/ (bits))))}

\mbox{\label{sha1-internal_8c_a9e2c8862606a4549edef298248089783}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1HANDSOFF@{SHA1HANDSOFF}}
\index{SHA1HANDSOFF@{SHA1HANDSOFF}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1HANDSOFF}
{\footnotesize\ttfamily \#define SHA1\+HANDSOFF}



\doxysubsection{Typedef Documentation}
\mbox{\label{sha1-internal_8c_abd1ada82e56afeb02bcb22fa43749849}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1\_CTX@{SHA1\_CTX}}
\index{SHA1\_CTX@{SHA1\_CTX}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1\_CTX}
{\footnotesize\ttfamily typedef struct \textbf{ SHA1\+Context} \textbf{ SHA1\+\_\+\+CTX}}



\doxysubsection{Function Documentation}
\mbox{\label{sha1-internal_8c_ac06a574002700fe245e6f543e79daccd}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!sha1\_vector@{sha1\_vector}}
\index{sha1\_vector@{sha1\_vector}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{sha1\_vector()}
{\footnotesize\ttfamily int sha1\+\_\+vector (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{num\+\_\+elem,  }\item[{const \textbf{ u8} $\ast$}]{addr[$\,$],  }\item[{const size\+\_\+t $\ast$}]{len,  }\item[{\textbf{ u8} $\ast$}]{mac }\end{DoxyParamCaption})}



sha1\+\_\+vector -\/ SHA-\/1 hash for data vector @num\+\_\+elem\+: Number of elements in the data vector @addr\+: Pointers to the data areas @len\+: Lengths of the data blocks @mac\+: Buffer for the hash Returns\+: 0 on success, -\/1 of failure 

sha1\+\_\+vector -\/ SHA-\/1 hash for data vector @num\+\_\+elem\+: Number of elements in the data vector @addr\+: Pointers to the data areas @len\+: Lengths of the data blocks @mac\+: Buffer for the hash Returns\+: 0 on success, -\/1 on failure 

References \textbf{ len}, \textbf{ SHA1\+Final()}, \textbf{ SHA1\+Init()}, and \textbf{ SHA1\+Update()}.



Referenced by \textbf{ hmac\+\_\+sha1\+\_\+vector()}.

\mbox{\label{sha1-internal_8c_aa58f279c51d82e868c9b0f7b1b7d08f4}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1Final@{SHA1Final}}
\index{SHA1Final@{SHA1Final}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1Final()}
{\footnotesize\ttfamily void SHA1\+Final (\begin{DoxyParamCaption}\item[{unsigned char}]{digest[20],  }\item[{\textbf{ SHA1\+\_\+\+CTX} $\ast$}]{context }\end{DoxyParamCaption})}



References \textbf{ SHA1\+Context\+::buffer}, \textbf{ SHA1\+Context\+::count}, \textbf{ os\+\_\+memset}, \textbf{ SHA1\+Update()}, and \textbf{ SHA1\+Context\+::state}.



Referenced by \textbf{ sha1\+\_\+vector()}.

\mbox{\label{sha1-internal_8c_a159a97b3039391403b8d9b0d240a9640}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1Init@{SHA1Init}}
\index{SHA1Init@{SHA1Init}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1Init()}
{\footnotesize\ttfamily void SHA1\+Init (\begin{DoxyParamCaption}\item[{\textbf{ SHA1\+\_\+\+CTX} $\ast$}]{context }\end{DoxyParamCaption})}



References \textbf{ SHA1\+Context\+::count}, and \textbf{ SHA1\+Context\+::state}.



Referenced by \textbf{ sha1\+\_\+vector()}.

\mbox{\label{sha1-internal_8c_a5bd00201ebf1fbb569dca973975d822b}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1Transform@{SHA1Transform}}
\index{SHA1Transform@{SHA1Transform}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1Transform()}
{\footnotesize\ttfamily void SHA1\+Transform (\begin{DoxyParamCaption}\item[{\textbf{ u32}}]{state[5],  }\item[{const unsigned char}]{buffer[64] }\end{DoxyParamCaption})}



References \textbf{ c}, \textbf{ l}, \textbf{ os\+\_\+memcpy}, \textbf{ os\+\_\+memset}, \textbf{ R0}, \textbf{ R1}, \textbf{ R2}, \textbf{ R3}, and \textbf{ R4}.



Referenced by \textbf{ SHA1\+Update()}.

\mbox{\label{sha1-internal_8c_ac6e81ac0b65c4211d8db52799ae87a3c}} 
\index{sha1-\/internal.c@{sha1-\/internal.c}!SHA1Update@{SHA1Update}}
\index{SHA1Update@{SHA1Update}!sha1-\/internal.c@{sha1-\/internal.c}}
\doxysubsubsection{SHA1Update()}
{\footnotesize\ttfamily void SHA1\+Update (\begin{DoxyParamCaption}\item[{\textbf{ SHA1\+\_\+\+CTX} $\ast$}]{context,  }\item[{const void $\ast$}]{\+\_\+data,  }\item[{\textbf{ u32}}]{len }\end{DoxyParamCaption})}



References \textbf{ SHA1\+Context\+::buffer}, \textbf{ SHA1\+Context\+::count}, \textbf{ data}, \textbf{ len}, \textbf{ os\+\_\+memcpy}, \textbf{ SHA1\+Transform()}, and \textbf{ SHA1\+Context\+::state}.



Referenced by \textbf{ sha1\+\_\+vector()}, and \textbf{ SHA1\+Final()}.

