\doxysection{src/gsm/milenage/aes-\/internal-\/enc.c File Reference}
\label{aes-internal-enc_8c}\index{src/gsm/milenage/aes-\/internal-\/enc.c@{src/gsm/milenage/aes-\/internal-\/enc.c}}


AES (Rijndael) cipher -\/ encrypt.  


{\ttfamily \#include \char`\"{}includes.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}common.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}crypto.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}aes\+\_\+i.\+h\char`\"{}}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ ROUND}(i,  d,  s)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \textbf{ rijndael\+Encrypt} (const \textbf{ u32} rk[$\,$], const \textbf{ u8} pt[16], \textbf{ u8} ct[16])
\item 
void $\ast$ \textbf{ aes\+\_\+encrypt\+\_\+init} (const \textbf{ u8} $\ast$key, size\+\_\+t \textbf{ len})
\begin{DoxyCompactList}\small\item\em aes\+\_\+encrypt\+\_\+init -\/ Initialize AES for encryption @key\+: Encryption key @len\+: Key length in bytes (usually 16, i.\+e., 128 bits) Returns\+: Pointer to context data or NULL on failure \end{DoxyCompactList}\item 
void \textbf{ aes\+\_\+encrypt} (void $\ast$ctx, const \textbf{ u8} $\ast$plain, \textbf{ u8} $\ast$crypt)
\begin{DoxyCompactList}\small\item\em aes\+\_\+encrypt -\/ Encrypt one AES block @ctx\+: Context pointer from \doxyref{aes\+\_\+encrypt\+\_\+init()}{p.}{kdf_2crypto_8h_a343a371ec5ee6a3785da74796bb25bc4} @plain\+: Plaintext data to be encrypted (16 bytes) @crypt\+: Buffer for the encrypted data (16 bytes) \end{DoxyCompactList}\item 
void \textbf{ aes\+\_\+encrypt\+\_\+deinit} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em aes\+\_\+encrypt\+\_\+deinit -\/ Deinitialize AES encryption @ctx\+: Context pointer from \doxyref{aes\+\_\+encrypt\+\_\+init()}{p.}{kdf_2crypto_8h_a343a371ec5ee6a3785da74796bb25bc4} \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
AES (Rijndael) cipher -\/ encrypt. 

Modifications to public domain implementation\+:
\begin{DoxyItemize}
\item support only 128-\/bit keys
\item cleanup
\item use C pre-\/processor to make it easier to change S table access
\item added option (AES\+\_\+\+SMALL\+\_\+\+TABLES) for reducing code size by about 8 kB at cost of reduced throughput (quite small difference on Pentium 4, 10-\/25\% when using -\/O1 or -\/O2 optimization) 
\end{DoxyItemize}

\doxysubsection{Macro Definition Documentation}
\mbox{\label{aes-internal-enc_8c_a6d21e787fe192f6b2bcbef74a38b1b70}} 
\index{aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}!ROUND@{ROUND}}
\index{ROUND@{ROUND}!aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}}
\doxysubsubsection{ROUND}
{\footnotesize\ttfamily \#define ROUND(\begin{DoxyParamCaption}\item[{}]{i,  }\item[{}]{d,  }\item[{}]{s }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{d\#\#0 = TE0(s\#\#0) \string^ TE1(s\#\#1) \string^ TE2(s\#\#2) \string^ TE3(s\#\#3) \string^ rk[4 * i]; \(\backslash\)}
\DoxyCodeLine{d\#\#1 = TE0(s\#\#1) \string^ TE1(s\#\#2) \string^ TE2(s\#\#3) \string^ TE3(s\#\#0) \string^ rk[4 * i + 1]; \(\backslash\)}
\DoxyCodeLine{d\#\#2 = TE0(s\#\#2) \string^ TE1(s\#\#3) \string^ TE2(s\#\#0) \string^ TE3(s\#\#1) \string^ rk[4 * i + 2]; \(\backslash\)}
\DoxyCodeLine{d\#\#3 = TE0(s\#\#3) \string^ TE1(s\#\#0) \string^ TE2(s\#\#1) \string^ TE3(s\#\#2) \string^ rk[4 * i + 3]}

\end{DoxyCode}


\doxysubsection{Function Documentation}
\mbox{\label{aes-internal-enc_8c_ab5d5144d5ff65df3a2141b61aa8cbbc5}} 
\index{aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}!aes\_encrypt@{aes\_encrypt}}
\index{aes\_encrypt@{aes\_encrypt}!aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}}
\doxysubsubsection{aes\_encrypt()}
{\footnotesize\ttfamily void aes\+\_\+encrypt (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const \textbf{ u8} $\ast$}]{plain,  }\item[{\textbf{ u8} $\ast$}]{crypt }\end{DoxyParamCaption})}



