Initial commit

This commit is contained in:
Valentin Brandl
2018-10-13 13:23:37 +02:00
commit 1ad2f0e3ab
32 changed files with 2541 additions and 0 deletions

View File

@ -0,0 +1,28 @@
digraph classification {
edge [ arrowhead="none" ];
1 [ label="Kryptologie" ];
2 [ label="Kryptographie" ];
3 [ label="Kryptoanalyse" ];
4 [ label="symmetrische\nChiffren" ];
5 [ label="asymmetrische\nChiffren" ];
6 [ label="Protokolle\n& Sonstiges" ];
{
rank=same;
2;
3;
}
{
rank=same;
4;
5;
6;
}
1 -> 2;
1 -> 3;
2 -> 4;
2 -> 5;
2 -> 6;
}

View File

@ -0,0 +1,26 @@
---
title: Intro
date: 2018-10-11
---
# Moodle
**Kursnummer**: 141022
**Passwort** : krypto1819
# Klausur
* 10% Bonus durch Übungen, nur wenn bestanden (>49%)
* Anmeldung im Prüfungsamt
## Hilfsmittel
* Taschenrechner
* 1 Seite handschriftlich
# Übungen
**Abgabe**: Donnerstag 12:14 Uhr
Handschriftlich oder LaTeX (Vorlage vorhanden)

View File

@ -0,0 +1,59 @@
---
title: Klassifikation, Grundlagen, Substitutionschiffre
date: 2018-10-11
---
# Klassifikation der "Kryptographie"
![Klassifikation](./20181011-classification.png)
## Anwendungen
* WhatsApp
* Auto
* Mensa Karte
* Medizinische Geräte
* Kreditkarten
* mobile Kommunikation
* IoT
* BitCoin
* Flugzeuge
* E-Mail
* (Schadsoftware)
# Grundlagen symmetrischer Chiffren
Einfache Ausgangssituation:
![Ausgangssituation](./20181011_situation.png)
* $e \widehat{=}$ Verschlüsselung oder Chiffrierung
* $d \widehat{=}$ Entschlüsselung oder Dechiffrierung
* $x \widehat{=}$ Klartext
* $y \widehat{=}$ Chiffrat
* $k \widehat{=}$ Schlüssel
* $\vert k \vert \widehat{=}$ Schlüsselraum
## Kerckhoffs' Prinzip
> Ein Kryptosystem muss auch dann sicher sein, wenn der Angreifer alle Deteils kennt, bis auf den Schlüssel.
Bei Verletzung der Prinzips: `Security by Obscurity`.
# Substitutionschiffre
* operiert auf Buchstaben
* Prinzip:
$$
A \to l \\
B \to d \\
C \to w \\
...
$$
**Beispiel**: $ABBA \to^e lddl$
## Angriffe
1. Häufigkeitsanalyse (Übung)
2. Vollständige Schlüsselsuche (Bruteforce): $\vert k \vert = 26! \approx 2^{88}$ Möglichkeiten

View File

@ -0,0 +1,51 @@
digraph situation {
rankdir=LR;
a [ label="Alice" shape="none" ];
b [ label="Bob" shape="none" ];
o [ label="Oscar" shape="none" ];
i [ label="unsicherer\nKanal" ];
e [ label="e" shape="box" ];
d [ label="d" shape="box" ];
g [ label="Gen" shape="box"];
1 [ style="invisible" shape="point" width=0 ];
2 [ style="invisible" shape="point" width=0 ];
3 [ style="invisible" shape="point" width=0 ];
4 [ style="invisible" shape="point" width=0 ];
{
rank=same;
a;
g;
}
{
rank=same;
e;
1;
}
{
rank=same;
d;
2;
}
{
rank=same;
i; o;
}
a -> e [ label="x" ];
e -> i [ label="y" ];
i -> d [ label="y" ];
d -> b [ label="x" ];
g -> 1 [ arrowhead="none" ];
1 -> e [ label="k" ];
1 -> 3 [ arrowhead="none" ];
3 -> 4 [ arrowhead="none"; penwidth=10; label="sicherer Kanal\n " ];
4 -> 2 [ arrowhead="none" ];
2 -> d [ label="k" ];
i -> o [ label="y" ];
}

View File

