Skip to content
Snippets Groups Projects
Commit ddaa6ef5 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Vorbereitung Wintersemester 2020/21 - 5.11.2020

parent 79beb5f2
Branches
No related tags found
No related merge requests found
Showing with 0 additions and 392 deletions
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
#include <stdio.h>
int main (void)
{
"Hello, world!\n";
return 0;
}
#include <stdio.h>
int main (void)
{
Hello, world!\n;
return 0;
}
program Hello;
begin
WriteLn ('Hello, world!')
end.
File deleted
% hp-2019ws-p1.pdf - Labor Notes on Low-Level Programming
% Copyright (C) 2014, 2015, 2016, 2017, 2018, 2019 Peter Gerwinski
%
% This document is free software: you can redistribute it and/or
% modify it either under the terms of the Creative Commons
% Attribution-ShareAlike 3.0 License, or under the terms of the
% GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% This document is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this document. If not, see <http://www.gnu.org/licenses/>.
%
% You should have received a copy of the Creative Commons
% Attribution-ShareAlike 3.0 Unported License along with this
% document. If not, see <http://creativecommons.org/licenses/>.
% README: Versuch 1, 17. und 31.10.2019: RSA-Verschlüsselung
\documentclass[a4paper]{article}
\usepackage{pgscript}
\usepackage{multicol}
\usepackage{sfmath}
\sloppy
\pagestyle{empty}
\addtolength{\textheight}{1cm}
\newcommand{\sep}{~$\cdot$~}
\newcommand{\mylicense}{CC-by-sa (Version 3.0) oder GNU GPL (Version 3 oder höher)}
\begin{document}
\makebox(0,0.005)[tl]{\includegraphics[scale=0.72]{logo-hochschule-bochum-cvh-text-v2.pdf}}\hfill
\makebox(0,0)[tr]{\includegraphics[scale=0.5]{logo-hochschule-bochum.pdf}}
\par\bigskip\bigskip
\begin{center}
\Large\textbf{Praktikumsversuch 1: RSA-Verschlüsselung}
\par\medskip
\normalsize Hardwarenahe Programmierung\sep
Wintersemester 2019/20\sep
Prof.~Dr.~Peter Gerwinski
\end{center}
Aufgabe: Schreiben Sie ein Programm, das
die Verschlüsselung nach Rivest, Shamir und Adleman (RSA)
sowie die Schwierigkeiten beim Brechen ("`Knacken"') der
Verschlüsselung demonstriert.
\begin{multicols}{2}
Schreiben Sie ein C-Programm (oder mehrere),
das folgendes durchführt:
\begin{itemize}
\item
\textbf{Schlüsselerzeugung}
Bestimmen Sie drei verschiedene Primzahlen $p$, $q$ und $e$, wobei $e$
kleiner als $(p-1)\cdot(q-1)$ und teilerfremd zu $(p-1)\cdot(q-1)$ sei.
(Dies ist z.\,B.\ der Fall, wenn $e$ größer als $p$ und $q$ ist.)
Berechnen Sie $N = p \cdot q$
sowie eine natürliche Zahl $d$ mit der Eigenschaft:
\begin{displaymath}
(e \cdot d) \,\%\, \bigl((p-1)\cdot(q-1)\bigr) = 1
\end{displaymath}
("`$x \,\%\, y\/$"' wird "`x modulo y"' gesprochen und steht
für den Rest, der bei Division von $x$ durch $y$ verbleibt.)
$N$ und $e$ sind der \newterm{öffentliche Schlüssel}. \\
$p$, $q$ und $d$ sind der \newterm{geheime Schlüssel}.
\item
\textbf{Verschlüsselung}
Wählen Sie eine geheime Botschaft $m$ eine Zahl kleiner als $N$,
die Sie verschlüsseln wollen.
$m$ muß teilerfremd zu $N$ sein.
(Dies ist der Fall, wenn $m$ weder durch $p$ noch durch $q$ teilbar ist.)
Schreiben Sie ein Programm, das aus $m$ die verschlüsselte
Nachricht $c$ berechnet:
\begin{displaymath}
c = m^e ~\%\, N
\end{displaymath}
\strut\vfill\goodbreak
Hinweis:
\begin{displaymath}
m^e ~\%\, N
= \underbrace{(m \cdot m \cdot \dots \cdot m)}_{\mbox{$e$ Faktoren}} \,\%\, N
\hspace*{2cm}
\end{displaymath}
\vspace*{-\medskipamount}
\begin{displaymath}
= \underbrace{\Bigl(\dots\bigl((m \cdot m) \,\%\, N \cdot m\bigr) \,\%\, N \cdot \dots \cdot m\Bigr) \,\%\, N}_{\mbox{$e$ Faktoren}}
\end{displaymath}
Dies bedeutet: Multiplizieren Sie die Zahl $m$ $e$-mal mit sich selbst,
wobei Sie \emph{nach jeder Multiplikation\/} modulo $N$ rechnen.
% \vfill\goodbreak
\item
\textbf{Entschlüsselung}
Rekonstruieren Sie aus der verschlüsselten Botschaft $c$
wieder die geheime Botschaft $m$:
\begin{displaymath}
m = c^d ~\%\, N
\end{displaymath}
\item
\textbf{Verschlüsselung brechen}
Rekonstruieren Sie aus der verschlüsselten Botschaft $c$
wieder die geheime Botschaft $m$,
\emph{ohne\/} den geheimen Schlüssel zu kennen,
d.\,h.\ Sie kennen nur $N$ und $e$, nicht jedoch $p$, $q$ und $d$.
Hinweis:\\
Sie können z.\,B.\ versuchen, $N$ in seine Primfaktoren zu zerlegen.
Auf diese Weise können Sie zunächst $p$ und $q$ berechnen und danach $d$.
Vergleichen Sie dann
die für das Brechen der Verschlüsselung benötigte Rechenzeit
mit der Zeit, die das reguläre Ver- und Entschlüsseln dauert.
(Auf diesem Schwierigkeitsunterschied
beruht die Sicherheit der RSA-Verschlüsselung.)
% \vfill
\end{itemize}
\bigskip
\strut\hfill\emph{Viel Erfolg!}
% \vspace*{4cm}
\end{multicols}
\vfill
\begingroup
\small
\setlength{\leftskip}{3cm}
Stand: 9.\ Oktober 2019
% Soweit nicht anders angegeben:\\
Copyright \copyright\ 2014, 2015, 2016, 2017, 2018, 2019\quad Peter Gerwinski\\
Lizenz: \mylicense
Sie können diese Praktikumsunterlagen einschließlich \LaTeX-Quelltext
%% und Beispielprogramme\\
herunterladen unter:\\
\url{https://gitlab.cvh-server.de/pgerwinski/hp}
\endgroup
\end{document}
#include <stdio.h>
int main (void)
{
double a;
printf ("Bitte eine Zahl eingeben: ");
scanf ("%lf", &a);
printf ("Ihre Antwort war: %lf\n", a);
return 0;
}
#include <stdio.h>
int main (void)
{
double a;
printf ("Bitte eine Zahl eingeben: ");
scanf ("%lf", a);
printf ("Ihre Antwort war: %lf\n", a);
return 0;
}
#include <stdio.h>
int main (void)
{
int a;
printf ("Bitte eine Zahl eingeben: ");
scanf ("%d", &a);
a = 2 * a;
printf ("Das Doppelte ist: %d\n", a);
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Die Antwort lautet: ");
printf (42);
printf ("\n");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Die Antwort lautet: %d\n", 42);
return 0;
}
#include <stdio.h>
int main (void)
{
int a = 42;
int b;
printf ("a = %d\n", a);
printf ("b = %d\n", b);
return 0;
}
#include <stdio.h>
int main (void)
{
for (int i = 10; i = 0; i - 1)
printf ("%d\n", i);
return 0;
}
#include <stdio.h>
int main (void)
{
double pi;
pi = 3,1415;
printf ("pi = %lf\n", pi);
return 0;
}
#include <stdio.h>
int main (void)
{
double pi;
pi = (3,1415);
printf ("pi = %lf\n", pi);
return 0;
}
#include <stdio.h>
int main (void)
{
for (int i = 1; i < 10; printf ("%d\n", i), i++);
return 0;
}
#include <stdio.h>
int a, b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
/*
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
*/
return 0;
}
#include <stdio.h>
int a = 0, b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
/*
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
*/
return 0;
}
#include <stdio.h>
int a = 0, b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
/*
printf ("main(): a = %d, b = %d\n", a, b);
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
*/
return 0;
}
#include <stdio.h>
int a = 0, b = 3;
void foo (void)
{
b++;
static int a = 5;
int b = 7;
printf ("foo(): a = %d, b = %d\n", a, b);
a++;
}
int main (void)
{
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
/*
a = b = 12;
printf ("main(): a = %d, b = %d\n", a, b);
foo ();
printf ("main(): a = %d, b = %d\n", a, b);
*/
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment