Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve...

29
Kryptographie mit elliptischen Kurven Markus Hermann, Dejan Lazich Micronas GmbH Freiburg, 2006

Transcript of Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve...

Page 1: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Kryptographie mit elliptischen Kurven

Markus Hermann, Dejan Lazich

Micronas GmbH

Freiburg, 2006

Page 2: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

y

EK sind Teilmengen der Ebene x , definiert durch a und b in

Gleichungen der Form y2 = x3 + ax + b

Es gibt zwei Formen: „Küste mit Insel“ und „Kleiderbügel“

Beispiele:

Elliptische Kurven (EK) über

-2 2 4x

-4

-2

2

4

y

-2 2 4

-4

-2

2

4

y2 = x3 – 7x + 5 y2 = x3 – 5x + 4.7

Page 3: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Beispiel zur Punktaddition P Q=S

2

4

y

Q

P

Zwei Kurvenpunkte P, Q können „addiert“ werden:

Ziehe Verbindungsgerade zwischen P und Q

S

−2 2 4

−4

−2

2

x

QErmittle Schnittpunkt der Verbindungsgerade mit der EK

Spiegle diesen Schnittpunkt an der x-Achse

-S

Page 4: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Beispiel zur Punktverdopplung P=S

2

4

y Sonderfall P + Q mit P = Q („Verdopplung“):

Zeichne Tangente der EK im Punkt P

Ermittle Schnittpunkt der

-SPP

−2 2 4

−4

−2

x

Ermittle Schnittpunkt der Tangente mit der EK

Spiegle diesen Schnittpunkt an der x-Achse

S

Page 5: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Der abstrakte Punkt

Sonderfall P + Q mit Q = -P:

Ziehe Verbindungsgerade zwischen P und –P

Sie ist senkrecht zur x-Achse, hat keinen dritten Schnittpunkt mit der EK

−2 2 4

−2

2

4

x

y

P

EK

Definiere: Die Verbindungsgerade schneidet die EK „im Unendlichen“, im abstrakten Punkt

−4-P

P+(-P)=

Page 6: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Man kann die Punkte einer EK:

Addieren: P Q

Subtrahieren: P Q

Verdoppeln: P

Gruppenstruktur

Hier kann Punktaddition und -Verdopplung beliebig kombiniert werden (Additionsketten, Double-and-Add, usw.)

Verdoppeln: P

Und: P P = P

P P = P

P P P = P

=> Mit ganzen Zahlen multiplizieren: P

Das bedeutet: Wir können die Punkte einer EK „ganz normal“

zueinander addieren, subtrahieren und mit n multiplizieren.

3

5

4

Page 7: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Punktaddition:

Formeln für die Punktarithmetik

PSPS

QPS

SSQQPP

yxxsy

xxsx

yxSQPyxQyxP

−−=

−−=

