\hypertarget{aesencdec_8h_source}{}\doxysection{aesencdec.\+h}
\label{aesencdec_8h_source}\index{crypto/aesni/aesencdec.h@{crypto/aesni/aesencdec.h}}
\mbox{\hyperlink{aesencdec_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00002}00002 \textcolor{comment}{ * Copyright 2013 John-\/Mark Gurney <jmg@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00003}00003 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00004}00004 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00005}00005 \textcolor{comment}{ * Copyright 2015 Netflix, Inc.}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00027}00027 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00028}00028 \textcolor{comment}{ * \$FreeBSD\$}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00029}00029 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00030}00030 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00032}00032 \textcolor{preprocessor}{\#ifndef \_AESENCDEC\_H\_}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00033}00033 \textcolor{preprocessor}{\#define \_AESENCDEC\_H\_}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00035}00035 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{aesni__os_8h}{crypto/aesni/aesni\_os.h}}>}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00037}00037 \textcolor{preprocessor}{\#include <wmmintrin.h>}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00039}00039 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00040}\mbox{\hyperlink{aesencdec_8h_a1d58e25f1eda534e0f5602c5a40b6751}{00040}} \mbox{\hyperlink{aesencdec_8h_a1d58e25f1eda534e0f5602c5a40b6751}{aesni\_enc8}}(\textcolor{keywordtype}{int} rounds, \textcolor{keyword}{const} \_\_m128i *keysched, \_\_m128i a,}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00041}00041     \_\_m128i b, \_\_m128i c, \_\_m128i d, \_\_m128i e, \_\_m128i f, \_\_m128i g,}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00042}00042     \_\_m128i h, \_\_m128i out[8])}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00043}00043 \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00044}00044         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00045}00045 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00046}00046         a \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00047}00047         b \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00048}00048         c \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00049}00049         d \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00050}00050         e \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00051}00051         f \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00052}00052         g \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00053}00053         h \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00054}00054 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00055}00055         \textcolor{keywordflow}{for} (i = 0; i < rounds; i++) \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00056}00056                 a = \_mm\_aesenc\_si128(a, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00057}00057                 b = \_mm\_aesenc\_si128(b, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00058}00058                 c = \_mm\_aesenc\_si128(c, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00059}00059                 d = \_mm\_aesenc\_si128(d, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00060}00060                 e = \_mm\_aesenc\_si128(e, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00061}00061                 f = \_mm\_aesenc\_si128(f, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00062}00062                 g = \_mm\_aesenc\_si128(g, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00063}00063                 h = \_mm\_aesenc\_si128(h, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00064}00064         \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00065}00065 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00066}00066         out[0] = \_mm\_aesenclast\_si128(a, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00067}00067         out[1] = \_mm\_aesenclast\_si128(b, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00068}00068         out[2] = \_mm\_aesenclast\_si128(c, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00069}00069         out[3] = \_mm\_aesenclast\_si128(d, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00070}00070         out[4] = \_mm\_aesenclast\_si128(e, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00071}00071         out[5] = \_mm\_aesenclast\_si128(f, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00072}00072         out[6] = \_mm\_aesenclast\_si128(g, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00073}00073         out[7] = \_mm\_aesenclast\_si128(h, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00074}00074 \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00075}00075 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00076}00076 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00077}\mbox{\hyperlink{aesencdec_8h_ae9fa3de93108a370f3c9cf96c6327c48}{00077}} \mbox{\hyperlink{aesencdec_8h_ae9fa3de93108a370f3c9cf96c6327c48}{aesni\_dec8}}(\textcolor{keywordtype}{int} rounds, \textcolor{keyword}{const} \_\_m128i *keysched, \_\_m128i a,}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00078}00078     \_\_m128i b, \_\_m128i c, \_\_m128i d, \_\_m128i e, \_\_m128i f, \_\_m128i g,}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00079}00079     \_\_m128i h, \_\_m128i out[8])}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00080}00080 \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00081}00081         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00082}00082 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00083}00083         a \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00084}00084         b \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00085}00085         c \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00086}00086         d \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00087}00087         e \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00088}00088         f \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00089}00089         g \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00090}00090         h \string^= keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00091}00091 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00092}00092         \textcolor{keywordflow}{for} (i = 0; i < rounds; i++) \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00093}00093                 a = \_mm\_aesdec\_si128(a, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00094}00094                 b = \_mm\_aesdec\_si128(b, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00095}00095                 c = \_mm\_aesdec\_si128(c, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00096}00096                 d = \_mm\_aesdec\_si128(d, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00097}00097                 e = \_mm\_aesdec\_si128(e, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00098}00098                 f = \_mm\_aesdec\_si128(f, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00099}00099                 g = \_mm\_aesdec\_si128(g, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00100}00100                 h = \_mm\_aesdec\_si128(h, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00101}00101         \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00102}00102 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00103}00103         out[0] = \_mm\_aesdeclast\_si128(a, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00104}00104         out[1] = \_mm\_aesdeclast\_si128(b, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00105}00105         out[2] = \_mm\_aesdeclast\_si128(c, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00106}00106         out[3] = \_mm\_aesdeclast\_si128(d, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00107}00107         out[4] = \_mm\_aesdeclast\_si128(e, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00108}00108         out[5] = \_mm\_aesdeclast\_si128(f, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00109}00109         out[6] = \_mm\_aesdeclast\_si128(g, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00110}00110         out[7] = \_mm\_aesdeclast\_si128(h, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00111}00111 \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00112}00112 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00113}00113 \textcolor{comment}{/* rounds is passed in as rounds -\/ 1 */}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00114}00114 \textcolor{keyword}{static} \textcolor{keyword}{inline} \_\_m128i}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00115}\mbox{\hyperlink{aesencdec_8h_a6087a1bf3892050e3668922911feabd0}{00115}} \mbox{\hyperlink{aesencdec_8h_a6087a1bf3892050e3668922911feabd0}{aesni\_enc}}(\textcolor{keywordtype}{int} rounds, \textcolor{keyword}{const} \_\_m128i *keysched, \textcolor{keyword}{const} \_\_m128i from)}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00116}00116 \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00117}00117         \_\_m128i tmp;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00118}00118         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00119}00119 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00120}00120         tmp = from \string^ keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00121}00121         \textcolor{keywordflow}{for} (i = 1; i < rounds; i += 2) \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00122}00122                 tmp = \_mm\_aesenc\_si128(tmp, keysched[i]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00123}00123                 tmp = \_mm\_aesenc\_si128(tmp, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00124}00124         \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00125}00125 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00126}00126         tmp = \_mm\_aesenc\_si128(tmp, keysched[rounds]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00127}00127         \textcolor{keywordflow}{return} \_mm\_aesenclast\_si128(tmp, keysched[rounds + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00128}00128 \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00129}00129 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00130}00130 \textcolor{keyword}{static} \textcolor{keyword}{inline} \_\_m128i}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00131}\mbox{\hyperlink{aesencdec_8h_a0bbe215461ba264b18f3eed4da053230}{00131}} \mbox{\hyperlink{aesencdec_8h_a0bbe215461ba264b18f3eed4da053230}{aesni\_dec}}(\textcolor{keywordtype}{int} rounds, \textcolor{keyword}{const} \_\_m128i *keysched, \textcolor{keyword}{const} \_\_m128i from)}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00132}00132 \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00133}00133         \_\_m128i tmp;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00134}00134         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00135}00135 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00136}00136         tmp = from \string^ keysched[0];}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00137}00137 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00138}00138         \textcolor{keywordflow}{for} (i = 1; i < rounds; i += 2) \{}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00139}00139                 tmp = \_mm\_aesdec\_si128(tmp, keysched[i]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00140}00140                 tmp = \_mm\_aesdec\_si128(tmp, keysched[i + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00141}00141         \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00142}00142 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00143}00143         tmp = \_mm\_aesdec\_si128(tmp, keysched[rounds]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00144}00144         \textcolor{keywordflow}{return} \_mm\_aesdeclast\_si128(tmp, keysched[rounds + 1]);}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00145}00145 \}}
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00146}00146 }
\DoxyCodeLine{\Hypertarget{aesencdec_8h_source_l00147}00147 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* \_AESENCDEC\_H\_ */}\textcolor{preprocessor}{}}

\end{DoxyCode}
