\section{Part 5: Asymmetric Encryption}

\subsection{Generierte Primzahlen}

\begin{verbatim}
openssl prime -generate -bits 8
\end{verbatim}

\begin{verbatim}
prime1 = 211, prime2 = 223, e=11
\end{verbatim}

\subsection{Berechnungen}

\begin{align}
    d = e^{-1}\ mod\ ((prime1-1)(prime2-1)) \\
    d = 11^{-1}\ mod\ ((211-1)(223-1)) = 21191
\end{align}

\begin{verbatim}
g = 9, x = 2, y = 3, n = 227 (prime3)
\end{verbatim}

\begin{align}
    a = g^{x}\ (mod\ n) = 9^{2} (mod\ 227) = 81\ (public\ a) \\
    b = g^{y}\ (mod\ n) = 9^{3} (mod\ 227) = 48\ (public\ b) \\
    k_{1} = b^{x}\ (mod\ n) = 48^{2}\ (mod\ 227) = 34\ (private) \\
    k_{2} = a^{y}\ (mod\ n) = 81^{3}\ (mod\ 227) = 34\ (private) \\
    k = k_{1} = k_{2} = 34\ (private)
\end{align}

\newpage

\subsection{Fragen und Antworten}

1. What attack is the Diffie-Hellman key exchange vulnerable to?

\begin{list}{-}{}
    \item Man in the Middle
\end{list}

2. What measures can be taken to prevent this type of attack?

\begin{list}{-}{}
    \item Encrypting exchange (VPN)
    \item Signature verification
    \item Combine with RSA/AES
    \item Authentication at Server-Level over QR code or 2Factor-Authentication
\end{list}

3. For the Diffie-Hellman, a generator g is used. Explain what a generator is and how can it be found

\begin{list}{-}{}
    \item A generator is a number that will be the base of the calculation and is shared between the 2 parties
    \item G is a small prime number.
\end{list}

\begin{align}
    g^{a}\ (mod\ n) \neq g^{b}\ (mod\ n) \\
    g^{(a\ *\ b)}\ (mod\ n) = g^{(b\ *\ a)}\ (mod\ n)
\end{align}

4. Show why for the primes 61,23 and the public key e=60 no private key d can be found

\begin{align}
    d = e^{-1}\ mod\ ((p1-1)(p2-1)) \\
    d = 60^{-1}\ mod\ ((61-1)(23-1)) = 60^{-1} mod\ 1320
\end{align}