==⇒==

)(

),( ),( ),,(2

)tan(α=−−

=PQ

PQ

xx

yys

Analytische Geometrie wird in rein algebraische Formeln überführt!

2

4y

a

Punktverdopplung:

PSPS yxxsy −−= )( − PQ xx

PSPS

PS

SSPP

yxxy

xx

yxSPyxP

−−=−=

==⇒=

)(

2

),( ),(2

σσ

P

P

y

ax

2

3 3 +=σ

−2 2 4

−4

−2 x

a

Page 8: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Anschaulich sind das keine Kurven

mehr, sondern Punktmengen. Bsp.:Java-Applet

Formeln können jedoch trotzdem

Elliptische Kurven über endlichen Körpern ( p, 2n)

(im Fall 2n mit kleinen Anpassungen)

verwendet werden!

Formeln werden dann im jeweiligen

Grundkörper berechnet =>

Punktarithmetik wird auf Arithmetik

in endlichen Körpern zurückgeführt.

Page 9: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Anwendung in der Kryptographie

Als Grundlage für Public-Key-Kryptographie benötigt man sog.

Einwegfunktionen:

Berechnung des Funktionswertes einfach („leichte Funktionen“)

Berechnung des ursprünglichen Arguments aus dem Funktionswert

„unmöglich“ („schwere Funktionen“)

Zwei Einwegfunktionen für Public-Key-Verfahren:

(1) Multiplikation v. Primzahlen -> Primfaktorzerlegung (RSA)

x • y = ? -> ? • ? = z

(2) Diskrete Exponentation -> diskreter Logarithmus (DH, EG, DSA)

xe = ? mod p -> x? = z mod p

(?e = z mod p)

Page 10: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Diskrete Logarithmen

Das diskrete Logarithmus Problem (DLP):

Gegeben: Zahlen x und y mit y = xΩx Ω ∫ Ω x = xk mod p.

Frage: Wie oft wurde x modulo p mit sich selbst multipliziert, um y zu

erhalten?

k-mal

Gesucht: k

Das DLP auf elliptischen Kurven (ECDLP):

Gegeben: EK-Punkte P und Q mit Q = P P ∫ P = P auf der EK.

Frage: Wie oft wurde der Punkt P zu sich selbst addiert, um den Punkt Q zu

erhalten?

Gesucht: k

k-mal

Page 11: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Diffie-Hellman in Gruppen

Alice Bob

Generator g, Primzahl p

ga mod p

gb mod p

Schlüsselaustausch

Alice Bob

X=(gb)a =gab mod p X=(ga)b =gab mod p

g mod p

Kennt g, p, ga, gb aber nicht X!

: a : b

Page 12: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Diffie-Hellman auf elliptischen KurvenPunkt P, EK

P

P

Alice Bob

Schlüsselaustausch

P

X = ( P)

= P

X = ( P)

= PKennt P, EK,

P, P

aber nicht X!

: u : v

Alice Bob

Page 13: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

ElGamal-Algorithmus in Gruppen

Bob würfelt Zufallszahl a (geheimer Schlüssel) und veröffentlicht

ga (öffentlicher Schlüssel)

Alice wählt Zufallszahl k und chiffriert die Nachricht m zu

(gk, mgak)

Verschlüsselung

(gk, mgak)

Bob kennt a und kann durch den „Tipp“ gk das Rauschen gak

entfernen, um die Nachricht m zu erhalten.

Zahlreiche Varianten standardisiert

Multiplikativ verrauschte Nachricht (Chiffrat)

„Tipp“ für Bob, damit er das Rauschen entfernen kann

Page 14: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Punkt P, EK, ENC, DEC, MAC, KDF

: u

Alice Bob

Öff. Schlüssel Q, Kofaktor h

Q

d

Elliptic Curve Integrated Encryption Scheme (ECIES)

Verschlüsselung

(k1, k2) = KDF(x, R)

C, t, R

: u

R= PZ= Q = (x, y)

C = ENCk1(m)

t = MACk2(C)

Page 15: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

ECIES (2)Punkt P, EK, ENC, DEC, MAC, KDF

C, t, R

Alice Bob

Geh. Schlüssel d, Kofaktor h

Z= R = (x, y)

d

Q

Verschlüsselung

m = DECk1(C)

t‘ = MACk2(C)

t == t‘ ?

(k1, k2) = KDF(x, R)

ENC, DEC: Symmetrische Chiffre, bspw. 3DES, AES, ...

MAC: Message Authentication Code, bspw. HMAC (im Prinzip Hashfkt., bspw. SHA-1)

KDF: Key Derivation Function (im Prinzip Hashfkt., bspw. SHA-1)

Page 16: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Digital Signature Algorithm (DSA) mit elliptischen Kurven (EC-DSA) (1)

Signieren einer Nachricht m

Bekannt ist ein Punkt P auf der EK, seine Ordnung n (n prim, n>2191)

sowie der geheime Schlüssel d (eine Zahl).

Wähle Zufallszahl k œ [0,n-1]

Signatur

Wähle Zufallszahl k œ [0,n-1]

Berechne (x,y):= P (k-fache Addition eines Kurvenpunktes)

Berechne r:=x mod n

Berechne e:=SHA-1(m)

Berechne s:=k-1(e+dr) mod n

Signatur ist das Tupel (r, s)

Nur x-Koordinate wird weiterverwendet

m, (r, s)

Page 17: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

DSA mit elliptischen Kurven (EC-DSA) (2)

Verifizieren einer Signatur (r, s)

Bekannt ist ein Punkt P auf der EK, seine Ordnung n (n prim, n>2191)

sowie der öffentliche Schlüssel Q (ein Punkt auf der EK).

Berechne e:=SHA-1(m)

m, (r, s) Signatur

Berechne e:=SHA-1(m)

Berechne w:=s-1 mod n

Berechne u:=ew mod n

Berechne v:=rw mod n

Berechne (x,y):= P Q (u- bzw. v-fache Addition von P bzw. Q)

Berechne t:=x mod n

Wenn t==r, dann Signatur gültigNur x-Koordinate wird weiterverwendet

Page 18: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

DSA mit elliptischen Kurven (EC-DSA) (3)

Welchen Aufwand hat eine der anfallenden mehrfachen Additionen

(Multiplikation)? Implementierung mit Double-and-Add:P

Punktverdopplung P Punktaddition P P

Länge von k in Bit = L(k) mal Hamminggewicht von k = wH(k) mal

Punktverdopplung P Punktaddition P P

q Mult. q Add.q Inv.

71 63 4

1

q-2 q>>190!!!

Page 19: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Wie erhält man schnelle Punktarithmetik?

Zwei Ansätze:

(1) Verändere die Darstellung der Punkte, so dass nur

wenige Körperoperationen, nach Möglichkeit keine

Invertierungen nötig sind!

(2) Implementiere möglichst schnelle Körperoperationen!

Punktarithmetik

Körperarithmetik

(1) (2)

Page 20: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Projektive Standarddarstellung Jeder Kurvenpunkt wird eindeutig

durch eine Ursprungsgerade (einen Strahl) dargestellt

Zur Addition von zwei Kurven-punkten können beliebige Punkte auf deren Ursprungsgeraden auf deren Ursprungsgeraden verwendet werden

Dadurch können Invertierungen gegen andere Operationen ein-getauscht werden.

Aber: Transformation in die projektive Darstellung und zurück erforderlich!

Page 21: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Projektive Jacobi-Darstellung Alternative zur projektiven

Standarddarstellung

Jeder Kurvenpunkt wird durch eine kubische Funktion (einen gekrümmten Strahl) dargestellt

Page 22: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Transformationen der Darstellung

Affine Darstellung -> Proj. Standarddarstellung

(x, y) ->

Proj. Standarddarst. -> Affine Darstellung

(X, Y, Z) -> (X/Z, Y/Z) = (x, y)

|),,( Κ∈ZZZyZx

Affine Darstellung -> Proj. Jacobi-Darstellung

(x, y) ->

Proj. Jacobi-Darst. -> Affine Darstellung

(X, Y, Z) -> (X/Z2, Y/Z3) = (x, y)

|),,( 32 Κ∈ZZyZxZ

Invertierungen!

Page 23: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Projektiver Additionsalgorithmus

Page 24: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Benötigte Körperoperationen

Punktaddition

Darstellung Mult. Inv. Add./Sub.

Affine Darstellung 3 1 6

Proj. Standarddarstellung 15 0 6

Proj. Jacobi-Darstellung 18 0 7Zzgl. Transformation undRücktransformation!

Punktverdopplung

Darstellung Mult. Inv. Add./Sub.

Affine Darstellung 7 1 4

Proj. Standarddarstellung 18 0 4

Proj. Jacobi-Darstellung 16 0 4

Proj. Jacobi-Darst. (a ∫ –3) 14 0 5

Erinnerung: 1 Inv. kostet >> 191 Mult.!!!

Zzgl. Transformation undRücktransformation!

Page 25: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (1): Wann sind proj. Darst. sinnvoll?

Für eine einzelne Addition/Verdopplung sind die Transformationen

zu teuer, außerdem mehr Multiplikationen notwendig.

Fallen mehrere Operationen an (bspw. Multiplikation P), dann

gehe wie folgt vor:

Transformation in projektive Darstellung

(keine Invertierung)

Führe alle Rechnungen in projektiver Darstellung durch

(keine Invertierung)

Transformiere das Ergebnis zurück in affine Darstellung

(zwei Invertierungen)

Page 26: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Wie erhält man schnelle Punktarithmetik?

Zwei Ansätze:

(1) Verändere die Darstellung der Punkte, so dass nur

wenige Körperoperationen, nach Möglichkeit keine

Invertierungen nötig sind!

(2) Implementiere möglichst schnelle Körperoperationen!

Punktarithmetik

Körperarithmetik

(1) (2)

Page 27: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Ansatz (2): Schnelle Körperarithmetik

Ziele:

Skalierbarkeit (nicht an einen bestimmten Körper gebunden)

Einheitlichkeit (soll für p, als auch für 2n nutzbar sein)

Konform mit (möglichst allen) StandardsKonform mit (möglichst allen) Standards

Möglichkeiten:

Montgomery-Arithmetik (wortweise, eher für CPU geeignet)

Rückgekoppelte Schieberegister (bitweise, für Hardware-

Lösungen (ASIC) geeignet)

Page 28: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Standards|Standard |Jahr |Titel |

ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA)

