\doxysection{aes\+\_\+i.\+h}
\label{aes__i_8h_source}\index{src/gsm/milenage/aes\_i.h@{src/gsm/milenage/aes\_i.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{3 \textcolor{comment}{/*}}
\DoxyCodeLine{4 \textcolor{comment}{ * Copyright (c) 2003-\/2005, Jouni Malinen <j@w1.fi>}}
\DoxyCodeLine{5 \textcolor{comment}{ *}}
\DoxyCodeLine{6 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{7 \textcolor{comment}{ * it under the terms of the GNU General Public License version 2 as}}
\DoxyCodeLine{8 \textcolor{comment}{ * published by the Free Software Foundation.}}
\DoxyCodeLine{9 \textcolor{comment}{ *}}
\DoxyCodeLine{10 \textcolor{comment}{ * Alternatively, this software may be distributed under the terms of BSD}}
\DoxyCodeLine{11 \textcolor{comment}{ * license.}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0 or BSD-\/3-\/Clause}}
\DoxyCodeLine{14 \textcolor{comment}{ *}}
\DoxyCodeLine{15 \textcolor{comment}{ * See README and COPYING for more details.}}
\DoxyCodeLine{16 \textcolor{comment}{ */}}
\DoxyCodeLine{17 }
\DoxyCodeLine{18 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{19 }
\DoxyCodeLine{20 \textcolor{preprocessor}{\#include "{}aes.h"{}}}
\DoxyCodeLine{21 }
\DoxyCodeLine{22 \textcolor{comment}{/* \#define FULL\_UNROLL */}}
\DoxyCodeLine{23 \textcolor{preprocessor}{\#define AES\_SMALL\_TABLES}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Te0[256];}
\DoxyCodeLine{26 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Te1[256];}
\DoxyCodeLine{27 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Te2[256];}
\DoxyCodeLine{28 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Te3[256];}
\DoxyCodeLine{29 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Te4[256];}
\DoxyCodeLine{30 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Td0[256];}
\DoxyCodeLine{31 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Td1[256];}
\DoxyCodeLine{32 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Td2[256];}
\DoxyCodeLine{33 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Td3[256];}
\DoxyCodeLine{34 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 Td4[256];}
\DoxyCodeLine{35 \textcolor{keyword}{extern} \textcolor{keyword}{const} u32 rcon[10];}
\DoxyCodeLine{36 \textcolor{keyword}{extern} \textcolor{keyword}{const} u8 Td4s[256];}
\DoxyCodeLine{37 \textcolor{keyword}{extern} \textcolor{keyword}{const} u8 rcons[10];}
\DoxyCodeLine{38 }
\DoxyCodeLine{39 \textcolor{preprocessor}{\#ifndef AES\_SMALL\_TABLES}}
\DoxyCodeLine{40 }
\DoxyCodeLine{41 \textcolor{preprocessor}{\#define RCON(i) rcon[(i)]}}
\DoxyCodeLine{42 }
\DoxyCodeLine{43 \textcolor{preprocessor}{\#define TE0(i) Te0[((i) >> 24) \& 0xff]}}
\DoxyCodeLine{44 \textcolor{preprocessor}{\#define TE1(i) Te1[((i) >> 16) \& 0xff]}}
\DoxyCodeLine{45 \textcolor{preprocessor}{\#define TE2(i) Te2[((i) >> 8) \& 0xff]}}
\DoxyCodeLine{46 \textcolor{preprocessor}{\#define TE3(i) Te3[(i) \& 0xff]}}
\DoxyCodeLine{47 \textcolor{preprocessor}{\#define TE41(i) (Te4[((i) >> 24) \& 0xff] \& 0xff000000)}}
\DoxyCodeLine{48 \textcolor{preprocessor}{\#define TE42(i) (Te4[((i) >> 16) \& 0xff] \& 0x00ff0000)}}
\DoxyCodeLine{49 \textcolor{preprocessor}{\#define TE43(i) (Te4[((i) >> 8) \& 0xff] \& 0x0000ff00)}}
\DoxyCodeLine{50 \textcolor{preprocessor}{\#define TE44(i) (Te4[(i) \& 0xff] \& 0x000000ff)}}
\DoxyCodeLine{51 \textcolor{preprocessor}{\#define TE421(i) (Te4[((i) >> 16) \& 0xff] \& 0xff000000)}}
\DoxyCodeLine{52 \textcolor{preprocessor}{\#define TE432(i) (Te4[((i) >> 8) \& 0xff] \& 0x00ff0000)}}
\DoxyCodeLine{53 \textcolor{preprocessor}{\#define TE443(i) (Te4[(i) \& 0xff] \& 0x0000ff00)}}
\DoxyCodeLine{54 \textcolor{preprocessor}{\#define TE414(i) (Te4[((i) >> 24) \& 0xff] \& 0x000000ff)}}
\DoxyCodeLine{55 \textcolor{preprocessor}{\#define TE4(i) (Te4[(i)] \& 0x000000ff)}}
\DoxyCodeLine{56 }
\DoxyCodeLine{57 \textcolor{preprocessor}{\#define TD0(i) Td0[((i) >> 24) \& 0xff]}}
\DoxyCodeLine{58 \textcolor{preprocessor}{\#define TD1(i) Td1[((i) >> 16) \& 0xff]}}
\DoxyCodeLine{59 \textcolor{preprocessor}{\#define TD2(i) Td2[((i) >> 8) \& 0xff]}}
\DoxyCodeLine{60 \textcolor{preprocessor}{\#define TD3(i) Td3[(i) \& 0xff]}}
\DoxyCodeLine{61 \textcolor{preprocessor}{\#define TD41(i) (Td4[((i) >> 24) \& 0xff] \& 0xff000000)}}
\DoxyCodeLine{62 \textcolor{preprocessor}{\#define TD42(i) (Td4[((i) >> 16) \& 0xff] \& 0x00ff0000)}}
\DoxyCodeLine{63 \textcolor{preprocessor}{\#define TD43(i) (Td4[((i) >> 8) \& 0xff] \& 0x0000ff00)}}
\DoxyCodeLine{64 \textcolor{preprocessor}{\#define TD44(i) (Td4[(i) \& 0xff] \& 0x000000ff)}}
\DoxyCodeLine{65 \textcolor{preprocessor}{\#define TD0\_(i) Td0[(i) \& 0xff]}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\#define TD1\_(i) Td1[(i) \& 0xff]}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#define TD2\_(i) Td2[(i) \& 0xff]}}
\DoxyCodeLine{68 \textcolor{preprocessor}{\#define TD3\_(i) Td3[(i) \& 0xff]}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{preprocessor}{\#else }\textcolor{comment}{/* AES\_SMALL\_TABLES */}\textcolor{preprocessor}{}}
\DoxyCodeLine{71 }
\DoxyCodeLine{72 \textcolor{preprocessor}{\#define RCON(i) ((u32)rcons[(i)] << 24)}}
\DoxyCodeLine{73 }
\DoxyCodeLine{74 \textcolor{keyword}{static} \textcolor{keyword}{inline} u32 rotr(u32 val, \textcolor{keywordtype}{int} bits)}
\DoxyCodeLine{75 \{}
\DoxyCodeLine{76         \textcolor{keywordflow}{return} (val >> bits) | (val << (32 -\/ bits));}
\DoxyCodeLine{77 \}}
\DoxyCodeLine{78 }
\DoxyCodeLine{79 \textcolor{preprocessor}{\#define TE0(i) Te0[((i) >> 24) \& 0xff]}}
\DoxyCodeLine{80 \textcolor{preprocessor}{\#define TE1(i) rotr(Te0[((i) >> 16) \& 0xff], 8)}}
\DoxyCodeLine{81 \textcolor{preprocessor}{\#define TE2(i) rotr(Te0[((i) >> 8) \& 0xff], 16)}}
\DoxyCodeLine{82 \textcolor{preprocessor}{\#define TE3(i) rotr(Te0[(i) \& 0xff], 24)}}
\DoxyCodeLine{83 \textcolor{preprocessor}{\#define TE41(i) ((Te0[((i) >> 24) \& 0xff] << 8) \& 0xff000000)}}
\DoxyCodeLine{84 \textcolor{preprocessor}{\#define TE42(i) (Te0[((i) >> 16) \& 0xff] \& 0x00ff0000)}}
\DoxyCodeLine{85 \textcolor{preprocessor}{\#define TE43(i) (Te0[((i) >> 8) \& 0xff] \& 0x0000ff00)}}
\DoxyCodeLine{86 \textcolor{preprocessor}{\#define TE44(i) ((Te0[(i) \& 0xff] >> 8) \& 0x000000ff)}}
\DoxyCodeLine{87 \textcolor{preprocessor}{\#define TE421(i) ((Te0[((i) >> 16) \& 0xff] << 8) \& 0xff000000)}}
\DoxyCodeLine{88 \textcolor{preprocessor}{\#define TE432(i) (Te0[((i) >> 8) \& 0xff] \& 0x00ff0000)}}
\DoxyCodeLine{89 \textcolor{preprocessor}{\#define TE443(i) (Te0[(i) \& 0xff] \& 0x0000ff00)}}
\DoxyCodeLine{90 \textcolor{preprocessor}{\#define TE414(i) ((Te0[((i) >> 24) \& 0xff] >> 8) \& 0x000000ff)}}
\DoxyCodeLine{91 \textcolor{preprocessor}{\#define TE4(i) ((Te0[(i)] >> 8) \& 0x000000ff)}}
\DoxyCodeLine{92 }
\DoxyCodeLine{93 \textcolor{preprocessor}{\#define TD0(i) Td0[((i) >> 24) \& 0xff]}}
\DoxyCodeLine{94 \textcolor{preprocessor}{\#define TD1(i) rotr(Td0[((i) >> 16) \& 0xff], 8)}}
\DoxyCodeLine{95 \textcolor{preprocessor}{\#define TD2(i) rotr(Td0[((i) >> 8) \& 0xff], 16)}}
\DoxyCodeLine{96 \textcolor{preprocessor}{\#define TD3(i) rotr(Td0[(i) \& 0xff], 24)}}
\DoxyCodeLine{97 \textcolor{preprocessor}{\#define TD41(i) (Td4s[((i) >> 24) \& 0xff] << 24)}}
\DoxyCodeLine{98 \textcolor{preprocessor}{\#define TD42(i) (Td4s[((i) >> 16) \& 0xff] << 16)}}
\DoxyCodeLine{99 \textcolor{preprocessor}{\#define TD43(i) (Td4s[((i) >> 8) \& 0xff] << 8)}}
\DoxyCodeLine{100 \textcolor{preprocessor}{\#define TD44(i) (Td4s[(i) \& 0xff])}}
\DoxyCodeLine{101 \textcolor{preprocessor}{\#define TD0\_(i) Td0[(i) \& 0xff]}}
\DoxyCodeLine{102 \textcolor{preprocessor}{\#define TD1\_(i) rotr(Td0[(i) \& 0xff], 8)}}
\DoxyCodeLine{103 \textcolor{preprocessor}{\#define TD2\_(i) rotr(Td0[(i) \& 0xff], 16)}}
\DoxyCodeLine{104 \textcolor{preprocessor}{\#define TD3\_(i) rotr(Td0[(i) \& 0xff], 24)}}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* AES\_SMALL\_TABLES */}\textcolor{preprocessor}{}}
\DoxyCodeLine{107 }
\DoxyCodeLine{108 \textcolor{preprocessor}{\#ifdef \_MSC\_VER}}
\DoxyCodeLine{109 \textcolor{preprocessor}{\#define SWAP(x) (\_lrotl(x, 8) \& 0x00ff00ff | \_lrotr(x, 8) \& 0xff00ff00)}}
\DoxyCodeLine{110 \textcolor{preprocessor}{\#define GETU32(p) SWAP(*((u32 *)(p)))}}
\DoxyCodeLine{111 \textcolor{preprocessor}{\#define PUTU32(ct, st) \{ *((u32 *)(ct)) = SWAP((st)); \}}}
\DoxyCodeLine{112 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{113 \textcolor{preprocessor}{\#define GETU32(pt) (((u32)(pt)[0] << 24) \string^ ((u32)(pt)[1] << 16) \string^ \(\backslash\)}}
\DoxyCodeLine{114 \textcolor{preprocessor}{((u32)(pt)[2] <<  8) \string^ ((u32)(pt)[3]))}}
\DoxyCodeLine{115 \textcolor{preprocessor}{\#define PUTU32(ct, st) \{ \(\backslash\)}}
\DoxyCodeLine{116 \textcolor{preprocessor}{(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \(\backslash\)}}
\DoxyCodeLine{117 \textcolor{preprocessor}{(ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); \}}}
\DoxyCodeLine{118 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{119 }
\DoxyCodeLine{120 \textcolor{preprocessor}{\#define AES\_PRIV\_SIZE (4 * 44)}}
\DoxyCodeLine{121 }
\DoxyCodeLine{122 \textcolor{keywordtype}{void} rijndaelKeySetupEnc(u32 rk[\textcolor{comment}{/*44*/}], \textcolor{keyword}{const} u8 cipherKey[]);}

\end{DoxyCode}