@ -0,0 +1,51 @@
digraph situation {
rankdir=LR;
a [ label="Alice" shape="none" ];
b [ label="Bob" shape="none" ];
o [ label="Oscar" shape="none" ];
i [ label="unsicherer\nKanal" ];
e [ label="e" shape="box" ];
d [ label="d" shape="box" ];
g [ label="Gen" shape="box"];
1 [ style="invisible" shape="point" width=0 ];
2 [ style="invisible" shape="point" width=0 ];
3 [ style="invisible" shape="point" width=0 ];
4 [ style="invisible" shape="point" width=0 ];
{
rank=same;
a;
g;
}
{
rank=same;
e;
1;
}
{
rank=same;
d;
2;
}
{
rank=same;
i; o;
}
a -> e [ label="x" ];
e -> i [ label="y" ];
i -> d [ label="y" ];
d -> b [ label="x" ];
g -> 1 [ arrowhead="none" ];
1 -> e [ label="k" ];
1 -> 3 [ arrowhead="none" ];
3 -> 4 [ arrowhead="none"; penwidth=10; label="sicherer Kanal\n " ];
4 -> 2 [ arrowhead="none" ];
2 -> d [ label="k" ];
i -> o [ label="y" ];
}

View File

@ -0,0 +1,99 @@
\documentclass[12pt,a4paper,german]{article}
\usepackage{url}
%\usepackage{graphics}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{paralist}
\geometry{left=2.0cm,textwidth=17cm,top=3.5cm,textheight=23cm}
%%%%%%%%%% Fill out the the definitions %%%%%%%%%
\def \name {Valentin Brandl} %
\def \matrikel {108018274494} %
\def \gruppe {VB} %
\def \uebung {1} %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT MODIFY THIS HEADER
\newcommand{\hwsol}{
\vspace*{-2cm}
\noindent \matrikel \quad \name \hfill Gruppe:\gruppe \\
% \noindent \pmatrikel \quad \pname \\
\begin{center}{\Large \bf L\"osung f\"ur \"Ubung \# \uebung}\end{center}
}
\begin{document}
%Import header
\hwsol
\section*{Aufgabe 1}
\begin{enumerate}[(a)]
\item
\begin{itemize}
\item Algorithmen sollen offengelegt werden, nur Schl<68>ssel werden geheim gehalten
\item Es ist schwer, einen Algorithmus geheim zu halten
\item Prinzip def vielen Augen: ein <20>ffentlicher Algorithmus wird ggf. analysiert und Schwachstellen gefunden
\end{itemize}
\item
\begin{itemize}
\item Kryptographie: Entwerfen von Algorithmen und Protokollen
\item Kryptoanalyse: Schwachstellen in existierenden Verfahren suchen
\end{itemize}
\item
\parbox{\linewidth}{\centering
\includegraphics[width=\textwidth]{20181011_situation.png}
}
Ein Angreifer (Eve) kann die ausgetauschten Nachrichten mitlesen und ver<65>ndern
\item
\begin{itemize}
\item Schl<68>ssel: $k$
\item Verschl<68>sselung $e(\cdot)$
\item Schl<68>sselraum $\#k = \vert k \vert$
\item Chiffrat $y$
\item Entschl<68>sselung $d(\cdot)$
\item Klartext $x$
\end{itemize}
\end{enumerate}
\section*{Aufgabe 2}
\begin{enumerate}[(a)]
\item $2^{128}$. Mit $2^{10} \approx 10^3 \to 2^{130} \approx 10^{39}$
\item
\begin{itemize}
\item 80 Eur pro ASIC
\item $10^6$ Eur Kapital
\item $7 \cdot 10^8 \frac{k}{s}$ Leistung
\end{itemize}
\begin{eqnarray*}
10^6 / 80 &=& 12500 \\
7 \cdot 10^8 \cdot 12500 &=& 8.75 \cdot 10^{12} \frac{k}{s} \\
\frac{2^{128}k}{8.75 \cdot 10^{12} \frac{k}{s}} &\approx{}& 3.89 \cdot 10^{25} s \\
&\approx{}& 1.23 \cdot 10^{18} y
\end{eqnarray*}
\item
\begin{eqnarray*}
24 h &=& 86400 s \\
\frac{2^{128}}{x} &=& 86400 \\
\frac{2^{128}}{86400} &=& x \\
x &\approx{}& 3.94 \cdot 10^{33} \text{ gesuchte $\frac{k}{s}$} \\
\frac{x}{12500} &\approx{}& 3.15 \cdot 10^{29} \text{ gesuchte $\frac{k}{s}$ pro ASIC} \\
\\
(7 \cdot 10^8) \cdot 2^n &\geq{}& 3.15 \cdot 10^{29} \\
n &\geq{}& 68.6 \approx 69 \text{ (Leistung muss sich 69 mal verdoppeln)} \\
69 * 18m &=& 1242m = 103.5 y
\end{eqnarray*}
In $103.5$ Jahren w<>re man in der Lage alle $2^{128}$ Schl<68>ssel innerhlab von 24h durch zu probieren.
\end{enumerate}
\end{document}

View File

@ -0,0 +1,67 @@
\documentclass[12pt,a4paper,german]{article}
\usepackage{url}
%\usepackage{graphics}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{paralist}
\geometry{left=2.0cm,textwidth=17cm,top=3.5cm,textheight=23cm}
%%%%%%%%%% Fill out the the definitions %%%%%%%%%
\def \name {Vorname1 Nachname1} %
\def \matrikel {Matrikelnummer1} %
\def \pname {Vorname2 Nachname2} %
\def \pmatrikel {Matrikelnummer2} %
\def \gruppe {Gruppenkuerzel} %
\def \uebung {1} %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT MODIFY THIS HEADER
\newcommand{\hwsol}{
\vspace*{-2cm}
\noindent \matrikel \quad \name \hfill Gruppe:\gruppe \\
\noindent \pmatrikel \quad \pname \\
\begin{center}{\Large \bf L\"osung f\"ur \"Ubung \# \uebung}\end{center}
}
\begin{document}
%Import header
\hwsol
\section*{Aufgabe 1}
\begin{enumerate}[(a)]
\item Beispielantwort
\item Hier k\"onnte deine Antwort auf diese Teilaufgabe stehen.
\item F<>r das Beispiel gilt $b_1=2^4+1=17=(10001)_2$ und $b_2=2^4-1=15=(1111)_2$.
\end{enumerate}
\section*{Aufgabe 2}
Notation von mathematischen L\"osungen:
\begin{eqnarray*}
r_{0} &=& \beta^{K_{X}} \bmod n\\
r_{1} &=& \alpha^{K_{X}+1} = \alpha \cdot \alpha^{K_{n}} = \alpha \cdot r_{1} \bmod p\\
r_{2} &=& (a_{1}-d \cdot q_{1}) \cdot z_{E}^{-1} \bmod p-1 \Leftrightarrow d = (x_{1}-s_{1} \cdot o_{E}) \cdot r_{1}^{-1} \bmod p-1\\
\end{eqnarray*}
\section*{Aufgabe 3}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Tabellenzeile & Tabellenzeile & Tabellenzeile & Tabellenzeile \\
\hline
e & f & g & h \\
\hline
i & j & k & l \\
\hline
m & n & o & p \\
\hline
\end{tabular}
\end{center}
\end{document}

View File

@ -0,0 +1,248 @@
\documentclass[12pt,a4paper,german]{article}
\usepackage{url}
%\usepackage{graphics}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage{float}
\usepackage{diagbox}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{paralist}
\geometry{left=2.0cm,textwidth=17cm,top=3.5cm,textheight=23cm}
%%%%%%%%%% Fill out the the definitions %%%%%%%%%
\def \name {Valentin Brandl} %
\def \matrikel {108018274494} %
% \def \pname {Vorname2 Nachname2} %
% \def \pmatrikel {Matrikelnummer2} %
\def \gruppe {Gruppenkuerzel} %
\def \uebung {1} %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT MODIFY THIS HEADER
\newcommand{\hwsol}{
\vspace*{-2cm}
\noindent \matrikel \quad \name \hfill Gruppe:\gruppe \\
% \noindent \pmatrikel \quad \pname \\
\begin{center}{\Large \bf L\"osung f\"ur \"Ubung \# \uebung}\end{center}
}
\begin{document}
%Import header
\hwsol
\section*{Aufgabe 2}
\begin{enumerate}[(a)]
\item
\begin{eqnarray*}
A &\text{:}& 23 \to{} 0.02 \\
B &\text{:}& 5 \to{} 0.00 \\
C &\text{:}& 22 \to{} 0.02 \\
D &\text{:}& 8 \to{} 0.01 \\
E &\text{:}& 17 \to{} 0.02 \\
F &\text{:}& 2 \to{} 0.00 \\
G &\text{:}& 80 \to{} 0.07 \\
J &\text{:}& 66 \to{} 0.06 \\
K &\text{:}& 39 \to{} 0.04 \\
L &\text{:}& 47 \to{} 0.04 \\
M &\text{:}& 2 \to{} 0.00 \\
N &\text{:}& 17 \to{} 0.02 \\
O &\text{:}& 63 \to{} 0.06 \\
P &\text{:}& 80 \to{} 0.07 \\
Q &\text{:}& 62 \to{} 0.06 \\
R &\text{:}& 57 \to{} 0.05 \\
S &\text{:}& 136 \to{} 0.12 \\
T &\text{:}& 6 \to{} 0.01 \\
U &\text{:}& 57 \to{} 0.05 \\
V &\text{:}& 6 \to{} 0.01 \\
W &\text{:}& 76 \to{} 0.07 \\
X &\text{:}& 25 \to{} 0.02 \\
Y &\text{:}& 8 \to{} 0.01 \\
Z &\text{:}& 83 \to{} 0.08 \\
\text{\"A} &\text{:}& 43 \to{} 0.04 \\
\text{\"O} &\text{:}& 14 \to{} 0.01 \\
\text{\"U} &\text{:}& 28 \to{} 0.03 \\
\text{<EFBFBD>} &\text{:}& 18 \to{} 0.02 \\
sum &\text{:}& 1090
\end{eqnarray*}
\item
\begin{displayquote}
gr<67>ndlich durchgecheckt steht sie da \\
und wartet auf den start - alles klar! \\
experten streiten sich um ein paar daten \\
die crew hat da noch ein paar fragen \\
doch der countdown l<>uft \\
\end{displayquote}
\item
\begin{tabular}{|c|c|}
\hline
von & zu \\\hline
A & f \\
B & <20> \\
C & g \\
D & j \\
E & <20> \\
F & x \\
G & n \\
J & i \\
K & m \\
L & c \\
M & <20> \\
N & v \\
O & d \\
P & r \\
Q & a \\
R & l \\
S & e \\
T & <20> \\
U & h \\
V & z \\
W & t \\
X & w \\
Y & p \\
Z & s \\
<09> & o \\
<09> & b \\
<09> & u \\
<09> & k \\
H/I & q/y \\
\hline
\end{tabular}
Weder H noch I kommen im Ciphertext vor, daher ist es nicht m<>glich, die Substitution von H/I eindeutig zu
bestimmen. Da jedoch auch weder q noch y im Plaintext vorkommen, muss entweder $H \to q \text{ und } I \to y$
oder $H \to y \text{ und } I \to q$ gelten.
\item $30! = \vert \{A,B,...Z,\text{<EFBFBD>},\text{<EFBFBD>},\text{<EFBFBD>},\text{<EFBFBD>}\} \vert!$
\item Name des Textes: Major Tom (v<>llig losgel<65>st) \\
Erscheinungsjahr: 1982
\end{enumerate}
\section*{Aufgabe 3}
\begin{enumerate}[(a)]
\item $2^{63} = 9,223,372,036,854,775,808$
\item $2^{63} * 0.03g = 276,701,161,105,643,260g \approx 276,701,161,106t$ \\
$277 \cdot 10^9 / 460 \cdot 10^6 \approx 602 \Rightarrow$ mehr als das 600-fache der j<>hrlichen Reisernte
\item $2^{10} * 0.1mm = 102.4mm = 1.204m$
\item
\begin{eqnarray*}
2^n * 0.1mm &\geq{}& 1,000,000mm \\
2^n &\geq{}& 10000000 \\
n &\geq{}& 24
\end{eqnarray*}
Man muss das Blatt 24 mal falten.
\item
\begin{eqnarray*}
2^n * 0.1mm &\geq{}& 384,400,000,000mm \\
2^n &\geq{}& 3,844,000,000,000 \\
n &\geq{}& 42
\end{eqnarray*}
Man muss das Blatt 42 mal falten.
\item
\begin{eqnarray*}
2^n * 0.1mm &\geq{}& 9,460,730,472,580,800,000mm \\
2^n &\geq{}& 94,607,304,725,808,000,000mm \\
n &\geq{}& 67
\end{eqnarray*}
Man muss das Blatt 67 mal falten.
\end{enumerate}
\section*{Aufgabe 4}
\begin{enumerate}[(a)]
\item $2^n$
\item $\frac{2^n}{2}$
\item Gerechnet mit $1y = 365d$
\begin{figure}[h]
\begin{tabular}{|l|l|l|l|}
\hline
\diagbox{Case}{$n$} & 80 & 112 & 192 \\\hline
Worst Case & $2.50 * 10^8y$ & $1.08 * 10^{18}y$ & $1.30 * 10^{42}y$ \\\hline
Average Case & $1.25 * 10^8y$ & $5.38 * 10^{17}y$ & $6.50 * 10^{41}y$ \\\hline
\end{tabular}
\caption{GPU}
\end{figure}
\begin{figure}[h]
\begin{tabular}{|l|l|l|l|}
\hline
\diagbox{Case}{$n$} & 80 & 112 & 192 \\\hline
Worst Case & $5.81 * 10^7y$ & $2.49 * 10^{17}y$ & $3.02 * 10^{41}y$ \\\hline
Average Case & $2.90 * 10^7y$ & $1.25 * 10^{17}y$ & $1.51 * 10^{41}y$ \\\hline
\end{tabular}
\caption{Amazon Cloud}
\end{figure}
\begin{figure}[h]
\begin{tabular}{|l|l|l|l|}
\hline
\diagbox{Case}{$n$} & 80 & 112 & 192 \\\hline
Worst Case & $3.41 * 10^7y$ & $1.46 * 10^{17}y$ & $1.77 * 10^{41}y$ \\\hline
Average Case & $1.70 * 10^7y$ & $7.32 * 10^{16}y$ & $8.85 * 10^{40}y$ \\\hline
\end{tabular}
\caption{FPGA}
\end{figure}
\item Unter Anwendung der Erkenntnisse aus e):
\begin{eqnarray*}
n &=& 80 \\
n + w &=& 112 \\
w &=& 32 \\
x &=& \frac{2^{112} - 2^{80}}{r} \\
\end{eqnarray*}
\begin{itemize}
\item $r_{GPU} = 15.3 * 10^7 \frac{k}{s}$
\item $r_{Amazon} = 66 * 10^7 \frac{k}{s}$
\item $r_{FPGA} = 11.25 * 10^8 \frac{k}{s}$
\end{itemize}
\begin{eqnarray*}
x_{GPU} &=& 1.06 * 10^{18}y \\
x_{Amazon} &=& 2.49 * 10^{17}y \\
x_{FPGA} &=& 1.46 * 10^{17}y \\
\end{eqnarray*}
\item
\begin{itemize}
\item $r$: Anzahl der Versuche pro Sekunde
\item $n$: Aktuelle Bit L<>nge der Schl<68>ssel
\item $w$: Verl<72>ngerung der Schl<68>ssell<6C>nge um $w$ Bit
\item $x$: Gesucht: Wie viel langsamer der Angriff wird
\end{itemize}
\begin{eqnarray*}
\frac{2^n}{r} + x &=& \frac{2^{n+w}}{r} \\
x &=& \frac{2^{n+w} - 2^n}{r} \\
x &=& \frac{2^n(2^w-1)}{r}
\end{eqnarray*}
\item
\begin{eqnarray*}
183d &=& 4392h \\\\
\frac{4392}{2^n} &\leq{}& 1 \\
n &\geq{}& 13 \Rightarrow \text{ 13 Verdoppelungen der Rechenleistung} \\\\
13 * 18m &=& 234 m = 19.5y \approx 20y \\
1992 + 20 &=& 2012
\end{eqnarray*}
Seit dem Jahr 2012 sollte es m<>glich sein, 50-bit Keys in weniger als 1 Stunde zu Bruteforcen.
\end{enumerate}
\end{document}

View File

@ -0,0 +1,60 @@
CPTGORJLU OÜPLUCSLUSLßW ZWSUW ZJS OQ
ÜGO XQPWSW QÜA OSG ZWQPW - QRRSZ ßRQP!
SFYSPWSG ZWPSJWSG ZJLU ÜK SJG YQQP OQWSG
OJS LPSX UQW OQ GÄLU SJG YQQP APQCSG
OÄLU OSP LÄÜGWOÄXG RBÜAW
SAASßWJNJWBW ÖSZWJKKW OQZ UQGOSRG
KQG NSPRBZZW ZJLU ÖRJGO QÜA OSG QGOSP'G
DSOSP XSJM CSGQÜ, XQZ NÄG JUK QÖUBGCW
DSOSP JZW JK ZWPSZZ, OÄLU KQDÄP WÄK
KQLUW SJGSG ZLUSPV
OQGG USÖW SP QÖ ÜGO
NERRJC RÄZCSREZW
NÄG OSP SPOS
ZLUXSÖW OQZ PQÜKZLUJAA
NERRJC ZLUXSPSRÄZ
OJS SPOQGVJSUÜGCZßPQAW JZW TÖSPXÜGOSG
QRRSZ RBÜAW YSPASßW, ZLUÄG ZSJW ZWÜGOSG
XJZZSGZLUQAWRJLUS SFYSPJKSGWS
OÄLU XQZ GTWVSG OJS QK SGOS, OSGßW
ZJLU KQDÄP WÄK
JK ßÄGWPÄRRVSGWPÜK, OQ XJPO KQG YQGJZLU
OSP ßÜPZ OSP ßQYZSR, OSP ZWJKKW DQ CQP GJLUW
"UQRRÄ KQDÄP WÄK, ßEGGSG ZJS UEPSG
XÄRR'G ZJS OQZ YPÄDSßW OSGG ZÄ VSPZWEPSG?"
OÄLU SP ßQGG GJLUWZ UEP'G
SP ZLUXSÖW XSJWSP
NERRJC RÄZCSREZW
NÄG OSP SPOS
ZLUXSÖW OQZ PQÜKZLUJAA
NERRJC ZLUXSPSRÄZ
OJS SPOS ZLUJKKSPW ÖRQÜ, ZSJG RSWVWSP AÜGß ßÄKKW
"CPTMW KJP KSJGS APQÜ", ÜGO SP NSPZWÜKKW
ÜGWSG WPQÜSPG GÄLU OJS SCÄJZWSG
KQDÄP WÄK OSGßW ZJLU, XSGG OJS XTZZWSG
KJLU ATUPW UJSP SJG RJLUW OÜPLU OQZ QRR
OQZ ßSGGW JUP GÄLU GJLUW, JLU ßÄKKS ÖQRO
KJP XJPO ßQRW
NERRJC RÄZCSREZW
NÄG OSP SPOS
ZLUXSÖW OQZ PQÜKZLUJAA
ZLUXSPSRÄZ
NERRJC RÄZCSREZW
NÄG OSP SPOS
ZLUXSÖW OQZ PQÜKZLUJAA
ZLUXSPSRÄZ
NERRJC RÄZCSREZW
NÄG OSP SPOS
ZLUXSÖW OQZ PQÜKZLUJAA
NERRJC ZLUXSPSRÄZ

View File

@ -0,0 +1,30 @@
A & f \\
B & ä \\
C & g \\
D & j \\
E & ö \\
F & x \\
G & n \\
J & i \\
K & m \\
L & c \\
M & ß \\
N & v \\
O & d \\
P & r \\
Q & a \\
R & l \\
S & e \\
T & ü \\
U & h \\
V & z \\
W & t \\
X & w \\
Y & p \\
Z & s \\
Ä & o \\
Ö & b \\
Ü & u \\
ß & k \\
? & q \\
? & y \\

View File

@ -0,0 +1,2 @@
/target
**/*.rs.bk

View File

@ -0,0 +1,32 @@
[[package]]
name = "countmap"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "u01"
version = "0.1.0"
dependencies = [
"countmap 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum countmap 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ef2a403c4af585607826502480ab6e453f320c230ef67255eee21f0cc72c0a6"
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"

View File

@ -0,0 +1,7 @@
[package]
name = "u01"
version = "0.1.0"
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
[dependencies]
countmap = "0.2.0"

View File

@ -0,0 +1,81 @@
extern crate countmap;
use countmap::CountMap;
use std::{
fs::File,
io::{BufRead, BufReader},
};
fn count() {
let args: Vec<_> = std::env::args().collect();
let file = args.get(1).unwrap();
let mut map: CountMap<char, u32> = CountMap::new();
let read = BufReader::new(File::open(file).unwrap());
for line in read.lines() {
if let Ok(line) = line {
line.chars().filter(|c| c.is_alphabetic()).for_each(|c| {
map.insert_or_increment(c);
});
}
}
let sum: u32 = map
.iter()
.filter(|(k, _)| k.is_alphabetic())
.map(|(_, v)| v)
.sum();
let mut vec: Vec<_> = map.into_iter().collect();
vec.sort_unstable();
vec.into_iter().for_each(|(k, v)| {
println!(
"{} &\\text{{:}}& {:3} \\to{{}} {:.2} \\\\",
k,
v,
v as f64 / sum as f64
)
});
println!("sum &\\text{{:}}& {}", sum);
}
fn main() {
let args: Vec<_> = std::env::args().collect();
let file = args.get(1).unwrap();
let read = BufReader::new(File::open(file).unwrap());
for line in read.lines() {
if let Ok(line) = line {
let s: String = line
.chars()
.map(|c| match c {
'A' => 'f',
'B' => 'ä',
'C' => 'g',
'D' => 'j',
'E' => 'ö',
'F' => 'x',
'G' => 'n',
'J' => 'i',
'K' => 'm',
'L' => 'c',
'M' => 'ß',
'N' => 'v',
'O' => 'd',
'P' => 'r',
'Q' => 'a',
'R' => 'l',
'S' => 'e',
'T' => 'ü',
'U' => 'h',
'V' => 'z',
'W' => 't',
'X' => 'w',
'Y' => 'p',
'Z' => 's',
'Ä' => 'o',
'Ö' => 'b',
'Ü' => 'u',
'ß' => 'k',
c => c,
}).collect();
println!("{}", s);
}
}
}

Binary file not shown.

View File

@ -0,0 +1,67 @@
\documentclass[12pt,a4paper,german]{article}
\usepackage{url}
%\usepackage{graphics}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{paralist}
\geometry{left=2.0cm,textwidth=17cm,top=3.5cm,textheight=23cm}
%%%%%%%%%% Fill out the the definitions %%%%%%%%%
\def \name {Vorname1 Nachname1} %
\def \matrikel {Matrikelnummer1} %
\def \pname {Vorname2 Nachname2} %
\def \pmatrikel {Matrikelnummer2} %
\def \gruppe {Gruppenkuerzel} %
\def \uebung {1} %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT MODIFY THIS HEADER
\newcommand{\hwsol}{
\vspace*{-2cm}
\noindent \matrikel \quad \name \hfill Gruppe:\gruppe \\
\noindent \pmatrikel \quad \pname \\
\begin{center}{\Large \bf L\"osung f\"ur \"Ubung \# \uebung}\end{center}
}
\begin{document}
%Import header
\hwsol
\section*{Aufgabe 1}
\begin{enumerate}[(a)]
\item Beispielantwort
\item Hier k\"onnte deine Antwort auf diese Teilaufgabe stehen.
\item F<>r das Beispiel gilt $b_1=2^4+1=17=(10001)_2$ und $b_2=2^4-1=15=(1111)_2$.
\end{enumerate}
\section*{Aufgabe 2}
Notation von mathematischen L\"osungen:
\begin{eqnarray*}
r_{0} &=& \beta^{K_{X}} \bmod n\\
r_{1} &=& \alpha^{K_{X}+1} = \alpha \cdot \alpha^{K_{n}} = \alpha \cdot r_{1} \bmod p\\
r_{2} &=& (a_{1}-d \cdot q_{1}) \cdot z_{E}^{-1} \bmod p-1 \Leftrightarrow d = (x_{1}-s_{1} \cdot o_{E}) \cdot r_{1}^{-1} \bmod p-1\\
\end{eqnarray*}
\section*{Aufgabe 3}
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Tabellenzeile & Tabellenzeile & Tabellenzeile & Tabellenzeile \\
\hline
e & f & g & h \\
\hline
i & j & k & l \\
\hline
m & n & o & p \\
\hline
\end{tabular}
\end{center}
\end{document}