ANSI X9.63 2001 Key agreement and key transport

FIPS 186-2 2000 Digital Signature Standard (DSS) (ECDSA, ECDH)

IEEE 1363-2000 2000 Standard specifications for public-key cryptography (ECDSA, Projektive Jacobi-Darstellung)

IEEE 1363a (draft) Amendment 1: Additional techniques

ISO/IEC 15946-1 2002 Techniques based on elliptic curves-Part 1: General

ISO/IEC 15946-2 2002 Part 2: Digital Signatures (ECDSA)

ISO/IEC 15946-3 2002 Part 3: Key establishment

ISO/IEC 15946-4 (draft) Part 4: Digital signatures giving message recovery

SEC 1 2000 Elliptic curve cryptography (ECDSA, ECDH)

SEC 2 2000 Recommended elliptic curve domain parameters

PKCS13 1998 RSA Laboratories

Page 29: Kryptographie mit elliptischen Kurven - crypto.iti.kit.edu · ANSI X9.62 1999 The elliptic curve digital signature algorithm (ECDSA) ANSI X9.63 2001 Key agreement and key transport

Zusammenfassung

Auf elliptischen Kurven kann man „normal“ addieren und mit ganzen Zahlen multiplizieren (Gruppenstruktur).

Es existieren Protokolle für Schlüsselaustausch, Verschlüsselung und Signatur mit elliptischen Kurven, sie wurden von verschiedenen Gremien standardisiert.standardisiert.

Die Invertierung im Grundkörper ist die bezüglich der Laufzeit teuerste Operation, die zur Punktarithmetik notwendig ist.

Man kann durch projektive Darstellungen Invertierungen einsparen.

Offene Frage: Wie kann ein universelles Kryptomodul implementiert werden (für RSA, elliptische Kurven, Primkörper, erw. Körper, ...)?