Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
Project: Math 314
Views: 11Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204\documentclass[12pt,letterpaper,final]{report}1\usepackage{amsmath}2\usepackage{amsfonts}3\usepackage{amssymb}4\usepackage{amsthm}5\usepackage[linewidth=1pt]{mdframed}6\usepackage{fullpage}7\usepackage{graphicx}8910\begin{document}1112\begin{mdframed}1314\center{\Large{\textbf{MATH 314 Fall 2024 - Class Notes}}}15\center{9/26/2024} %Put the date of the class here!16\center{Mark Alexander} %Put Your Name Here!1718\end{mdframed}1920\bigskip21\textbf{\underline{Summary:}} This class covered simplified AES (SAES) and SAES encryption up to the key expansion step.2223\bigskip\bigskip24\textbf{\underline{Advanced Encryption Standard (AES)}}2526\begin{itemize}27\item All the encryption happens in $\mathbb{F}_{256} = \mathbb{F}_{2^8}$28\item Permutation/Substitution network with 10 rounds, every round uses a different key all generated from a master key by key expansion29\item Confusion is produced using a single substitution box (S-box)30\end{itemize}3132\bigskip33\textbf{\underline{Simplified Advanced Encryption Standard (SAES)}}34\begin{itemize}35\item Uses $\mathbb{F}_{256} = \mathbb{F}_{2^4}$ instead36\item$\pmod{x^4+x+1}$37\item SAES S-box is a function $\mathbb{F}_{16} \rightarrow \mathbb{F}_{16}$, in other words, inputs 4 bits $\rightarrow$ outputs 4 bits38\item Formula: Treat input as a polynomial in $\mathbb{F}_{16}$, find its inverse. Takes this output and convert the bits to a vector $\vec{v}$:39$$40\begin{bmatrix}411 & 0 & 1 & 1\\421 & 1 & 0 & 1\\431 & 1 & 1 & 0\\440 & 1 & 1 & 1\\45\end{bmatrix}46\vec{v} +47\begin{bmatrix}481 \\490 \\500 \\511 \\52\end{bmatrix}53\rightarrow \text{output of S-box}54$$55\end{itemize}565758\bigskip59\textbf{\underline{Example:}} Compute the s-box value of \texttt{1010}6061\texttt{1010} evaluates to $1x^3+0x^2+1x+0$ as a polynomial, simplified as $x^3+x$6263\bigskip64The inverse of $x^3+x$ is then found using Euclid's algorithm for polynomials:6566\includegraphics[width=0.6\textwidth]{./IMG_7819.jpeg}6768\bigskip69\textbf{\underline{Note:}} AES (and SAES) are $\mathbb{F}_2[x]$, and are therefore mod 2, simply meaning all negatives become positive7071\bigskip72Long division is performed for all found remainders, where the divisor is divided by the last found remainder. This is performed until a remainder of 0 is found or the degree of the divisor is larger than the dividend.7374\bigskip75$(x^3+x) \div (x^2+x+1) = (x+1)\ R(x+1)$7677$(x^2+x+1) \div (x+1) = (x)\ R(1)$7879\bigskip80Thus, we have found:8182$(x^4+x+1)=x(x^3+x)+(x^2+x+1)$8384$(x^3+x)=(x+1)(x^2+x+1)+(x+1)$8586$(x^2+x+1)=x(x+1)+1$8788\bigskip89Using Extended Euclid's Algorithm:9091$(x^2+x+1)=(x^4+x+1)+x(x^3+x)$9293$(x+1)=(x^3+x)+(x+1)(x^2+x+1)$9495$1=(x^2+x+1)+x(x+1)$9697\bigskip98Finding the inverse of $x^3+x$:99100$1=(x^2+x+1)+x(x+1)$101102$1=(x^2+x+1)+x((x^3+x)+(x+1)(x^2+x+1))$103104$1=(x^2+x+1)+x(x^3+x)+(x^2+x)(x^2+x+1)$105106$1=(x^2+x+1)(x^2+x+1)+x(x^3+x)$107108$1=(x^2+x+1)((x^4+x+1)+x(x^3+x))+x(x^3+x)$109110$1=(x^2+x+1)(x^4+x+1)+(x^3+x^2+x)(x^3+x)+x(x^3+x)$111112$1=(x^2+x+1)(x^4+x+1)+(x^3+x^2)(x^3+x) \pmod{x^4+x+1}$113114$1=(x^3+x^2)(x^3+x) \pmod{x^4+x+1}$115116$(x^3+x)^{-1}=x^3+x^2 \pmod{x^4+x+1}$117118\bigskip119The inverse of $x^3+x$ is $x^3+x^2$ expressed in bits as \texttt{1100}120121\bigskip122To find the S-box value:123124\bigskip125$126\begin{bmatrix}1271 & 0 & 1 & 1\\1281 & 1 & 0 & 1\\1291 & 1 & 1 & 0\\1300 & 1 & 1 & 1\\131\end{bmatrix}132\begin{bmatrix}1331 \\1341 \\1350 \\1360 \\137\end{bmatrix} +138\begin{bmatrix}1391 \\1400 \\1410 \\1421 \\143\end{bmatrix} =144\begin{bmatrix}1450 \\1460 \\1470 \\1480 \\149\end{bmatrix}150$151152153\bigskip154The S-box value of \texttt{1010} is \texttt{0000}155156\bigskip\bigskip157\textbf{\underline{Using SAES:}}158\begin{itemize}159\item SAES performs 2 rounds160\item Utilizes a masterkey, plaintext, and ciphertext (all 16 bits)161\item The masterkey consists of two 8 bit words $(W_0, W_1)$162\item 2 "round keys" are needed, these are used for each round163\item The keys $k_1$ and $k_2$ are found using key expansion164\end{itemize}165166\bigskip167Key Expansion:168169$W_2 = W_0 \oplus g(W_1, 1)$170171$W_3 = W_1 \oplus W_2$172173$W_4 = W_2 \oplus g(W_3, 2)$174175$W_5 = W_3 \oplus W_4$176177\bigskip178The function $g(W, i)$ is found using:179\begin{figure}[h]180\includegraphics[width=0.6\textwidth]{./IMG_7825.jpg}181\end{figure}182183\bigskip\bigskip\bigskip184\textbf{\underline{SAES Encryption:}}185\begin{itemize}186\item Plaintext is 16 bits187\item Add master key188\end{itemize}189Round 1:190\begin{enumerate}191\item Substitute192\item Shift rows193\item Mix columns194\item Add round key 1195\end{enumerate}196Round 2:197\begin{enumerate}198\item Substitute199\item Shift rows200\item Add round key 2201\end{enumerate}202After round 2 the ciphertext is found.203204\bigskip\bigskip205206207\textbf{\underline{Breaking down the steps:}}208209\bigskip210Substitute Step211\begin{enumerate}212\item Break into 4 nibbles213\item Substitute into S-box214\item Write entries out in a matrix (fill out columns first)215\end{enumerate}216217\bigskip218Shift Rows219\begin{enumerate}220\item Leave top row unchanged221\item Swap entries in bottom row222\end{enumerate}223224\bigskip225Mix Columns226\begin{enumerate}227\item Take the matrix and multiply by encryption matrix228\item Add round key either by reading back to string of 1s and 0s or by converting the key into a matrix of nibbles.229\end{enumerate}230231\bigskip232\textbf{\underline{Example:}} Encrypt $P = 1011\ 1001\ 1110\ 0000$ with key, $k_0 = 1001\ 1111\ 0101\ 1000$233234\bigskip235Key expansion:236237$W_0 = 1001\ 1111$238239$W_1 = 0101\ 1000$240241\bigskip242$W_2 = W_0 \oplus g(W_1, 1)$243244\includegraphics[width=0.6\textwidth]{./IMG_7824.jpg}245246$W_2 = 1001\ 1111 \oplus 1110\ 0001 = 0111\ 1110$247248\bigskip249$W_3 = W_1 \oplus W_2$250251$W_3 = 0101\ 1000 \oplus 0111\ 1110 = 0010\ 0110$252253\bigskip254$W_4 = W_2 \oplus g(W_3, 2)$255256\includegraphics[width=0.6\textwidth]{./IMG_7823.jpg}257258$W_4 = 0111\ 1110 \oplus 1011\ 1010 = 1100\ 0100$259260\bigskip261$W_5 = W_3 \oplus W_4$262263$W_5 = 0010\ 0110 \oplus 1100\ 0100 = 1110\ 0010$264265\bigskip266$k_1 = 0111\ 1110\ 0010\ 0110$267268$k_2 = 1100\ 0100\ 1110\ 0010$269270\bigskip271Computing P + $k_0$ beings round 0:272273$P \oplus k_0 = 0010\ 0110\ 1011\ 1000$274275\bigskip276From here, round 1 and 2 occur using the computed P + $k_0$ following the steps for each round.277278\end{document}279280