From dc7f8c16c4923a2104a901ed9df642ea75003894 Mon Sep 17 00:00:00 2001 From: wieerwill Date: Thu, 2 Dec 2021 10:13:37 +0100 Subject: [PATCH] translate to english --- Network Security.md | 923 ++++++++++++++++++++++---------------------- 1 file changed, 462 insertions(+), 461 deletions(-) diff --git a/Network Security.md b/Network Security.md index 44a8bc4..af696c4 100644 --- a/Network Security.md +++ b/Network Security.md @@ -35,25 +35,25 @@ - [KASUMI](#kasumi) - [KASUMI - Sicherheitsdiskussion](#kasumi---sicherheitsdiskussion) - [Asymmetrische Kryptographie](#asymmetrische-kryptographie) - - [Some Mathematical Background](#some-mathematical-background) - - [The RSA Public Key Algorithm](#the-rsa-public-key-algorithm) - - [Some More Mathematical Background](#some-more-mathematical-background) - - [Diffie-Hellman Key Exchange](#diffie-hellman-key-exchange) - - [The ElGamal Algorithm](#the-elgamal-algorithm) - - [Elliptic Curve Cryptography](#elliptic-curve-cryptography) - - [Foundations of ECC - Group Elements](#foundations-of-ecc---group-elements) - - [Foundations of ECC - Point Addition](#foundations-of-ecc---point-addition) - - [Foundations of ECC - Algebraic Addition](#foundations-of-ecc---algebraic-addition) - - [Foundations of ECC - Multiplication](#foundations-of-ecc---multiplication) - - [Foundations of ECC - Curves over $\mathbb{Z}_p$](#foundations-of-ecc---curves-over-mathbbz_p) - - [Foundations of ECC - Calculate the y-values in $\mathbb{Z}_p$](#foundations-of-ecc---calculate-the-y-values-in-mathbbz_p) - - [Foundations of ECC - Addition and Multiplication in $\mathbb{Z}_p$](#foundations-of-ecc---addition-and-multiplication-in-mathbbz_p) - - [Foundations of ECC - Size of generated groups](#foundations-of-ecc---size-of-generated-groups) - - [Foundations of ECC - ECDH](#foundations-of-ecc---ecdh) - - [Foundations of ECC - EC version of ElGamal Algorithm](#foundations-of-ecc---ec-version-of-elgamal-algorithm) - - [Foundations of ECC - Security](#foundations-of-ecc---security) - - [Foundations of ECC - Further remarks](#foundations-of-ecc---further-remarks) - - [Conclusion](#conclusion) + - [Einige mathematische Hintergründe](#einige-mathematische-hintergründe) + - [Der RSA Public Key Algorithmus](#der-rsa-public-key-algorithmus) + - [Einige weitere mathematische Hintergründe](#einige-weitere-mathematische-hintergründe) + - [Diffie-Hellman-Schlüsselaustausch](#diffie-hellman-schlüsselaustausch) + - [ElGamal Algorithmus](#elgamal-algorithmus) + - [Elliptische Kurven Kryptographie](#elliptische-kurven-kryptographie) + - [Gruppenelemente](#gruppenelemente) + - [Punktaddition](#punktaddition) + - [Grundlagen des ECC - Algebraische Addition](#grundlagen-des-ecc---algebraische-addition) + - [Multiplikation](#multiplikation) + - [Kurven über $\mathbb{Z}_p$](#kurven-über-mathbbz_p) + - [Berechnen Sie die y-Werte in $\mathbb{Z}_p$](#berechnen-sie-die-y-werte-in-mathbbz_p) + - [Addition und Multiplikation in $\mathbb{Z}_p$](#addition-und-multiplikation-in-mathbbz_p) + - [Foundations of ECC - Größe der erzeugten Gruppen](#foundations-of-ecc---größe-der-erzeugten-gruppen) + - [ECDH](#ecdh) + - [EC-Version des ElGamal-Algorithmus](#ec-version-des-elgamal-algorithmus) + - [Sicherheit](#sicherheit) + - [Weitere Anmerkungen](#weitere-anmerkungen) + - [Schlussfolgerung](#schlussfolgerung) - [Modifikationsprüfwerte](#modifikationsprüfwerte) - [Zufallszahlengenerierung](#zufallszahlengenerierung) - [Kryptographische Protokolle](#kryptographische-protokolle) @@ -716,508 +716,509 @@ Standardisierte AES-Konfigurationen - Aber auch anfällig für verwandte Schlüsselangriffe [KY11]. # Asymmetrische Kryptographie -,,However, prior exposure to discrete mathematics will help the reader to appreciate the concepts presented here.'' E. Amoroso in another context [Amo94] +Eine vorherige Beschäftigung mit der diskreten Mathematik wird dem Leser jedoch helfen, die hier vorgestellten Konzepte zu verstehen.'' E. Amoroso in einem anderen Zusammenhang [Amo94] -- General idea: - - Use two different keys $-K$ and $+K$ for encryption and decryption - - Given a random ciphertext $c=E(+K, m)$ and $+K$ it should be infeasible to compute $m = D(-K, c) = D(-K, E(+K, m))$ - - This implies that it should be infeasible to compute $-K$ when given $+K$ - - The key $-K$ is only known to one entity A and is called A’s private key $-K_A$ - - The key $+K$ can be publicly announced and is called A’s public key $+K_A$ -- Applications: - - Encryption: - - If B encrypts a message with A’s public key $+K_A$, he can be sure that only A can decrypt it using $-K_A$ - - Signing: - - If A encrypts a message with his own private key $-K_A$, everyone can verify this signature by decrypting it with A’s public key $+K_A$ - - Attention: It is crucial, that everyone can verify that he really knows A’s public key and not the key of an adversary! -- Design of asymmetric cryptosystems: - - Difficulty: Find an algorithm and a method to construct two keys $-K$, $+K$ such that it is not possible to decipher $E(+K, m)$ with the knowledge of $+K$ - - Constraints: - - The key length should be ,,manageable'' - - Encrypted messages should not be arbitrarily longer than unencrypted messages (we would tolerate a small constant factor) - - Encryption and decryption should not consume too much resources (time, memory) - - Basic idea: Take a problem in the area of mathematics / computer science, that is hard to solve when knowing only $+K$, but easy to solve when knowing $-K$ - - Knapsack problems: basis of first working algorithms, which were unfortunately almost all proven to be insecure - - Factorization problem: basis of the RSA algorithm - - Discrete logarithm problem: basis of Diffie-Hellman and ElGamal +- Allgemeine Idee: + - Verwenden Sie zwei verschiedene Schlüssel $-K$ und $+K$ für die Ver- und Entschlüsselung + - Bei einem zufälligen Chiffretext $c=E(+K, m)$ und $+K$ sollte es nicht möglich sein, $m = D(-K, c) = D(-K, E(+K, m))$ zu berechnen. + - Dies impliziert, dass die Berechnung von $-K$ bei $+K$ nicht möglich sein sollte. + - Der Schlüssel $-K$ ist nur einer Entität A bekannt und wird A's privater Schlüssel $-K_A$ genannt + - Der Schlüssel $+K$ kann öffentlich bekannt gegeben werden und wird A's öffentlicher Schlüssel $+K_A$ genannt +- Anwendungen: + - Verschlüsselung: + - Wenn B eine Nachricht mit dem öffentlichen Schlüssel $+K_A$ von A verschlüsselt, kann er sicher sein, dass nur A sie mit $-K_A$ entschlüsseln kann. + - Signieren: + - Wenn A eine Nachricht mit seinem eigenen privaten Schlüssel $-K_A$ verschlüsselt, kann jeder diese Signatur verifizieren, indem er sie mit A's öffentlichem Schlüssel $+K_A$ entschlüsselt + - Achtung! Entscheidend ist, dass jeder nachprüfen kann, dass er wirklich den öffentlichen Schlüssel von A kennt und nicht den Schlüssel eines Gegners! +- Entwurf von asymmetrischen Kryptosystemen: + - Schwierigkeit: Finde einen Algorithmus und eine Methode, zwei Schlüssel $-K$, $+K$ so zu konstruieren, dass es nicht möglich ist, $E(+K, m)$ mit der Kenntnis von $+K$ zu entschlüsseln + - Beschränkungen: + - Die Schlüssellänge sollte ,,überschaubar'' sein + - Verschlüsselte Nachrichten sollten nicht beliebig länger sein als unverschlüsselte Nachrichten (wir würden einen kleinen konstanten Faktor tolerieren) + - Ver- und Entschlüsselung sollten nicht zu viele Ressourcen verbrauchen (Zeit, Speicher) + - Grundlegende Idee: Man nehme ein Problem aus dem Bereich der Mathematik/Informatik, das schwer zu lösen ist, wenn man nur $+K$ kennt, aber leicht zu lösen, wenn man $-K$ kennt + - Knapsack-Probleme: Grundlage der ersten funktionierenden Algorithmen, die sich leider fast alle als unsicher erwiesen haben + - Faktorisierungsproblem: Grundlage des RSA-Algorithmus + - Diskreter-Logarithmus-Problem: Grundlage von Diffie-Hellman und ElGamal -## Some Mathematical Background -- Let $\mathbb{Z}$ be the number of integers, and $a,b,n\in\mathbb{Z}$ -- We say $a$ divides $b(,,a|b'')$ if there exists an integer $k\in\mathbb{Z}$ such that $a\times k=b$ -- We say $a$ is prime if it is positive and the only divisors of a are $1$ and $a$ -- We say $r$ is the remainder of a divided by $n$ if $r=a-\lfloor a / n \rfloor\times n$ where $\lfloor x\rfloor$ denotes the largest integer less than or equal to $x$ - - Example: 4 is the remainder of 11 divided by 7 as $4=11-\lfloor 11/7\rfloor\times 7$ - - We can write this in another way: $a=q\times n + r$ with $q=\lfloor a/n\rfloor$ -- For the remainder $r$ of the division of a by n we write $a\ MOD\ n$ -- We say b is congruent $a\ mod\ n$ if it has the same remainder like a when divided by n. So, n divides $(a-b)$, and we write $b\equiv a\ mod\ n$ - - Examples: $4\equiv 11\ mod\ 7$, $25\equiv 11\ mod\ 7$, $11\equiv 25\ mod\ 7$, $11\equiv 4\ mod\ 7$, $-10\equiv 4\ mod\ 7$ -- As the remainder r of division by n is always smaller than n , we sometimes represent the set $\{x\ MOD\ n | x\in\mathbb{Z}\}$ by elements of the set $\mathbb{Z}_n=\{0, 1, ..., n-1\}$ +## Einige mathematische Hintergründe +- Sei $\mathbb{Z}$ die Menge der ganzen Zahlen, und $a,b,n\in\mathbb{Z}$ +- Wir sagen, $a$ teilt $b(,,a|b'')$, wenn es eine ganze Zahl $k\in\mathbb{Z}$ gibt, so dass $a\mal k=b$ +- $a$ ist prim, wenn es positiv ist und die einzigen Teiler von a $1$ und $a$ sind. +- $r$ ist der Rest von a geteilt durch $n$, wenn $r=a-\lfloor a / n \rfloor\times n$, wobei $\lfloor x\rfloor$ die größte ganze Zahl kleiner oder gleich $x$ ist. + - Beispiel: 4 ist der Rest von 11 geteilt durch 7 als $4=11-\lfloor 11/7\rfloor\times 7$ + - Wir können dies auch anders schreiben: $a=q\mal n + r$ mit $q=\lfloor a/n\rfloor$ +- Für den Rest $r$ der Division von a durch n schreiben wir $a\ MOD\ n$ +- Wir sagen, b ist kongruent $a\ mod\ n$, wenn es bei der Division durch n den gleichen Rest wie a hat. Also teilt n $(a-b)$, und wir schreiben $b\equiv a\ mod\ n$ + - Beispiele: $4\equiv 11\ mod\ 7$, $25\equiv 11\ mod\ 7$, $11\equiv 25\ mod\ 7$, $11\equiv 4\ mod\ 7$, $-10\equiv 4\ mod\ 7$ +- Da der Rest r der Division durch n immer kleiner als n ist, stellt man manchmal die Menge $\{x\ MOD\ n | x\in\mathbb{Z}\}$ durch Elemente der Menge $\mathbb{Z}_n=\{0, 1, ..., n-1\}$ dar -| Property | Expression | +| Eigenschaft | Ausdruck | | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -| Commutative Laws | $(a + b)\ MOD\ n = (b + a)\ MOD\ n$ | +| Kommutativgesetze + | $(a + b)\ MOD\ n = (b + a)\ MOD\ n$ | | $(a \times b)\ MOD\ n = (b \times a)\ MOD\ n$ | -| Associative Laws | $[(a + b) + c]\ MOD\ n = [a + (b + c)]\ MOD\ n$ | +| Assoziativgesetze | $[(a + b) + c]\ MOD\ n = [a + (b + c)]\ MOD\ n$ | | $[(a \times b) \times c]\ MOD\ n = [a \times (b \times c)]\ MOD\ n$ | -| Distributive Law | $[a \times (b + c)]\ MOD\ n = [(a \times b) + (a \times c)]\ MOD\ n$ | -| Identities | $(0 + a)\ MOD\ n = a\ MOD\ n$ | +| Distributivgesetz | $[a \times (b + c)]\ MOD\ n = [(a \times b) + (a \times c)]\ MOD\ n$ | +| Identitäten | $(0 + a)\ MOD\ n = a\ MOD\ n$ | | $(1 \times a)\ MOD\ n = a\ MOD\ n$ | -| Inverses | $\forall a \in \mathbb{Z}n: \exists (-a) \in \mathbb{Z}n : a + (-a) \equiv 0\ mod\ n$ | +| Inverse | $\forall a \in \mathbb{Z}n: \exists (-a) \in \mathbb{Z}n : a + (-a) \equiv 0\ mod\ n$ | | $p is prime \Rightarrow \forall a \in \mathbb{Z}p: \exists (a-1) \in \mathbb{Z}p: a \times (a-1) \equiv 1\ mod\ p$ | -Greatest common divisor -- $c = gcd(a, b) :\Leftrightarrow ( c | a) \wedge ( c | b) \wedge [\forall d: ( d | a ) \wedge ( d | b) \Rightarrow ( d | c )]$ and $gcd(a, 0 ) : = | a |$ -- The gcd recursion theorem : - - $\forall a, b \in \mathbb{Z}^+: gcd(a, b) = gcd(b, a\ MOD\ b)$ - - Proof: - - As $gcd(a, b)$ divides both a and b it also divides any linear combination of them, especially $(a- \lfloor a / b \rfloor \times b) = a\ MOD\ b$, so $gcd(a, b) | gcd(b, a\ MOD\ b)$ - - As $gcd(b, a\ MOD\ b)$ divides both b and $a\ MOD\ b$ it also divides any linear combination of them, especially $\lfloor a / b \rfloor \times b + (a\ MOD\ b) = a$, so $gcd(b, a\ MOD\ b) | gcd(a, b)$ -- Euclidean Algorithm: - - The algorithm Euclid given a, b computes $gcd(a, b)$ +Größter gemeinsamer Teiler +- $c = gcd(a, b) :\Leftrightarrow ( c | a) \wedge ( c | b) \wedge [\forall d: ( d | a ) \wedge ( d | b) \Rightarrow ( d | c )]$ und $gcd(a, 0 ) : = | a |$ +- Der gcd-Rekursionssatz : + - $\für alle a, b \in \mathbb{Z}^+: gcd(a, b) = gcd(b, a\ MOD\ b)$ + - Beweis: + - Da $gcd(a, b)$ sowohl a als auch b teilt, teilt es auch jede Linearkombination von ihnen, insbesondere $(a- \lfloor a / b \rfloor \times b) = a\ MOD\ b$, also $gcd(a, b) | gcd(b, a\ MOD\ b)$ + - Da $gcd(b, a\ MOD\ b)$ sowohl b als auch $a\ MOD\ b$ teilt, teilt es auch jede Linearkombination von beiden, insbesondere $\lfloor a / b \rfloor \times b + (a\ MOD\ b) = a$, also $gcd(b, a\ MOD\ b) | gcd(a, b)$ +- Euklidischer Algorithmus: + - Der euklidische Algorithmus berechnet aus a, b $gcd(a, b)$ ```cpp int Euclid(int a, b){ if (b = 0) { return(a); } {return(Euclid(b, a\ MOD\ b);} } ``` -- Extended Euclidean Algorithm: - - The algorithm ExtendedEuclid given a, b computes d, m, n such that: $d = gcd(a, b) = m \times a + n \times b$ +- Erweiterter euklidischer Algorithmus: + - Der Algorithmus ExtendedEuclid berechnet für a, b d, m, n so, dass: $d = gcd(a, b) = m \times a + n \times b$ ```cpp struct{int d, m, n} ExtendedEuclid(int a, b) - { int d, d’, m, m’, n, n’; + { int d, d', m, m', n, n'; if (b = 0) {return(a, 1, 0); } - (d’, m’, n’) = ExtendedEuclid(b, a MOD b); - (d, m, n) = (d’, n’, m’ - \lfloor a / b \rfloor \times n’); + (d', m', n') = ExtendedEuclid(b, a MOD b); + (d, m, n) = (d', n', m' - \lfloor a / b \rfloor \times n'); return(d, m, n); } ``` - - Proof: (by induction) - - Basic case $(a,0): gcd(a, 0) = a = 1 \times a + 0 \times 0$ - - Induction from $(b, a\ MOD\ b)$ to $(a, b)$: - - ExtendedEuclid computes $d’, m’, n’$ correctly (induction hypothesis) - - $d=d’=m’\times b+n’\times (a\ MOD\ b)=m’\times b+n’\times(a-\lfloor a/b\rfloor\times b)=n’\times a+(m’-\lfloor a/b\rfloor\times n’)\times b$ - - The run time of $Euclid(a, b)$ and $ExtendedEuclid(a, b)$ is of $O(log\ b)$ - - Proof: see [Cor90a], section 33. - - Lemma 1: Let $a,b\in\mathbb{N}$ and $d=gcd(a,b)$. Then there exists $m,n\in\mathbb{N}$ such that: $d=m\times a+n \times b$ -- Theorem 1 (Euclid): If a prime divides the product of two integers, then it divides at least one of the integers: $p|(a\times b)\Rightarrow (p|a) \vee (p|b)$ - - Proof: Let $p|(a\times b)$ - - If $p|a$ then we are done. - - If not then $gcd(p,a) = 1 \Rightarrow\exists m, n\in\mathbb{N}:1=m\times p+n\times a \Leftrightarrow b=m\times p \times b + n \times a \times b$ - - As $p|(a\times b)$, p divides both summands of the equation and so it divides also the sum which is b -- Theorem 2 (fundamental theorem of arithmetic): Factorization into primes is unique up to order. - - Proof: - - We will show that every integer with a non-unique factorization has a proper divisor with a non-unique factorization which leads to a clear contradiction when we finally have reduced to a prime number. - - Let’s assume that n is an integer with a non-unique factorization: $n=p_1\times p_2\times ...\times p_r=q_1 \times q_2\times ... \times q_s$. The primes are not necessarily distinct, but the second factorization is not simply a reordering of the first one. As $p_1$ divides n it also divides the product $q_1\times q_2\times ... \times q_s$. By repeated application of Theorem 1 we show that there is at least one $q_i$ which is divisible by $p_1$. If necessary reorder the $q_i$’s so that it is $q_1$. As both $p_1$ and $q_1$ are prime they have to be equal. So we can divide by $p_1$ and we have that $n/p_1$ has a non-unique factorization. - - We will use Theorem 2 to prove the following Corollary 1 - - If $gcd(c,m)=1$ and $(a\times c)\equiv(b\times c)mod\ m$, then $a\equiv b\ mod\ m$ - - Proof: As $(a\times c)\equiv(b\times c)mod\ m\Rightarrow\exists n\in\mathbb{N}:(a\times c)-(b\times c)=n\times m$ - - $\Leftrightarrow ( a - b ) \times c = n \times m$ - - $\Leftrightarrow p_1\times ...\times p_i\times q_1\times ...\times q_j=r_1\times ...\times r_k\times s_1\times ...\times s_l$ - - Please note that the $p$’s, $q$’s, $r$’s and $s$’s are prime and do not need to be distinct, but as $gcd(c,m)=1$, there are no indices g, h such that $q_g = s_h$. - - So we can continuously divide the equation by all q’s without ever ,,eliminating'' one $s$ and will finally end up with something like $\Leftrightarrow p_1\times ...\times p_i=r_1\times ...\times r_o\times s_1\times ...\times s_l$ (note that there will be fewer r’s) - - $\Leftrightarrow(a-b)=r_1\times ...\times r_o\times m\Rightarrow a \equiv b\ mod\ m$ - - Let $\phi(n)$ denote the number of positive integers less than n and relatively prime to n - - Examples: $\phi(4) = 2$, \phi(6)=2$, $\phi(7)=6$, $\phi(15)=8$ - - If p is prime $\Rightarrow\phi(p)=p-1$ -- Theorem 3 (Euler): Let n and b be positive and relatively prime integers, i.e. $gcd(n, b) = 1 \Rightarrow b \phi(n) \equiv 1\ mod\ n$ - - Proof: - - Let $t=\phi(n)$ and $a_1,...a_t$ be the positive integers less than $n$ which are relatively prime to $n$. Define $r_1,...,r_t$ to be the residues of $b\times a_1\ mod\ n , ..., b\times a_t\ mod\ n$ that is to say: $b\times a_i \equiv r_i\ mod\ n$. - - Note that $i\not= j \Rightarrow r_i\not= r_j$. If this would not hold, we would have $b\times a_i\equiv b\times a_j\ mod\ n$ and as $gcd(b,n)=1$, Corollary 1 would imply $a_i\equiv a_j\ mod\ n$ which can not be as $a_i$ and $a_j$ are by definition distinct integers between 0 and n - - We also know that each $r_i$ is relatively prime to n because any common divisor k of $r_i$ and $n$ , i.e. $n=k\times m$ and $r_i=p_i\times k$, would also have to divide $a_i$, - - as $b\times a_i\equiv (p_i\times k)\ mod\ (k\times m)\Rightarrow\exists s\in\mathbb{N}:(b\times a_i)-(p_i\times k)=s\times k\times m \Leftrightarrow (b\times a_i)=s\times k\times m+(p_i\times k)$ - - Because k divides each of the summands on the right-hand side and k does not divide b by assumption (n and b are relatively prime), it would also have to divide $a_i$ which is supposed to be relatively prime to n - - Thus $r_1, ...,r_t$ is a set of $\phi(n)$ distinct integers which are relatively prime to $n$. This means that they are exactly the same as $a_1,...a_t$, except that they are in a different order. In particular, we know that $r_1\times...\times r_t=a_1\times...\times a_t$ - - We now use the congruence $r_1\times...\times r_t\equiv b\times a_1\times...\times b\times a_t\ mod\ n$ - $\Leftrightarrow r_1\times...\times r_t\equiv b_t\times a_1\times...\times a_t\ mod\ n$ - $\Leftrightarrow r_1\times...\times r_t\equiv b_t\times r_1\times...\times r_t\ mod\ n$ - - As all $r_i$ are relatively prime to $n$ we can use Corollary 1 and divide by their product giving: $1\equiv b_t\ mod\ n \Leftrightarrow 1\equiv b\phi(n)\ mod n$ -- Theorem 4 (Chinese Remainder Theorem): - - Let $m_1,...,m_r$ be positive integers that are pairwise relatively prime, - - i.e. $\forall i\not= j:gcd(m_i, m_j) = 1$. Let $a_1,...,a_r$ be arbitrary integers. - - Then there exists an integer a such that: + - Beweis: (durch Induktion) + - Grundfall $(a,0): gcd(a, 0) = a = 1 \Zeiten a + 0 \Zeiten 0$ + - Induktion von $(b, a\ MOD\ b)$ auf $(a, b)$: + - ExtendedEuclid berechnet $d', m', n'$ korrekt (Induktionshypothese) + - $d=d'=m'\Zeiten b+n'\Zeiten (a\ MOD\ b)=m'\Zeiten b+n'\Zeiten(a-\lfloor a/b\rfloor\Zeiten b)=n'\Zeiten a+(m'-\lfloor a/b\rfloor\Zeiten n')\Zeiten b$ + - Die Laufzeit von $Euclid(a, b)$ und $ExtendedEuclid(a, b)$ ist von $O(log\ b)$ + - Beweis: siehe [Cor90a], Abschnitt 33. + - Lemma 1: Sei $a,b\in\mathbb{N}$ und $d=gcd(a,b)$. Dann gibt es $m,n\in\mathbb{N}$ so, dass: $d=m\mal a+n \mal b$ +- Theorem 1 (Euklid): Wenn eine Primzahl das Produkt zweier ganzer Zahlen teilt, dann teilt sie mindestens eine der ganzen Zahlen: $p|(a\mal b)\Rechtspfeil (p|a) \vier (p|b)$ + - Der Beweis: Es sei $p|(a\mal b)$ + - Wenn $p|a$ dann sind wir fertig. + - Wenn nicht, dann $gcd(p,a) = 1 \Rightarrow\existiert m, n\in\mathbb{N}:1=m\mal p+n\mal a \Leftrightarrow b=m\mal p \mal b + n \mal a \mal b$ + - Da $p|(a\mal b)$, teilt p beide Summanden der Gleichung und somit auch die Summe, die b ist +- Theorem 2 (Fundamentalsatz der Arithmetik): Die Faktorisierung in Primzahlen ist bis zur Ordnung eindeutig. + - Der Beweis: + - Wir werden zeigen, dass jede ganze Zahl mit einer nicht eindeutigen Faktorisierung einen eigenen Teiler mit einer nicht eindeutigen Faktorisierung hat, was zu einem klaren Widerspruch führt, wenn wir schließlich auf eine Primzahl reduziert haben. + - Nehmen wir an, dass n eine ganze Zahl mit einer nicht eindeutigen Faktorisierung ist: $n=p_1\mal p_2\mal ...\mal p_r=q_1 \mal q_2\mal ... \times q_s$. Die Primzahlen sind nicht notwendigerweise verschieden, aber die zweite Faktorisierung ist nicht einfach eine Umordnung der ersten. Da $p_1$ n dividiert, dividiert es auch das Produkt $q_1\mal q_2\mal ... \times q_s$. Durch wiederholte Anwendung von Satz 1 zeigen wir, dass es mindestens ein $q_i$ gibt, das durch $p_1$ teilbar ist. Gegebenenfalls ordnen wir die $q_i$'s so, dass es $q_1$ ist. Da sowohl $p_1$ als auch $q_1$ Primzahlen sind, müssen sie gleich sein. Wir können also durch $p_1$ dividieren und haben, dass $n/p_1$ eine nicht-eindeutige Faktorisierung hat. + - Wir verwenden Theorem 2, um die folgende Korollarie 1 zu beweisen + - Wenn $gcd(c,m)=1$ und $(a\mal c)\equiv(b\mal c)mod\ m$, dann $a\equiv b\ mod\ m$ + - Der Beweis: Da $(a\times c)\equiv(b\times c)mod\ m\Rightarrow\existiert n\in\mathbb{N}:(a\times c)-(b\times c)=n\times m$ + - $\Leftrightarrow ( a - b ) \Zeiten c = n \Zeiten m$ + - $\Leftrightarrow p_1\Zeiten ...\Zeiten p_i\Zeiten q_1\Zeiten ...\Zeiten q_j=r_1\Zeiten ...\Zeiten r_k\Zeiten s_1\Zeiten ...\Zeiten s_l$ + - Man beachte, dass die $p$'s, $q$'s, $r$'s und $s$'s Primzahlen sind und nicht verschieden sein müssen, aber da $gcd(c,m)=1$, gibt es keine Indizes g, h, so dass $q_g = s_h$. + - Wir können also die Gleichung fortlaufend durch alle q's teilen, ohne jemals ein $s$ zu ,,eliminieren'' und erhalten schließlich etwas wie $\Leftrightarrow p_1\mal ...\mal p_i=r_1\mal ...\mal r_o\mal s_1\mal ...\mal s_l$ (beachten Sie, dass es weniger r's geben wird) + - $\Leftrightarrow(a-b)=r_1\Zeiten ...\Zeiten r_o\Zeiten m\Rightarrow a \equiv b\ mod\ m$ + - Bezeichne $\phi(n)$ die Anzahl der positiven ganzen Zahlen, die kleiner als n und relativ zu n prim sind + - Beispiele: $\phi(4) = 2$, \phi(6)=2$, $\phi(7)=6$, $\phi(15)=8$ + - Wenn p eine Primzahl ist $\Rightarrow\phi(p)=p-1$ +- Theorem 3 (Euler): Seien n und b positive und relativ primäre ganze Zahlen, d.h. $gcd(n, b) = 1 \Rightarrow b \phi(n) \equiv 1\ mod\ n$ + - Beweis: + - Sei $t=\phi(n)$ und $a_1,...a_t$ seien die positiven ganzen Zahlen kleiner als $n$, die relativ zu $n$ prim sind. Definieren Sie $r_1,...,r_t$ als die Residuen von $b\mal a_1\ mod\ n , ..., b\mal a_t\ mod\ n$, d.h.: $b\mal a_i \equiv r_i\ mod\ n$. + - Beachten Sie, dass $i\not= j \Rightarrow r_i\not= r_j$. Wäre dies nicht der Fall, hätten wir $b\mal a_i\equiv b\mal a_j\ mod\ n$ und da $gcd(b,n)=1$, würde Korollar 1 $a_i\equiv a_j\ mod\ n$ implizieren, was nicht sein kann, da $a_i$ und $a_j$ per Definition verschiedene ganze Zahlen zwischen 0 und n sind + - Wir wissen auch, dass jedes $r_i$ relativ prim zu n ist, denn jeder gemeinsame Teiler k von $r_i$ und $n$ , d.h. $n=k\mal m$ und $r_i=p_i\mal k$, müsste auch $a_i$ teilen, + - da $b\mal a_i$gleich (p_i\mal k)\ mod\ (k\mal m)\Rightarrow\existiert s\in\mathbb{N}:(b\mal a_i)-(p_i\mal k)=s\mal k\mal m \Leftrightarrow (b\mal a_i)=s\mal k\mal m+(p_i\mal k)$ + - Da k jeden der Summanden auf der rechten Seite dividiert und k nicht durch b dividiert (n und b sind relativ prim), müsste es auch $a_i$ dividieren, das relativ prim zu n sein soll + - Somit ist $r_1, ...,r_t$ eine Menge von $\phi(n)$ verschiedenen ganzen Zahlen, die relativ prim zu $n$ sind. Das bedeutet, dass sie genau dasselbe sind wie $a_1,...a_t$, nur dass sie in einer anderen Reihenfolge stehen. Insbesondere wissen wir, dass $r_1\mal...\mal r_t=a_1\mal...\mal a_t$ + - Wir verwenden nun die Kongruenz $r_1\Zeiten...\Zeiten r_t\equiv b\Zeiten a_1\Zeiten...\Zeiten b\Zeiten a_t\ mod\ n$ + $\Leftrightarrow r_1\Zeiten...\Zeiten r_t\equiv b_t\Zeiten a_1\Zeiten...\Zeiten a_t\ mod\ n$ + $\Leftrightarrow r_1\Zeiten...\Zeiten r_t\equiv b_\Zeiten r_1\Zeiten...\Zeiten r_t\ mod\ n$ + - Da alle $r_i$ relativ prim zu $n$ sind, können wir Korollar 1 anwenden und durch ihr Produkt dividieren: $1\equiv b_t\ mod\ n \Leftrightarrow 1\equiv b\phi(n)\ mod n$ +- Satz 4 (Chinese Remainder Theorem): + - Seien $m_1,...,m_r$ positive ganze Zahlen, die paarweise relativ prim sind, + - d.h. $ganz i\not= j:gcd(m_i, m_j) = 1$. Seien $a_1,...,a_r$ beliebige ganze Zahlen. + - Dann gibt es eine ganze Zahl a derart, dass: - $a\equiv a_1\ mod\ m_1$ - $a\equiv a_2\ mod\ m_2$ - ... - $a\equiv a_r\ mod\ m_r$ - - Furthermore, a is unique modulo $M := m_1\times...\times m_r$ - - Proof: - - For all $i\in\{1,...,r\}$ we define $M_i:=(M/m_i)\phi(m_i)$ - - As $M_i$ is by definition relatively prime to $m_i$ we can apply Theorem 3 and know that $M_i\equiv 1\ mod\ m_i$ - - Since $M_i$ is divisible by $m_j$ for every $j\not= i$, we have $\forall j\not= i:M_i\equiv 0\ mod\ m_j$ - - We can now construct the solution by defining: $a:= a_1\times M_1+a_2\times M_2+...+a_r\times M_r$ - - The two arguments given above concerning the congruences of the $M_i$ imply that a actually satisfies all of the congruences. - - To see that a is unique modulo $M$, let b be any other integer satisfying the r congruences. As $a\equiv c\ mod\ n$ and $b\equiv c\ mod\ n \Rightarrow a \equiv b\ mod\ n$ we have $\forall i\in\{1,...,r\}:a\equiv b\ mod\ m_i\Rightarrow\forall i\in\{1,...,r\}:m_i|(a-b) \Rightarrow M|(a-b)$ as the $m_i$ are pairwise relatively prime $\Leftrightarrow a\equiv b\ mod\ M$ + - Außerdem ist a eindeutig modulo $M := m_1\mal...\mal m_r$ + - Beweis: + - Für alle $i\in\{1,...,r\}$ definieren wir $M_i:=(M/m_i)\phi(m_i)$ + - Da $M_i$ per Definition relativ prim zu $m_i$ ist, können wir Theorem 3 anwenden und wissen, dass $M_i\equiv 1\ mod\ m_i$ + - Da $M_i$ durch $m_j$ für jedes $j\not= i$ teilbar ist, haben wir $\füralle j\not= i:M_i\equiv 0\ mod\ m_j$ + - Wir können nun die Lösung konstruieren, indem wir definieren: $a:= a_1\mal M_1+a_2\mal M_2+...+a_r\mal M_r$ + - Die beiden oben angeführten Argumente bezüglich der Kongruenzen der $M_i$ implizieren, dass a tatsächlich alle Kongruenzen erfüllt. + - Um zu sehen, dass a eindeutig modulo $M$ ist, sei b eine beliebige andere ganze Zahl, die die r Kongruenzen erfüllt. Da $a\equiv c\ mod\ n$ und $b\equiv c\ mod\ n \Rightarrow a \equiv b\ mod\ n$ haben wir $\für alle i\in\{1,...,r\}:a\equiv b\ mod\ m_i\Rightarrow\für alle i\in\{1,. ...,r\}:m_i|(a-b) \Rightarrow M|(a-b)$, da die $m_i$ paarweise relativ prim sind $\Leftrightarrow a\equiv b\ mod\ M$ - Lemma 2: - - If $gcd(m,n)=1$, then $\phi(m\times n)=\phi(m)\times\phi(n)$ - - Proof: - - Let a be a positive integer less than and relatively prime to $m\times n$. In other words, a is one of the integers counted by $\phi(m\times n)$. - - Consider the correspondence $a\rightarrow(a\ MOD\ m, a\ MOD\ n)$. The integer a is relatively prime to m and relatively prime to n (if not it would divide $m \times n$). So, $(a\ MOD\ m)$ is relatively prime to m and $(a\ MOD\ n)$ is relatively prime to n as: $a=\lfloor a/m\rfloor\times m + (a\ MOD\ m)$, so if there would be a common divisor of $m$ and $(a\ MOD\ m)$, this divisor would also divide a. Thus every number a counted by $\phi(m\times n )$ corresponds to a pair of two integers $(a\ MOD\ m,a\ MOD\ n)$, the first one counted by $\phi(m)$ and the second one counted by $\phi(n)$. - - Because of the second part of Theorem 4, the uniqueness of the solution $a\ mod\ (m\times n)$ to the simultaneous congruences: - $a \equiv(a\ MOD\ m)\ mod\ m$ + - Wenn $gcd(m,n)=1$, dann ist $\phi(m\mal n)=\phi(m)\mal\phi(n)$ + - Der Beweis: + - Sei a eine positive ganze Zahl, die kleiner als und relativ prim zu $m\mal n$ ist. Mit anderen Worten: a ist eine der ganzen Zahlen, die von $\phi(m\mal n)$ gezählt werden. + - Betrachten Sie die Entsprechung $a\rightarrow(a\ MOD\ m, a\ MOD\ n)$. Die ganze Zahl a ist relativ prim zu m und relativ prim zu n (andernfalls würde sie $m \mal n$ teilen). Also ist $(a\ MOD\ m)$ relativ prim zu m und $(a\ MOD\ n)$ ist relativ prim zu n, da: $a=\lfloor a/m\rfloor\times m + (a\ MOD\ m)$, wenn es also einen gemeinsamen Teiler von $m$ und $(a\ MOD\ m)$ gäbe, würde dieser Teiler auch a teilen. Somit entspricht jede Zahl a, die durch $\phi(m\mal n )$ gezählt wird, einem Paar von zwei ganzen Zahlen $(a\ MOD\ m,a\ MOD\ n)$, wobei die erste durch $\phi(m)$ und die zweite durch $\phi(n)$ gezählt wird. + - Aufgrund des zweiten Teils von Satz 4 ist die Einzigartigkeit der Lösung $a\ mod\ (m\mal n)$ der simultanen Kongruenzen: + $a \equiv(a\ mod\ m)\ mod\ m$ $a \equiv(a\ MOD\ n)\ mod\ n$ - we can deduce, that distinct integers counted by $\phi(m\times n)$ correspond to distinct pairs: - - Too see this, suppose that $a\not=b$ counted by $\phi(m\times n)$ does correspond to the same pair $(a\ MOD\ m, a\ MOD\ n)$. This leads to a contradiction as b would also fulfill the congruences: + können wir ableiten, dass verschiedene ganze Zahlen, die durch $\phi(m\mal n)$ gezählt werden, verschiedenen Paaren entsprechen: + - Um dies zu sehen, nehmen wir an, dass $a\not=b$, gezählt durch $\phi(m\mal n)$, demselben Paar $(a\ MOD\ m, a\ MOD\ n)$ entspricht. Dies führt zu einem Widerspruch, da b auch die Kongruenzen erfüllen würde: $b\equiv (a\ MOD\ m)\ mod\ m$ $b\equiv (a\ MOD\ n)\ mod\ n$ - but the solution to these congruences is unique modulo $(m \times n)$ - - Therefore, $\phi(m\times n)$ is at most the number of such pairs: $\phi(m\times n)\leq \phi(m)\times\phi(n)$ - - Consider now a pair of integers $(b,c)$, one counted by $\phi(m)$ and the other one counted by $\phi(n)$: Using the first part of Theorem 4 we can construct a unique positive integer a less than and relatively prime to $m\times n$: $a\equiv b\ mod\ m$ and $a\equiv c\ mod\ n$. So, the number of such pairs is at most $\phi(m\times n):\phi(m \times n)\leq\phi(m)\times\phi(n)$ + aber die Lösung dieser Kongruenzen ist eindeutig modulo $(m \mal n)$ + - Daher ist $\phi(m \mal n)$ höchstens die Anzahl solcher Paare: $\phi(m \mal n)\leq \phi(m)\mal\phi(n)$ + - Betrachten wir nun ein Paar von ganzen Zahlen $(b,c)$, von denen eine mit $\phi(m)$ und die andere mit $\phi(n)$ gezählt wird: Mit Hilfe des ersten Teils von Satz 4 können wir eine einzige positive ganze Zahl a konstruieren, die kleiner als und relativ prim zu $m\times n$ ist: $a\equiv b\ mod\ m$ und $a\equiv c\ mod\ n$. Die Anzahl solcher Paare ist also höchstens $\phi(m \times n):\phi(m \times n)\leq\phi(m)\times\phi(n)$ -## The RSA Public Key Algorithm -- The RSA algorithm was invented in 1977 by R. Rivest, A. Shamir and L. Adleman [RSA78] and is based on Theorem 3. -- Let $p, q$ be distinct large primes and $n=p\times q$. Assume, we have also two integers e and d such that: $d\times e \equiv 1\ mod\ \phi(n)$ -- Let M be an integer that represents the message to be encrypted, with M positive, smaller than and relatively prime to n. - - Example: Encode with = 99, A = 10, B = 11, ..., Z = 35. So ,,HELLO'' would be encoded as 1714212124. If necessary, break M into blocks of smaller messages: 17142 12124 -- To encrypt, compute: $E = M^e\ MOD\ n$ - - This can be done efficiently using the square-and-multiply algorithm -- To decrypt, compute: $M’=E^d\ MOD\ n$ - - As $d\times e\equiv 1\ mod\ \phi(n)\Rightarrow\exists k\in\mathbb{Z}:(d\times e)-1=k\times\phi(n)\Leftrightarrow(d\times e)=k\times\phi(n)+1$ - - we have: $M’\equiv E^d\equiv M^{e\times d}\equiv M^{k\times\phi(n)+1}\equiv 1^k\times M\equiv M\ mod\ n$ -- As $(d\times e)=(e\times d)$ the operation also works in the opposite direction, that means you can encrypt with d and decrypt with e - - This property allows to use the same keys d and e for: - - Receiving messages that have been encrypted with one’s public key - - Sending messages that have been signed with one’s private key -- To set up a key pair for RSA: - - Randomly choose two primes $p$ and $q$ (of 100 to 200 digits each) - - Compute $n=p\times q,\phi(n)=(p-1)\times (q-1)$ (Lemma 2) - - Randomly choose $e$, so that $gcd(e,\phi(n))=1$ - - With the extended euclidean algorithm compute d and c, such that: $e\times d+\phi(n)\times c = 1$, note that this implies, that $e\times d\equiv 1\ mod\ \phi(n)$ - - The public key is the pair $(e, n)$ - - The private key is the pair $(d, n)$ -- The security of the scheme lies in the difficulty of factoring $n=p\times q$ as it is easy to compute $\phi(n)$ and then $d$, when $p$ and $q$ are known -- This class will not teach why it is difficult to factor large n’s, as this would require to dive deep into mathematics - - If p and q fulfill certain properties, the best known algorithms are exponential in the number of digits of n - - Please be aware that if you choose p and q in an ,,unfortunate'' way, there might be algorithms that can factor more efficiently and your RSA encryption is not at all secure: - - Therefore, p and q should be about the same bitlength and sufficiently large - - $(p-q)$ should not be too small - - If you want to choose a small encryption exponent, e.g. 3, there might be additional constraints, e.g. $gcd(p-1, 3) = 1$ and $gcd(q-1,3)=1$ - - The security of RSA also depends on the primes generated being truly random (like every key creation method for any algorithm) - - Moral: If you are to implement RSA by yourself, ask a mathematician or better a cryptographer to check your design +## Der RSA Public Key Algorithmus +- Der RSA-Algorithmus wurde 1977 von R. Rivest, A. Shamir und L. Adleman [RSA78] erfunden und basiert auf Theorem 3. +- Seien $p, q$ verschiedene große Primzahlen und $n=p\times q$. Nehmen wir an, wir haben auch zwei ganze Zahlen e und d, so dass: $d\times e \equiv 1\ mod\ \phi(n)$ +- M sei eine ganze Zahl, die die zu verschlüsselnde Nachricht darstellt, wobei M positiv, kleiner als und relativ prim zu n ist. + - Beispiel: Verschlüsseln mit = 99, A = 10, B = 11, ..., Z = 35. Somit würde ,,HELLO'' als 1714212124 kodiert werden. Falls erforderlich, ist M in Blöcke kleinerer Nachrichten aufzuteilen: 17142 12124 +- Zum Verschlüsseln berechnen Sie: $E = M^e\ MOD\ n$ + - Dies kann mit dem Quadrat- und Multiplikationsalgorithmus effizient durchgeführt werden +- Zum Entschlüsseln berechnet man: $M'=E^d\ MOD\ n$ + - Da $d\times e\equiv 1\ mod\ \phi(n)\Rightarrow\existiert k\in\mathbb{Z}:(d\times e)-1=k\times\phi(n)\Leftrightarrow(d\times e)=k\times\phi(n)+1$ + - haben wir: $M'\equiv E^d\equiv M^{e\times d}\equiv M^{k\times\phi(n)+1}\equiv 1^k\times M\equiv M\ mod\ n$ +- Da $(d\times e)=(e\times d)$ funktioniert die Operation auch in umgekehrter Richtung, d.h. man kann mit d verschlüsseln und mit e entschlüsseln + - Diese Eigenschaft erlaubt es, die gleichen Schlüssel d und e zu verwenden: + - den Empfang von Nachrichten, die mit dem eigenen öffentlichen Schlüssel verschlüsselt wurden + - Senden von Nachrichten, die mit dem eigenen privaten Schlüssel signiert wurden +- So richten Sie ein Schlüsselpaar für RSA ein: + - Wählen Sie zufällig zwei Primzahlen $p$ und $q$ (mit jeweils 100 bis 200 Ziffern) + - Berechne $n=p\mal q,\phi(n)=(p-1)\mal (q-1)$ (Lemma 2) + - Wähle zufällig $e$, so dass $gcd(e,\phi(n))=1$ + - Berechne mit dem erweiterten euklidischen Algorithmus d und c, so dass: $e\mal d+\phi(n)\mal c = 1$, wobei zu beachten ist, dass dies impliziert, dass $e\mal d\equiv 1\ mod\ \phi(n)$ + - Der öffentliche Schlüssel ist das Paar $(e, n)$ + - Der private Schlüssel ist das Paar $(d, n)$ +- Die Sicherheit des Verfahrens liegt in der Schwierigkeit der Faktorisierung von $n=p\mal q$, da es einfach ist, $\phi(n)$ und dann $d$ zu berechnen, wenn $p$ und $q$ bekannt sind. +- In diesem Kurs wird nicht gelehrt, warum es schwierig ist, große n zu faktorisieren, da dies einen tiefen Einblick in die Mathematik erfordern würde. + - Wenn p und q bestimmte Eigenschaften erfüllen, sind die besten bekannten Algorithmen exponentiell zur Anzahl der Ziffern von n + - Bitte beachten Sie, dass es bei einer unglücklichen Wahl von p und q Algorithmen geben könnte, die effizienter faktorisieren können, und dass Ihre RSA-Verschlüsselung dann nicht mehr sicher ist: + - Daher sollten p und q ungefähr die gleiche Bitlänge haben und ausreichend groß sein + - $(p-q)$ sollte nicht zu klein sein + - Wenn man einen kleinen Verschlüsselungsexponenten, z.B. 3, wählen will, kann es zusätzliche Einschränkungen geben, z.B. $gcd(p-1, 3) = 1$ und $gcd(q-1,3)=1$ + - Die Sicherheit von RSA hängt auch davon ab, dass die erzeugten Primzahlen wirklich zufällig sind (wie jede Methode zur Schlüsselerzeugung bei jedem Algorithmus). + - Moral: Wenn Sie RSA selbst implementieren wollen, bitten Sie einen Mathematiker oder besser einen Kryptographen, Ihren Entwurf zu überprüfen. -## Some More Mathematical Background -- Definition: finite groups - - A group ( S , \oplus) is a set S together with a binary operation \oplus for which the - following properties hold: - - Closure: For all a, b \in S , we have a \oplus b \in S - - Identity: There is an element e \in S , such that e \oplus a = a \oplus e = a for all +## Einige weitere mathematische Hintergründe +- Definition: endliche Gruppen + - Eine Gruppe ( S , \oplus) ist eine Menge S zusammen mit einer binären Operation \oplus, für die die + folgende Eigenschaften gelten: + - Geschlossenheit: Für alle a, b \in S , haben wir a \oplus b \in S + - Identität: Es gibt ein Element e \in S , so dass e \oplus a = a \oplus e = a für alle a \in S - - Associativity: For all a, b, c \in S , we have ( a \oplus b ) \oplus c = a \oplus ( b \oplus c ) - - Inverses: For each a \in S , there exists a unique element b \in S , such - that a \oplus b = b \oplus a = e - - If a group ( S , \oplus) satisfies the commutative law \forall a, b \in S : a \oplus b = b \oplus a - then it is called an Abelian group - - If a group ( S , \oplus) has only a finite set of elements, i.e. |S| < \infty, then it is - called a finite group -- Examples: + - Assoziativität: Für alle a, b, c \in S , gilt ( a \oplus b ) \oplus c = a \oplus ( b \oplus c ) + - Inversen: Für jedes a \in S , gibt es ein einziges Element b \in S , so dass + dass a \oplus b = b \oplus a = e + - Erfüllt eine Gruppe ( S , \oplus) das Kommutativgesetz \für alle a, b \in S : a \oplus b = b \oplus a + dann nennt man sie eine abelsche Gruppe + - Wenn eine Gruppe ( S , \oplus) nur eine endliche Menge von Elementen hat, d.h. |S| < \infty, dann wird sie + eine endliche Gruppe genannt +- Beispiele: - $(\mathbb{Z}_n , +_n)$ - - with $\mathbb{Z}_n:=\{[0]_n,[1]_n,...,[n-1]_n\}$ - - where $[a]_n:=\{b \in \mathbb{Z} | b \equiv a mod n\}$ and - - $+_n$ is defined such that $[a]_n+_n[b]_n=[a+b]_n$ - - is a finite abelian group. For the proof see the table showing the properties of modular arithmetic + - mit $\mathbb{Z}_n:=\{[0]_n,[1]_n,...,[n-1]_n\}$ + - wobei $[a]_n:=\{b \in \mathbb{Z} | b \equiv a mod n\}$ und + - $+_n$ ist so definiert, dass $[a]_n+_n[b]_n=[a+b]_n$ + - eine endliche abelsche Gruppe ist. Für den Beweis siehe die Tabelle mit den Eigenschaften der modularen Arithmetik - $(\mathbb{Z}^*_n , \times_n)$ - - with $\mathbb{Z}^*_n :=\{[a]_n\in \mathbb{Z}_n | gcd(a,n)=1\}$, and - - $\times_n$ is defined such that $[a]_n\times_n [b]_n=[a\times b]_n$ - - is a finite Abelian group. Please note that $\mathbb{Z}^*_n$ just contains those elements of $\mathbb{Z}_n$ that have a multiplicative inverse modulo n. For the proof see the properties of modular arithmetic - - Example: $\mathbb{Z}^*_{15}=\{[1]_{15},[2]_{15},[4]_{15},[7]_{15},[8]_{15},[11]_{15},[13]_{15},[14]_{15}\}$, as $1\times 1\equiv 1 mod 15$, $2 \times 8 \equiv 1 mod 15$, $4 \times 4 \equiv 1 mod 15$, $7 \times 13 \equiv 1 mod 15$, $11 \times 11 \equiv 1 mod 15$, $14 \times 14 \equiv 1 mod 15$ -- If it is clear that we are talking about $(\mathbb{Z}_n, +_n)$ or $(\mathbb{Z}^*_n, \times_n)$ we often represent equivalence classes $[a]_n$ by their representative elements a and denote $+_n$ and $\times_n$ by $+$ and $\times$, respectively. - - Definition: finite fields - - A field $(S,\oplus, \otimes)$ is a set S together with two operations $\oplus$, $\otimes$ such that - - $(S,\oplus)$ and $(S\backslash\{e_{\oplus}\},\otimes)$ are commutative groups, i.e. only the identity element concerning the operation $\oplus$ does not need to have an inverse regarding the operation $\otimes$ - - For all $a,b,c\in S$, we have a $\otimes(b\oplus c)=(a\otimes b)\oplus(a\otimes c)$ - - If $|S|<\infty$ then $(S,\oplus,\otimes)$ is called a finite field -- Example: $(\mathbb{Z}_p, +_p, \times_p)$ is a finite field for each prime p -- Definition: primitive root, generator - - Let $(S,\circ)$ be a group, $g\in S$ and $g^a:=g\circ g\circ...\circ g$ (a times with $a\in\mathbb{Z}^+$) - - Then g is called a primitive root or generator of $(S,\circ):\Leftrightarrow\{g^a|1\leq a\leq |S|\}=S$ - - Examples: - - 1 is a primitive root of $(\mathbb{Z}_n, +_n)$ - - 3 is a primitive root of $(\mathbb{Z}^*_7, \times_7)$ - - Not all groups do have primitive roots and those who have are called cyclic groups + - mit $\mathbb{Z}^*_n :=\{[a]_n\in \mathbb{Z}_n | gcd(a,n)=1\}$, und + - $\times_n$ ist so definiert, dass $[a]_n\times_n [b]_n=[a\times b]_n$ + - eine endliche abelsche Gruppe ist. Man beachte, dass $\mathbb{Z}^*_n$ nur die Elemente von $\mathbb{Z}_n$ enthält, die eine multiplikative Inverse modulo n haben. Zum Beweis siehe Eigenschaften der modularen Arithmetik + - Beispiel: $\mathbb{Z}^*_{15}=\{[1]_{15},[2]_{15},[4]_{15},[7]_{15},[8]_{15},[11]_{15},[13]_{15},[14]_{15}\}$, als $1\times 1\equiv 1 mod 15$, $2 \Zeiten 8 \equiv 1 mod 15$, $4 \Zeiten 4 \equiv 1 mod 15$, $7 \Zeiten 13 \equiv 1 mod 15$, $11 \Zeiten 11 \equiv 1 mod 15$, $14 \Zeiten 14 \equiv 1 mod 15$ +- Wenn klar ist, dass es sich um $(\mathbb{Z}_n, +_n)$ oder $(\mathbb{Z}^*_n, \times_n)$ handelt, werden Äquivalenzklassen $[a]_n$ oft durch ihre repräsentativen Elemente a dargestellt und $+_n$ und $\times_n$ durch $+$ bzw. $\times$ bezeichnet. + - Definition: endliche Felder + - Ein Feld $(S,\oplus, \otimes)$ ist eine Menge S zusammen mit zwei Operationen $\oplus$, $\otimes$, so dass + - $(S,\oplus)$ und $(S\backslash\{e_{\oplus}\},\otimes)$ sind kommutative Gruppen, d.h. nur das Identitätselement bezüglich der Operation $\oplus$ muss kein Inverses bezüglich der Operation $\otimes$ haben + - Für alle $a,b,c\in S$ haben wir ein $\otimes(b\oplus c)=(a\otimes b)\oplus(a\otimes c)$ + - Wenn $|S|<\infty$ dann heißt $(S,\oplus,\otimes)$ ein endliches Feld +- Beispiel: $(\mathbb{Z}_p, +_p, \times_p)$ ist ein endliches Feld für jede Primzahl p +- Definition: Primitive Wurzel, Generator + - Sei $(S,\circ)$ eine Gruppe, $g\in S$ und $g^a:=g\circ g\circ...\circ g$ (a mal mit $a\in\mathbb{Z}^+$) + - Dann heißt g eine primitive Wurzel oder ein Generator von $(S,\circ):\Leftrightarrow\{g^a|1\leq a\leq |S|\}=S$ + - Beispiele: + - 1 ist eine primitive Wurzel von $(\mathbb{Z}_n, +_n)$ + - 3 ist eine Primitivwurzel von $(\mathbb{Z}^*_7, \times_7)$ + - Nicht alle Gruppen haben Primitivwurzeln, und diejenigen, die sie haben, nennt man zyklische Gruppen - Theorem 5: - - $(\mathbb{Z}^*_n, \times_n)$ does have a primitive root $\Leftrightarrow n\in\{2,4,p,2\times p^e\}$ where p is an odd prime and $e\in\mathbb{Z}^+$ + - $(\mathbb{Z}^*_n, \times_n)$ hat eine primitive Wurzel $\Leftrightarrow n\in\{2,4,p,2\times p^e\}$, wobei p eine ungerade Primzahl ist und $e\in\mathbb{Z}^+$ - Theorem 6: - - If $(S,\circ)$ is a group and $b\in S$ then $(S’,\circ)$ with $S’=\{b^a|a\in\mathbb{Z}^+\}$ is also a group. - - As $S’\subseteq S,(S’,\circ)$ is called a subgroup of $(S,\circ)$ - - If b is a primitive root of $(S,\circ)$ then $S’=S$ -- Definition: order of a group and of an element - - Let $(S,\circ)$ be a group, $e\in S$ its identity element and $b\in S$ any element of $S$: - - Then $|S|$ is called the order of $(S,\circ)$ - - Let $c\in\mathbb{Z}^+$ be the smallest element so that $b^c=e$ (if such a c exists, if not set $c=\infty$). Then c is called the order of b. + - Wenn $(S,\circ)$ eine Gruppe ist und $b\in S$, dann ist $(S',\circ)$ mit $S'=\{b^a|a\in\mathbb{Z}^+\}$ ebenfalls eine Gruppe. + - Da $S'\subseteq S, heißt (S',\circ)$ eine Untergruppe von $(S,\circ)$ + - Wenn b eine Urwurzel von $(S,\circ)$ ist, dann ist $S'=S$ +- Definition: Ordnung einer Gruppe und eines Elements + - Sei $(S,\circ)$ eine Gruppe, $e\in S$ ihr Identitätselement und $b\in S$ irgendein Element von $S$: + - Dann heiße $|S|$ die Ordnung von $(S,\circ)$ + - Sei $c\in\mathbb{Z}^+$ das kleinste Element, so dass $b^c=e$ ist (falls ein solches c existiert, falls nicht, setze $c=\infty$). Dann wird c die Ordnung von b genannt. - Theorem 7 (Lagrange): - - If G is a finite group and H is a subgroup of G , then $|H|$ divides $|G|$. - - Hence, if $b\in G$ then the order of b divides $|G|$. + - Ist G eine endliche Gruppe und H eine Untergruppe von G , so ist $|H|$ Teiler von $|G|$. + - Wenn also $b in G$ ist, dann ist die Ordnung von b Teiler von $|G|$. - Theorem 8: - - If G is a cyclic finite group of order n and d divides n then G has exactly $\phi(d)$ elements of order $d$. In particular, G has $\phi(n)$ elements of order n. -- Theorems 5, 7, and 8 are the basis of the following algorithm that finds a cyclic group $\mathbb{Z}^*_p$ and a primitive root g of it: - - Choose a large prime q such that $p=2q+1$ is prime. - - As $p$ is prime, Theorem 5 states that $\mathbb{Z}^*_p$ is cyclic. - - The order of $\mathbb{Z}^*_p$ is $2\times q$ and $\phi(2\times q)=\phi(2)\times\phi(q)=q-1$ as $q$ is prime. - - So, the odds of randomly choosing a primitive root are $(q-1)/2q \approx 1/2$ - - In order to efficiently test, if a randomly chosen g is a primitive root, we just have to test if $g^2\equiv 1 mod p$ or $g^q\equiv 1 mod p$. If not, then its order has to be $|\mathbb{Z}^*_p|$, as Theorem 7 states that the order of g has to divide $|\mathbb{Z}^*_p|$ -- Definition: discrete logarithm - - Let p be prime, g be a primitive root of $(\mathbb{Z}^*_p,\times_p)$ and c be any element of $\mathbb{Z}^*_p$. Then there exists z such that: $g^z\equiv c mod p$ - - z is called the discrete logarithm of c modulo p to the base g - - Example 6 is the discrete logarithm of 1 modulo 7 to the base 3 as $3^6\equiv 1 mod 7$ - - The calculation of the discrete logarithm z when given g, c, and p is a computationally difficult problem and the asymptotical runtime of the best known algorithms for this problem is exponential in the bitlength of p + - Ist G eine zyklische endliche Gruppe der Ordnung n und d ist Teiler von n, dann hat G genau $\phi(d)$ Elemente der Ordnung $d$. Insbesondere hat G $\phi(n)$-Elemente der Ordnung n. +- Die Theoreme 5, 7 und 8 sind die Grundlage des folgenden Algorithmus, der eine zyklische Gruppe $\mathbb{Z}^*_p$ und eine Urwurzel g davon findet: + - Man wählt eine große Primzahl q, so dass $p=2q+1$ eine Primzahl ist. + - Da $p$ prim ist, besagt Satz 5, dass $\mathbb{Z}^*_p$ zyklisch ist. + - Die Ordnung von $\mathbb{Z}^*_p$ ist $2\-mal q$ und $\phi(2\-mal q)=\phi(2)\-mal\phi(q)=q-1$, da $q$ prim ist. + - Die Wahrscheinlichkeit, dass eine Primitivwurzel zufällig ausgewählt wird, beträgt also $(q-1)/2q \ca. 1/2$. + - Um effizient zu prüfen, ob ein zufällig gewähltes g eine Urwurzel ist, müssen wir nur prüfen, ob $g^2\equiv 1 mod p$ oder $g^q\equiv 1 mod p$ ist. Wenn nicht, dann muss seine Ordnung $|\mathbb{Z}^*_p|$ sein, da Satz 7 besagt, dass die Ordnung von g $|\mathbb{Z}^*_p|$ teilen muss +- Definition: diskreter Logarithmus + - Sei p eine Primzahl, g eine Urwurzel von $(\mathbb{Z}^*_p,\times_p)$ und c ein beliebiges Element von $\mathbb{Z}^*_p$. Dann gibt es z so, dass: $g^z\equiv c mod p$ + - z wird der diskrete Logarithmus von c modulo p zur Basis g genannt + - Beispiel 6 ist der diskrete Logarithmus von 1 modulo 7 zur Basis 3 als $3^6\equiv 1 mod 7$ + - Die Berechnung des diskreten Logarithmus z bei gegebenem g, c und p ist ein rechnerisch schwieriges Problem, und die asymptotische Laufzeit der besten bekannten Algorithmen für dieses Problem ist exponentiell zur Bitlänge von p -## Diffie-Hellman Key Exchange -- The Diffie-Hellman key exchange was first published in the landmark paper [DH76], which also introduced the fundamental idea of asymmetric cryptography -- The DH exchange in its basic form enables two parties A and B to agree upon a shared secret using a public channel: - - Public channel means, that a potential attacker E (E stands for eavesdropper) can read all messages exchanged between A and B - - It is important, that A and B can be sure, that the attacker is not able to alter messages, as in this case he might launch a man-in-the-middle attack - - The mathematical basis for the DH exchange is the problem of finding discrete logarithms in finite fields - - The DH exchange is not an asymmetric encryption algorithm, but is nevertheless introduced here as it goes well with the mathematical flavor of this lecture... -- If Alice (A) and Bob (B) want to agree on a shared secret s and their only means of communication is a public channel, they can proceed as follows: - - A chooses a prime p, a primitive root g of $\mathbb{Z}^*_p$, and a random number q: - - A and B can agree upon the values p and g prior to any communication, or A can choose p and g and send them with his first message - - A computes $v=g^q\ MOD\ p$ and sends to $B:\{p,g,v\}$ - - B chooses a random number r: - - B computes $w=g^r\ MOD\ p$ and sends to $A:\{p,g,w\}$ (or just $\{w\}$) - - Both sides compute the common secret: - - A computes $s=w^q\ MOD\ p$ - - B computes $s’=v^r\ MOD\ p$ - - As $g^{q\times r}\ MOD\ p = g^{r \times q}\ MOD\ p$ it holds: $s=s’$ - - An attacker Eve who is listening to the public channel can only compute the secret s, if she is able to compute either q or r which are the discrete logarithms of v, w modulo p to the base g -- If the attacker Eve is able to alter messages on the public channel, she can launch a man-in-the-middle attack: - - Eve generates to random numbers $q’$ and $r’$: Eve computes $v’=g^{q’}\ MOD\ p$ and $w’=g^{r’}\ MOD\ p$ - - When A sends $\{p,g,v\}$ she intercepts the message and sends to $B:\{p,g,v’\}$ - - When B sends $\{p,g,w\}$ she intercepts the message and sends to $A:\{p,g,w’\}$ - - When the supposed ,,shared secret'' is computed we get: - - A computes $s_1=w’^q\ MOD\ p = v^{r’}\ MOD\ p$ the latter computed by E - - B computes $s_2=v’^r\ MOD\ p = w^{q’}\ MOD\ p$ the latter computed by E - - So, in fact A and E have agreed upon a shared secret $s_1$ as well as E and B have agreed upon a shared secret $s_2$ - - If the ,,shared secret'' is now used by A and B to encrypt messages to be exchanged over the public channel, E can intercept all the messages and decrypt/re-encrypt them before forwarding them between A and B. -- Two countermeasures against the man-in-the-middle attack: - - The shared secret is ,,authenticated'' after it has been agreed upon - - We will treat this in the section on key management - - A and B use a so-called interlock protocol after agreeing on a shared secret: - - For this they have to exchange messages that E has to relay before she can decrypt / re-encrypt them - - The content of these messages has to be checkable by A and B - - This forces E to invent messages and she can be detected - - One technique to prevent E from decrypting the messages is to split them into two parts and to send the second part before the first one. - - If the encryption algorithm used inhibits certain characteristics E can not encrypt the second part before she receives the first one. - - As A will only send the first part after he received an answer (the second part of it) from B, E is forced to invent two messages, before she can get the first parts. -- Remark: In practice the number g does not necessarily need to be a primitive root of p, it is sufficient if it generates a large subgroup of $\mathbb{Z}^*_p$ +## Diffie-Hellman-Schlüsselaustausch +- Der Diffie-Hellman-Schlüsselaustausch wurde erstmals in der bahnbrechenden Arbeit [DH76] veröffentlicht, in der auch die Grundidee der asymmetrischen Kryptographie vorgestellt wurde +- Der DH-Austausch in seiner Grundform ermöglicht es zwei Parteien A und B, sich über einen öffentlichen Kanal auf ein gemeinsames Geheimnis zu einigen: + - Öffentlicher Kanal bedeutet, dass ein potentieller Angreifer E (E steht für Eavesdropper) alle zwischen A und B ausgetauschten Nachrichten lesen kann + - Es ist wichtig, dass A und B sicher sein können, dass der Angreifer nicht in der Lage ist, Nachrichten zu verändern, da er in diesem Fall einen Man-in-the-Middle-Angriff starten könnte + - Die mathematische Grundlage für den DH-Austausch ist das Problem, diskrete Logarithmen in endlichen Feldern zu finden. + - Der DH-Austausch ist kein asymmetrischer Verschlüsselungsalgorithmus, wird aber dennoch hier vorgestellt, da er gut zum mathematischen Charakter dieser Vorlesung passt... +- Wenn Alice (A) und Bob (B) sich auf ein gemeinsames Geheimnis s einigen wollen und ihr einziges Kommunikationsmittel ein öffentlicher Kanal ist, können sie wie folgt vorgehen: + - A wählt eine Primzahl p, eine primitive Wurzel g von $\mathbb{Z}^*_p$ und eine Zufallszahl q: + - A und B können sich vor der Kommunikation auf die Werte p und g einigen, oder A wählt p und g und sendet sie mit seiner ersten Nachricht + - A berechnet $v=g^q\ MOD\ p$ und sendet an $B:\{p,g,v\}$ + - B wählt eine Zufallszahl r: + - B berechnet $w=g^r\ MOD\ p$ und sendet an $A:\{p,g,w\}$ (oder einfach $\{w\}$) + - Beide Seiten errechnen das gemeinsame Geheimnis: + - A errechnet $s=w^q\ MOD\ p$ + - B errechnet $s'=v^r\ MOD\ p$ + - Da $g^{q\mal r}\ MOD\ p = g^{r \mal q}\ MOD\ p$ ist, gilt: $s=s'$ + - Ein Angreifer Eve, der den öffentlichen Kanal abhört, kann das Geheimnis s nur berechnen, wenn er entweder q oder r berechnen kann, die die diskreten Logarithmen von v, w modulo p zur Basis g sind. +- Wenn der Angreifer Eve in der Lage ist, Nachrichten auf dem öffentlichen Kanal zu verändern, kann er einen Man-in-the-Middle-Angriff starten: + - Eve generiert zwei Zufallszahlen $q'$ und $r'$: Eve berechnet $v'=g^{q'}\ MOD\ p$ und $w'=g^{r'}\ MOD\ p$ + - Wenn A $\{p,g,v\}$ sendet, fängt sie die Nachricht ab und sendet an $B:\{p,g,v'\}$ + - Wenn B $\{p,g,w\}$ sendet, fängt sie die Nachricht ab und sendet an $A:\{p,g,w'\}$ + - Wenn das angebliche ,,gemeinsame Geheimnis'' berechnet wird, erhalten wir: + - A berechnet $s_1=w'^q\ MOD\ p = v^{r'}\ MOD\ p$, letzteres berechnet von E + - B berechnet $s_2=v'^r\ MOD\ p = w^{q'}\ MOD\ p$, letzteres berechnet von E + - A und E haben sich also auf ein gemeinsames Geheimnis $s_1$ geeinigt, und E und B haben sich auf ein gemeinsames Geheimnis $s_2$ geeinigt. + - Wenn das ,,gemeinsame Geheimnis'' nun von A und B verwendet wird, um Nachrichten zu verschlüsseln, die über den öffentlichen Kanal ausgetauscht werden sollen, kann E alle Nachrichten abfangen und ent- bzw. wiederverschlüsseln, bevor er sie zwischen A und B weiterleitet. +- Zwei Gegenmaßnahmen gegen den Man-in-the-Middle-Angriff: + - Das gemeinsame Geheimnis wird ,,authentifiziert'', nachdem es vereinbart worden ist. + - Wir werden dies im Abschnitt über die Schlüsselverwaltung behandeln + - A und B verwenden ein sogenanntes Interlock-Protokoll, nachdem sie sich auf ein gemeinsames Geheimnis geeinigt haben: + - Dazu müssen sie Nachrichten austauschen, die E weiterleiten muss, bevor sie sie entschlüsseln bzw. wieder verschlüsseln kann. + - Der Inhalt dieser Nachrichten muss von A und B überprüfbar sein. + - Dies zwingt E dazu, Nachrichten zu erfinden, und sie kann entdeckt werden. + - Eine Technik, um zu verhindern, dass E die Nachrichten entschlüsselt, besteht darin, sie in zwei Teile aufzuteilen und den zweiten Teil vor dem ersten zu senden. + - Wenn der verwendete Verschlüsselungsalgorithmus bestimmte Eigenschaften verhindert, kann E den zweiten Teil nicht verschlüsseln, bevor sie den ersten erhält. + - Da A den ersten Teil erst senden wird, nachdem er eine Antwort (den zweiten Teil) von B erhalten hat, ist E gezwungen, zwei Nachrichten zu erfinden, bevor sie die ersten Teile erhalten kann. +- Bemerkung: In der Praxis muss die Zahl g nicht unbedingt eine Urwurzel von p sein, es genügt, wenn sie eine große Untergruppe von $\mathbb{Z}^*_p$ erzeugt -## The ElGamal Algorithm -- The ElGamal algorithm can be used for both, encryption and digital signatures (see also [ElG85a] ) -- Like the DH exchange it is based on the difficulty of computing discrete logarithms in finite fields -- In order to set up a key pair: - - Choose a large prime p, a generator g of the multiplicative group $\mathbb{Z}^*_p$ and a random number v such that $1\leq v\leq p - 2$. Calculate: $y=g^v mod p$ - - The public key is $( y, g, p )$ - - The private key is v -- To sign a message m : - - Choose a random number k such that k is relatively prime to $p-1$. - - Compute $r=g^k mod p$ - - With the Extended Euclidean Algorithm compute $k^{-1}$, the inverse of $k mod (p - 1)$ - - Compute $s=k^{-1} \times ( m - v \times r) mod ( p - 1)$ - - The signature over the message is $( r, s )$ -- To verify a signature $( r , s )$ over a message m: - - Confirm that $y^r \times r^s\ MOD\ p = g^m\ MOD\ p$ - - Proof: We need the following - - Lemma 3: Let p be prime and g be a generator of $\mathbb{Z}^*_p$. Then $i \equiv j mod ( p -1) \Rightarrow g i \equiv g j mod p$ - - Proof: $i\equiv j mod (p-1) \Rightarrow$ there exists $k\in \mathbb{Z}^+$ such that $(i-j)=(p-1)\times k$ - - So, $g^{(i-j)}=g^{(p-1)\times k} \equiv 1^k\equiv 1 mod p$, because of Theorem 3 (Euler) $\Rightarrow g^i \equiv g^j mod p$ - - So as $s\equiv k^{-1}\times(m-v\times r) mod (p-1)$ +## ElGamal Algorithmus +- Der ElGamal-Algorithmus kann sowohl für die Verschlüsselung als auch für digitale Signaturen verwendet werden (siehe auch [ElG85a]). +- Wie der DH-Austausch basiert er auf der Schwierigkeit, diskrete Logarithmen in endlichen Feldern zu berechnen +- Um ein Schlüsselpaar zu erstellen: + - Wähle eine große Primzahl p, einen Generator g der multiplikativen Gruppe $\mathbb{Z}^*_p$ und eine Zufallszahl v, so dass $1\leq v\leq p - 2$. Berechnen Sie: $y=g^v mod p$ + - Der öffentliche Schlüssel ist $( y, g, p )$ + - Der private Schlüssel ist v +- So signieren Sie eine Nachricht m : + - Wähle eine Zufallszahl k so, dass k relativ prim zu $p-1$ ist. + - Berechne $r=g^k mod p$ + - Berechne mit dem erweiterten euklidischen Algorithmus $k^{-1}$, den Kehrwert von $k mod (p - 1)$ + - Berechne $s=k^{-1} \mal ( m - v \mal r) mod ( p - 1)$ + - Die Signatur über die Nachricht ist $( r, s )$ +- Überprüfen einer Signatur $( r , s )$ über eine Nachricht m: + - Bestätige, dass $y^r \times r^s\ MOD\ p = g^m\ MOD\ p$ + - Der Beweis: Wir benötigen Folgendes + - Lemma 3: Sei p eine Primzahl und g ein Generator von $\mathbb{Z}^*_p$. Dann sei $i \equiv j mod ( p -1) \Rightarrow g i \equiv g j mod p$ + - Beweis: $i \equiv j mod (p-1) \Rightarrow$ es gibt $k\in \mathbb{Z}^+$ so, dass $(i-j)=(p-1)\mal k$ + - Also $g^{(i-j)}=g^{(p-1)\mal k} \equiv 1^k\equiv 1 mod p$, wegen Theorem 3 (Euler) $\Rightarrow g^i \equiv g^j mod p$ + - Als $s\equiv k^{-1}\times(m-v\times r) mod (p-1)$ - $\Leftrightarrow k \times s\equiv m-v\times r mod (p-1)$ - $\Leftrightarrow m \equiv v\times r+k\times s mod (p-1)$ - - $\Rightarrow g^m \equiv g^{(v\times r+ k\times s)} mod p$ with Lemma 3 - - $\Leftrightarrow g^m \equiv g^{(v\times r)}\times g^{(k\times s)} mod p$ - - $\Leftrightarrow g^m \equiv y^r\times r^s mod p$ -- Security of ElGamal signatures: - - As the private key v is needed to be able to compute s, an attacker would have to compute the discrete logarithm of y modulo p to the basis g in order to forge signatures - - It is crucial to the security, that a new random number k is chosen for every message, because an attacker can compute the secret v if he gets two messages together with their signatures based on the same k (see [Men97a], Note 11.66.ii) - - In order to prevent an attacker to be able to create a message M with a matching signature, it is necessary not to sign directly the message M as explained before, but to sign a cryptographic hash value $m=h(M)$ of it (these will be treated soon, see also [Men97a], Note 11.66.iii) -- To encrypt a message m using the public key $(y,g,p)$: - - Choose a random $k\in\mathbb{Z}^+$ with $k 512 | -- The security also heavily depends on the implementation! - - The different cases (e.g. with O) in ECC calculation may be observable, i.e., power consumption and timing differences - - Attackers might deduct side-channel attacks, as in OpenSSL 0.9.8o [BT11] - - Attacker may deduce the bit length of a value k in $kP$ by measuring the time required for the square and multiply algorithm - - Algorithm was aborted early in OpenSSL when no further bits where set to ,,1'' - - Attackers might try to generate invalid points to derive facts about the used key as in OpenSSL 0.9.8g, leading to a recovery of a full 256-bit ECC key after only 633 queries [BBP12] -- Lesson learned: Do not do it on your own, unless you have to and know what you are doing! + | 112 | 2048 | 224-255 | + | 128 | 3072 | 256-383 | + | 192 | 7680 | 384-511 | + | 256 | 15360 | > 512 | +- Die Sicherheit hängt auch stark von der Implementierung ab! + - Die verschiedenen Fälle (z.B. mit O) in der ECC-Berechnung können beobachtbar sein, d.h. Stromverbrauch und Zeitunterschiede + - Angreifer können Seitenkanalangriffe ableiten, wie in OpenSSL 0.9.8o [BT11] + - Ein Angreifer kann die Bitlänge eines Wertes k in $kP$ ableiten, indem er die für den Quadrat- und Multiplikationsalgorithmus benötigte Zeit misst + - Der Algorithmus wurde in OpenSSL frühzeitig abgebrochen, wenn keine weiteren Bits auf ,,1'' gesetzt wurden + - Angreifer könnten versuchen, ungültige Punkte zu generieren, um Fakten über den verwendeten Schlüssel abzuleiten, wie in OpenSSL 0.9.8g, was zu einer Wiederherstellung eines vollen 256-Bit ECC-Schlüssels nach nur 633 Abfragen führte [BBP12] +- Lektion gelernt: Machen Sie es nicht selbst, es sei denn, Sie müssen es tun und wissen, was Sie tun! -### Foundations of ECC - Further remarks -- As mentioned earlier it is possible to construct cryptographic elliptic curves over $G(2^n)$, which may be faster in hardware implementations - - We refrained from details as this would not have brought many different insights! -- Elliptic curves and similar algebraic groups are an active field of research and allow other advanced applications e.g.: - - So-called Edwards Curves are currently discussed, as they seem more robust against side-channel attacks (e.g. [BLR08]) - - Bilinear pairings allow - - Programs to verify that they belong to the same group, without revealing their identity (Secret handshakes, e.g. [SM09]) - - Public keys to be structured, e.g. use ,,Alice'' as public key for Alice (Identity based encryption, foundations in [BF03]) -- Before deploying elliptic curve cryptography in a product, make sure to not violate patents, as there are still many valid ones in this field! +### Weitere Anmerkungen +- Wie bereits erwähnt, ist es möglich, kryptographische elliptische Kurven über $G(2^n)$ zu konstruieren, was in Hardware-Implementierungen schneller sein kann. + - Wir haben auf Details verzichtet, da dies nicht viele neue Erkenntnisse gebracht hätte! +- Elliptische Kurven und ähnliche algebraische Gruppen sind ein aktives Forschungsgebiet und ermöglichen weitere fortgeschrittene Anwendungen, z.B: + - Sogenannte Edwards-Kurven werden derzeit diskutiert, da sie robuster gegen Seitenkanalangriffe zu sein scheinen (z.B. [BLR08]) + - Bilineare Paarungen ermöglichen + - Programme zu verifizieren, dass sie zur selben Gruppe gehören, ohne ihre Identität preiszugeben (Secret Handshakes, z.B. [SM09]) + - Öffentliche Schlüssel können strukturiert werden, z.B. ,,Alice'' als öffentlicher Schlüssel für Alice verwenden (Identitätsbasierte Verschlüsselung, Grundlagen in [BF03]) +- Bevor Sie elliptische Kurvenkryptographie in einem Produkt einsetzen, stellen Sie sicher, dass Sie keine Patente verletzen, da es noch viele gültige Patente in diesem Bereich gibt! -## Conclusion -- Asymmetric cryptography allows to use two different keys for: - - Encryption / Decryption - - Signing / Verifying -- The most practical algorithms that are still considered to be secure are: - - RSA, based on the difficulty of factoring and solving discrete logarithms - - Diffie-Hellman (not an asymmetric algorithm, but a key agreement protocol) - - ElGamal, like DH based on the difficulty of computing discrete logarithms -- As their security is entirely based on the difficulty of certain mathematical problems, algorithmic advances constitute their biggest threat -- Practical considerations: - - Asymmetric cryptographic operations are about magnitudes slower than symmetric ones - - Therefore, they are often not used for encrypting / signing bulk data - - Symmetric techniques are used to encrypt / compute a cryptographic hash value and asymmetric cryptography is just used to encrypt a key / hash value +## Schlussfolgerung +- Asymmetrische Kryptographie erlaubt es, zwei verschiedene Schlüssel zu verwenden: + - Verschlüsselung / Entschlüsselung + - Signieren / Überprüfen +- Die praktischsten Algorithmen, die immer noch als sicher gelten, sind: + - RSA, basierend auf der Schwierigkeit, diskrete Logarithmen zu faktorisieren und zu lösen + - Diffie-Hellman (kein asymmetrischer Algorithmus, sondern ein Schlüsselvereinbarungsprotokoll) + - ElGamal, wie DH basierend auf der Schwierigkeit, diskrete Logarithmen zu berechnen +- Da ihre Sicherheit vollständig auf der Schwierigkeit bestimmter mathematischer Probleme beruht, stellt der algorithmische Fortschritt ihre größte Bedrohung dar. +- Praktische Überlegungen: + - Asymmetrische kryptografische Operationen sind um Größenordnungen langsamer als symmetrische Operationen. + - Daher werden sie oft nicht für die Verschlüsselung/Signierung von Massendaten verwendet. + - Symmetrische Verfahren werden zur Verschlüsselung / Berechnung eines kryptografischen Hashwerts verwendet, während die asymmetrische Kryptografie nur zur Verschlüsselung eines Schlüssels / Hashwerts eingesetzt wird. # Modifikationsprüfwerte @@ -1260,7 +1261,7 @@ Greatest common divisor - [Sta13] W. Stallings - Cryptography and Network Security: Principles and Practice - [Sti05] D. R. Stinson - Cryptography: Theory and Practice (Discrete Mathematics and Its Applications) - [Bre88a] D. M. Bressoud. - Factorization and Primality Testing -- [Cor90a] T. H. Cormen, C. E. Leiserson, R. L. Rivest. _Introduction to Algorithms. +- [Cor90a] T. H. Cormen, C. E. Leiserson, R. L. Rivest. Introduction to Algorithms. - [DH76] W. Diffie, M. E. Hellman - New Directions in Cryptography - [ElG85a] T. ElGamal - A Public Key Cryptosystem and a Signature Scheme based on Discrete Logarithms. - [Kob87a] N. Koblitz - A Course in Number Theory and Cryptography @@ -1268,7 +1269,7 @@ Greatest common divisor - [Niv80a] I. Niven, H. Zuckerman - An Introduction to the Theory of Numbers - [RSA78] R. Rivest, A. Shamir und L. Adleman - A Method for Obtaining Digital Signatures and Public Key Cryptosystems - [KAFL10] T. Kleinjung, K. Aoki, J. Franke, A. Lenstra, E. Thomé, J. Bos, P. Gaudry, A. Kruppa, P. Montgomery, D. Osvik, H. Te Riele, A.Timofeev, P. Zimmermann - Factorization of a 768-bit RSA modulus -- [LM10] M. Lochter, J. Merkle - Elliptic Curve Cryptography (ECC) Brainpool Standard Curves and Curve Generation_ +- [LM10] M. Lochter, J. Merkle - Elliptic Curve Cryptography (ECC) Brainpool Standard Curves and Curve Generation - [NIST99] NIST - Recommended Elliptic Curves for Federal Government Use - [NIST12] NIST - Recommendation for Key Management: Part 1: General (Revision 3) - [Ko87] N. Koblitz - Elliptic Curve Cryptosystems