aes\+\_\+encrypt -\/ Encrypt one AES block @ctx\+: Context pointer from \doxyref{aes\+\_\+encrypt\+\_\+init()}{p.}{kdf_2crypto_8h_a343a371ec5ee6a3785da74796bb25bc4} @plain\+: Plaintext data to be encrypted (16 bytes) @crypt\+: Buffer for the encrypted data (16 bytes) 



References \textbf{ rijndael\+Encrypt()}.



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

\mbox{\label{aes-internal-enc_8c_a3de4d709c14b6f0801604d37fde3306a}} 
\index{aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}!aes\_encrypt\_deinit@{aes\_encrypt\_deinit}}
\index{aes\_encrypt\_deinit@{aes\_encrypt\_deinit}!aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}}
\doxysubsubsection{aes\_encrypt\_deinit()}
{\footnotesize\ttfamily void aes\+\_\+encrypt\+\_\+deinit (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



aes\+\_\+encrypt\+\_\+deinit -\/ Deinitialize AES encryption @ctx\+: Context pointer from \doxyref{aes\+\_\+encrypt\+\_\+init()}{p.}{kdf_2crypto_8h_a343a371ec5ee6a3785da74796bb25bc4} 



References \textbf{ AES\+\_\+\+PRIV\+\_\+\+SIZE}, \textbf{ os\+\_\+free}, and \textbf{ os\+\_\+memset}.



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

\mbox{\label{aes-internal-enc_8c_a343a371ec5ee6a3785da74796bb25bc4}} 
\index{aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}!aes\_encrypt\_init@{aes\_encrypt\_init}}
\index{aes\_encrypt\_init@{aes\_encrypt\_init}!aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}}
\doxysubsubsection{aes\_encrypt\_init()}
{\footnotesize\ttfamily void $\ast$ aes\+\_\+encrypt\+\_\+init (\begin{DoxyParamCaption}\item[{const \textbf{ u8} $\ast$}]{key,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})}



aes\+\_\+encrypt\+\_\+init -\/ Initialize AES for encryption @key\+: Encryption key @len\+: Key length in bytes (usually 16, i.\+e., 128 bits) Returns\+: Pointer to context data or NULL on failure 



References \textbf{ AES\+\_\+\+PRIV\+\_\+\+SIZE}, \textbf{ len}, \textbf{ os\+\_\+malloc}, and \textbf{ rijndael\+Key\+Setup\+Enc()}.



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

\mbox{\label{aes-internal-enc_8c_a4b1540fca1dc3dea646204be464984b2}} 
\index{aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}!rijndaelEncrypt@{rijndaelEncrypt}}
\index{rijndaelEncrypt@{rijndaelEncrypt}!aes-\/internal-\/enc.c@{aes-\/internal-\/enc.c}}
\doxysubsubsection{rijndaelEncrypt()}
{\footnotesize\ttfamily static void rijndael\+Encrypt (\begin{DoxyParamCaption}\item[{const \textbf{ u32}}]{rk[$\,$],  }\item[{const \textbf{ u8}}]{pt[16],  }\item[{\textbf{ u8}}]{ct[16] }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ GETU32}, \textbf{ PUTU32}, \textbf{ ROUND}, \textbf{ TE41}, \textbf{ TE42}, \textbf{ TE43}, and \textbf{ TE44}.



Referenced by \textbf{ aes\+\_\+encrypt()}.

