[list=1][*]p, q Primfaktoren im CAS festlegen[/*][*]e auswählen → Slider grün → phi, e teilerfremd) -[color=#0000ff] public key[/color] [br][/*][*]Extended Euklid einstellen → n[sub]d[/sub] Slider grün → Iterationstiefe OK bei ExtGDC([color=#ff0000]0[/color]) - [color=#0000ff]private key[/color][br][/*][*]Alternative Berechnung d: Suchtiefe [color=#0000ff]k[/color] n[sub]d[/sub] (ggf. erhöhen von [color=#0000ff]k[/color] [sub](10)[/sub], wenn kein d gefunden wird)[/*][*]Im CAS stößt man nicht so schnell an ein Zahlenlimit (10000 Stellen siehe Bild unten). Den ExtGCD zur Berechnung der Modulo-Inversen (zu e) hab ich trotzdem in der AlgebraView versteckt - er benötigt 3 Arrays und würde die Übersichtlichkeit im CAS stören. [br][/*][*]Berechnung ExtGCD in einer Matrix, weicht jedoch von dem bekannten a,b,q,r,x,y Muster ab.[i][br]Iextgcd=[/i][size=85][i]IterationList({ Element(X, 2), Element(X, 1)-floor(Element(X, 1)/Element(X, 2)) Element(X, 2) , Element(X, 5), Element(X, 6), Element(X, 3)-floor(Element(X, 1)/Element(X, 2))*Element(X, 5), Element(X, 4)-floor(Element(X, 1)/Element(X, 2))*Element(X, 6) } ,X, {{a,b,1,0,0,1}}, nn)[br][/i][size=100]Mit nn Iterationstiefe angeben - Ergebnis in letzter Zeile Spalte 1,3,4! (siehe Aufgabe 2)[/size][/size][/*][/list] [br][size=150]Binäre Exponentiation[/size][br][br]EXTMOD(a,b,m) → a[sup]b[/sup] mod m [b]"große" Exponenten modulo n[/b] [b]"schnell"[/b] berechnen - [color=#0000ff]CAS function[/color][br][br][i]Beispiel[/i]:[br][br][math]\large 31^{99}\, mod\, 101[/math][br][br][i]wandel des Exponenten in eine [/i][b][i]Binärzahl [/i][br][/b][br][math]99_{(10)}=1100011_{(2)}[/math][br][br][math]\large \begin{array}{rr} 31^{2^0}= 31^{1} = 31 \equiv \textcolor{red}{31} \; mod\; 101&1\\[br]31^{2^1} = \textcolor{red}{31}^2 = 961\equiv \, \textcolor{red}{52}\; mod\; 101&1\\[br]31^{2^2} = 31^4=\textcolor{red}{52}^2=2704\equiv \textcolor{red}{78}\; mod\; 101&0\\[br]31^{2^3} = 31^8=\textcolor{red}{78}^2= 6084\equiv \textcolor{red}{24}\; mod\; 101&0\\[br]31^{2^4} =31^{16}=\textcolor{red}{24}^2=576\equiv \textcolor{red}{71}\; mod\; 101&0\\[br]31^{2^5} = 31^{32}=\textcolor{red}{71}^2=5041\equiv \textcolor{red}{92}\; mod\; 101&1\\[br]31^{2^6} = 31^{64}=\textcolor{red}{92}^2= 8464\equiv \textcolor{red}{81}\; mod\; 101&1\\\end{array}[br][/math][br][br][i]Alle Stellen-Werte an der die Binärzahl 1 steht miteinander multiplizieren. [/i][br][i] [b]Binärzahl die Länge 7[/b]. Führen auf insgesamt [b]"nur" 7 Zwischenrechnungen[/b] [/i](Rekursion)[br][math] 31^{99}\, mod\, 101 \to 31^{1100011_{2}}\, mod\, 101 \to b_i=b_{i-1}^2\, mod\, 101 \to \prod_{bit=1}^{11001_2} b_{i}\, mod\, 101 \to b_i \, = \, \left(\begin{array}{rr}6&81\\5&92\\4&71\\3&24\\2&78\\1&52\\0&31\\\end{array}\right) [/math][br][math]31\cdot 52\cdot 92\cdot 81 = 12012624 \equiv 88\; mod\; 101 \to[/math] [i]Mod(Mod([b]81 92[/b],101) Mod([b]52 31[/b],101),101)[/i])[br][br][math]31 \cdot 88 \equiv 1\; mod\; 101[/math][sub]modinv if mod prim[/sub] [br][br]Trick: einen öffentlichen Schlüssel e wählen mit möglichst wenigen 1 Bits![br][i]Beispiel App . mögliche Schlüssel e=31 (11111[sub]2[/sub]) oder e=37 (100101[sub]2[/sub])[/i][br]
Zahlenlimit - (CAS ist limitiert auf 10000 Stellen)[br]Größerer public key transportiert größeren Wert msg
Alice sendet an Bob die Nachricht (C1,C2) = (204,8), bestehend aus zwei [br]Einzelnachrichten, welche sie beide zuvor mit Bobs öffentlichem [br]RSA-Schlüssel (e,N) = (47,221) chiffriert hat. [br]Wie lautet die entschlüsselte Nachricht, wenn Alice eine ASCII-Tabelle verwendet hat. [br]Begründen Sie Ihr Vorgehen!
n=221 ==> factor(221)=13*17 ==> p q ==> phi 192[br][br]e public key: (47,221)[br][br]d private key: (143,221)[br][math]{\begin{array}{|r|r|r|r|r|r|}a&b&q&r&x&y \\ 192&47&4&4&12&-49 \\ 47&4&11&3&-1&12 \\ 4&3&1&1&1&-1 \\ 3&1&3&0&0&1 \\ \end{array}}[/math][br]-49+phi = 143[br][br]msg[br]EXPMOD(204,143,n)=68 [br][br][math]\prod_{k=1}^{6}[/math]{1, 1, 1, 1, [sub][color=#ff0000]0[/color][/sub], 1} {204, 68, 204, 68, [color=#ff0000][sub]204[/sub][/color], 68} = 13085402112 mod n = 68 ([color=#0000ff]D[/color])[sub]UnicodeToLetter(68)[/sub][br][i]Mod(Mod(Mod(204 68,n)^2,n) 68,n)[/i][br][i]Iteration(Flatten({Mod(Product(Take(X, 1, 2)), n), Take(X, 3)}), X, {[/i][math]\prod_{k=1}^{6}\backslash\{0\}[/math][i]}, 4)[/i] [br][br]EXPMOD(8,d,n)=83[br][br][math]\prod_{k=1}^{6}[/math]{1, 1, 1, 1, [sub][color=#ff0000]0[/color][/sub], 1} {8, 64, 118, 1, [sub][color=#ff0000]1[/color][/sub], 1} = 60416 mod n = 83 ([color=#0000ff]S[/color])[sub]UnicodeToLetter(83)[/sub]
Ein RSA-Verfahren mit privatem Schlüssel (d,n) = (21191,47053)[br]Berechnen Sie den öffentlichen Schlüssel e und [br]codieren Sie damit die zu übertragende Nachricht msg=1061.[br]
[i]Factor(47053)[br]p:=211[br]q:=223[br][/i][br]n = p q = 47053 ==> phi = (p-1)(q-1) = 46620[br][br][i]e d mod phi = 1[br][/i][br]e inverse zu privatem schlüssel d mod phi[br]activate [i]Iextgcd [/i][br][size=85][i]IterationList({ Element(X, 2), Element(X, 1)-floor(Element(X, 1)/Element(X, 2)) Element(X, 2) , Element(X, 5), Element(X, 6), Element(X, 3)-floor(Element(X, 1)/Element(X, 2))*Element(X, 5), Element(X, 4)-floor(Element(X, 1)/Element(X, 2))*Element(X, 6) } ,X, {{[b]21191[/b],[b]phi[/b],1,0,0,1}}, [b]4[/b])[/i][/size][br][math]\small \left(\begin{array}{rrrrrr}21191&46620&1&0&0&1\\46620&21191&0&1&1&0\\21191&4238&1&0&-2&1\\4238&1&-2&1&11&-5\\\textcolor{red}{1}&0&\textcolor{red}{11}&\textcolor{red}{-5}&-46620&21191\\\end{array}\right)[br][/math][br][br][i]Mod(([color=#ff0000]11[/color]) 21191,phi)=1[/i][br][br]==> e=11 ==> d = 21191 [br][br][i]msg:= 1061[/i][br]code = 4711
e encrypt - d decrypt - N msg[br][br][math]\large \left(N^{e}\right)^{d}=N [/math][br][math]\large[br]e d \equiv 1 \quad(\bmod \varphi(n))[br][/math][br][br]Es gibt also ein [math] k \in \mathbb{Z} [/math] mit:[br][br][math]\large[br]e d=1+k \varphi(n)=1+k(p-1)(q-1)=1+k^{\prime}(p-1)[br][/math][br][br]Fall 1: [math]\large p \nmid N . \ln \mathbb{Z}_{p} [/math] gilt [math] N^{p-1}=1 [/math] (Fermat) und:[br][br][math]\large[br]N^{e d}=N^{1+k^{\prime}(p-1)}=N \cdot\left(N^{p-1}\right)^{k^{\prime}}=N \cdot 1^{k^{\prime}}=N[br][/math][br][br]Fall 2: [math]\large p \mid N [/math], also [math] N=0 [/math] in [math]\large \mathbb{Z}_{p} [/math] und damit natürlich auch [math]\large N^{e d}=N [/math].[br][br]Wir haben somit [math] p \mid N^{e d}-N [/math] und ebenso [math] q \mid N^{e d}-N [/math].[br][br]Da [math] p [/math] und [math] q [/math] teilerfremd sind, folgt [math] p q \mid N^{e d}-N [/math].[br][br]entnommen [url=https://www.youtube.com/watch?v=mDRMzBlI3U4]E.Weitz Das RSA-Kryptosystem[math]\nearrow[/math][/url][br]