Algoritmi e Architetture per Sistemi...

74
Algoritmi e Architetture per Sistemi Crittografici Gerardo Pelosi Dipartimento di Elettronica e Informazione - DEI Politecnico di Milano Politecnico di Milano insegnamento erogato con il contributo dell'azienda Microelectronics

Transcript of Algoritmi e Architetture per Sistemi...

Page 1: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Algoritmi e Architetture per Sistemi Crittografici

Gerardo Pelosi

Dipartimento di Elettronica e Informazione - DEIPolitecnico di MilanoPolitecnico di Milano

insegnamento erogato con il contributo dell'azienda

Microelectronics

Page 2: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Informazioni GeneraliInformazioni GeneraliOrario (Dal 02 Mag al 17 Giu, 2.5 CFU--16+8 di lez/ese)

Lunedì (LEZ-ESE): 16.15 - 18.15 aula D.1.1 Venerdì (LEZ-ESE): 8.15 - 10.15 aula D.1.1

Modalita' d'esameLa valutazione avviene attraverso un progetto e/o elaborato da svolgersi al più in coppia concordato con il docente che da svolgersi al più in coppia concordato con il docente, che puo' essere sostituito da una prova scritta e un colloquio orale.

Appelli per Registrazione esame01 luglio 2011 ore 12.1526 l li 2011 12 1526 luglio 2011 ore 12.15(Le date di Settembre verranno confermate appena possibile)

Page 3: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Informazioni GeneraliInformazioni GeneraliElenco progetti disponibili (in fase di aggiornamento) su

http://home.dei.polimi.it/pelosi/doku.php?id=teaching:aasc

Per l’assegnamento e il coordinamento dei progetti/materiale è necessario fissare un appuntamento con il docente ([email protected])o con l' Ing Barenghi (barenghi@elet polimi it) Ufficio 127 Tel 3476o con l Ing. Barenghi ([email protected]). Ufficio 127, Tel. 3476L'assegnamento dei progetti è “on an FCFS-basis”

i l did iMateriale didatticoDispense e slides sul sito del corso Bibliografia consigliata nel programma g g p g

Page 4: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Riassunto del ProgrammaRiassunto del Programma Introduzione ai fondamenti matematici della crittografia (gruppi, campi)

Critto-sistemi a chiavi privata e a chiave pubblica p p(struttura e implementazioni)

Funzioni di hash crittografia su Curve ellittiche e Funzioni di hash, crittografia su Curve ellittiche e paradigmi Identity-based

Cenni di c itto analisi e metodi di attacco alle Cenni di critto-analisi e metodi di attacco alle implementazioni dei critto-sistemi.

Crittoanalisi: analisi lineare, analisi di potenza, contromisure, metodi d’attacco basati sull’induzione di guasti.d attacco basati sull induzione di guasti.

Page 5: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Introduction toIntroduction toCryptography and Security

Page 6: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Outline

The general goals of cryptographic systemsg g yp g p y

History of Cryptography and systematization of cipher design principlessystematization of cipher design principles

Categories of cryptographic algorithmsSymmetric Symmetric Asymmetric

public key: example of RSA; digital signature, tifi t d PKI certificates and PKI

identity based cryptographyHashing functionsHashing functionsImplementation of cryptographic algorithms

Categories of attacksCategories of attacks

Page 7: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

The General Goals of Cryptographyy g y

Cryptography is a set of methodologiesCryptography is a set of methodologiesand techniques for protecting information.It gives to a communication channel thegfollowing features:

o Confidentiality (or Secrecy)

o Data Integrity

A th ti ti ( U V ifi ti )o Authentication (or User Verification)

o Non Repudiationo Non-Repudiation

Page 8: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Security Services

Confidentiality:

Security Services

yassuring that only authorized parties areable to understand the data.

I te itIntegrity:ensuring that when a message is sent overa network, the message that arrives is the, gsame as the message that was originallysent.

A th ti tiAuthentication:ensuring that whoever supplies or accessessensitive data is an authorized party.p y

Non repudiation:ensuring that the intended recipient

t ll i d th & iactually received the message & ensuringthat the sender actually sent the message.

Page 9: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

More on ConfidentialityMore on Confidentiality

Confidentiality means that only authorizedConfidentiality means that only authorizedparties are able to understand the data(authorized from the perspective of the( p pparty that encrypted the data).It is okay if unauthorized parties know thatthere is data. It is even okay if they copythe data, as long as they cannotnde stand itunderstand it.

Page 10: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

More on AuthenticationMore on Authentication

How can we know that a party that provides us with sensitive data is an authenticated party?How can we know that the party that is accessing sensitive data is an accessing sensitive data is an authorized party?Possible solutions are:Possible solutions are:

Digital signaturesPasswords Symmetric encryption + hashing

Page 11: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

More on Integrityg y

o data integrity is a service that addresses the o data integrity is a service that addresses the unauthorized alteration of data

o to ensure data integrity one should be ableo to ensure data integrity, one should be ableto detect data manipulation by unauthorized parties

o data manipulation includes such things aso data manipulation includes such things as

insertiondeletionand substitution

o Cryptographic solutions include: Encryption and/or Hashing algorithms

Page 12: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

More on Non Repudiationp

Ensuring that the intended recipient actually g p ygot the message.Ensuring that the alleged sender actually

t th sent the message.How do we prove that a user's cryptographic credentials have not been cryptographic credentials have not been compromised?Disputes arise when an alleged sender denies that certain actions were taken. For example, one entity may authorize the purchase of property by another entity and purchase of property by another entity and later deny such authorization was granted. A procedure involving a Trusted Third Party is needed to resolve the dispute.

Page 13: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Basic TermsBasic Terms

Encryption: scrambling a message or data Encryption: scrambling a message or data using a specialized cryptographic algorithm.Plaintext: the message or data before it Plaintext: the message or data before it gets encrypted.Ciphertext: the encrypted (scrambled) p yp ( )version of the message.Cipher: the algorithm that does the encryption.Decryption: the process of converting ciphertext back to the original plaintext.Cryptanalysis: the science of breaking

t hi l ithcryptographic algorithms.

Page 14: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

History of Cryptographyy yp g p yRather non-systematic approach during Ancient Times and Middle AgesTimes and Middle Ages:

Cesar cipher (it is a substitution cipher):Shift letters of the plaintext message 3 alphabetic

i i positions on. A systematic approach to cryptography begins during the Renaissance:

Discovery of frequency analysis.Disadvantage of Cesar cipher: it does not smooth out frequencies in the ciphertext. q pIntroduction of polyalphabetic ciphers: use multiple cipher alphabets.

First non-trivial permutation algorithms.First non trivial permutation algorithms.the positions of the letters of the plaintext are scrambled in such a way to alter the ordering and neighbourhood characteristics of the original letters. g gThe shape of the frequency spectrumof the original plaintext is not altered.

Page 15: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Example of Substitution SchemeExample of Substitution Scheme

Let us try to abstract from unnecessay Let us try to abstract from unnecessay details, and to understand the underlying mechanisms:ec a s s

Use only two symbols: 0 and 1 (bits)Use only two substitution schemes:

0 → 0 and 1 → 1 (scheme a) - IDENTITY0 → 1 and 1 → 0 (scheme b) - NEGATION

(th l ibiliti ith bit!)(the only possibilities with one bit!)

Decide that the application order is: abbabaaaab (just an example)abbabaaaab (just an example).

Page 16: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Example (cont )Example (cont.)

Encryption example:Encryption example:0001000100 (plaintext: 0: 80%, 1: 20%)abbabaaaab (application order)abbabaaaab (application order)0111100101 (ciphertext: 0: 40%, 1: 60%)

The frequency spectrum of the ciphertext has been smoothed, with respect to that of the original plaintext.In principle the ciphertext has been made In principle, the ciphertext has been made relatively difficult to relate to the originalplaintext.But it is necessary to remember the application order abbabaaaab … an example of what is meant with a “key”what is meant with a key .

Page 17: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Example (cont )Example (cont.)Is is however easy to decrypt, if the application order is y yp , ppknown:

0111100101 (ciphertext)abbabaaaab (application order)abbabaaaab (application order)0001000100 (plaintext)

Note that, posing a = 0, b = 1, encryption and decryption consist of XORing bitwise the bit sequences:

Decryption Encryption0111100101 (cipher) 0001000100 (plain)0111100101 (cipher) 0001000100 (plain)0110100001 (applic.) 0110100001 (applic.)0001000100 (plain) 0111100101 (cipher)

Page 18: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

KeysKeys

A “key” is a parameter of the A key is a parameter of the cryptographic algorithm, that is necessary to know for reconstructing th i i l l i t tthe original plaintext.The key avoids the necessity of many different cryptographic algorithms limiting to different cryptographic algorithms, limiting to just one.The key gives a substantial contribution to make cryptanalysis difficult.However, the key must be kept secret to everybody but to the authorized userseverybody but to the authorized users.

Page 19: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Example (cont )Example (cont.)

Encryption example:Encryption example:0001000100 (plain text)0101111011 (key – parameter of the algorithm)0101111011 (key parameter of the algorithm)0100111111 (cipher text)

The key parametrizes the algorithm.y p gNote how the encryption and decryption algorithms are identical, and share the same key (example of a “symmetric” system).This is not a necessity, in general, though many cryptographic algorithms are constructed precisely in this way.

Page 20: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

History of Cryptography: Kerckhoffs’ P i i lPrinciple

A cryptosystem should be secure even if everything b t th t t th k i bli l about the system, except the key, is publicly

known.

Kerckhoffs’ desiderata (1883)Kerckhoffs desiderata (1883)1. The system must be practically, if not mathematically,

indecipherable;It t t b i d t b t d it t b bl 2. It must not be required to be secret, and it must be able to fall into the hands of the enemy without inconvenience;I k b i bl d i bl i h h h l 3. Its key must be communicable and retainable without the help of written notes, and changeable or modifiable at the will of the correspondents;

4. It must be applicable to telegraphic correspondence;5. It must be portable, and its usage and function must not

require the concourse of several people;6. The system must be easy to use, requiring neither mental

strain nor the knowledge of a long series of rules to observe.

Page 21: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Design Principles of Cryptographic AlgorithmsAlgorithms

o The security of every cryptographic system must not rely upon to the secrecy of the methodology (i.e., of the cryptographic algo ithm) b t onl in the sec ec of the algorithm) but only in the secrecy of the chosen key.

It can be theoretically studied and tested, lowering the risk It can be theoretically studied and tested, lowering the risk of containing hidden weaknesses and pitfalls.The encryption/decryption device can be efficiently implemented and fabricated in large volumesimplemented and fabricated in large volumes.Secrecy is limited only to the small amount of information represented by the key.

o Viability of an encryption scheme:o Viability of an encryption scheme:The cost of breaking exceeds the value of the encrypted informationThe time required to break the cipher exceeds the useful lifetime of the information

Page 22: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Composition of AlgorithmsComposition of AlgorithmsIn principle, one may combine several p p , ydifferent cryptosystems, in order to obtain a more resistant cryptosystem.yp y

However, there are practical limitations of time space and complexitytime, space and complexity.

And it may happen that the composite system is not really more robust (against system is not really more robust (against cryptanalysis) than its components, taken i di id llindividually.

Page 23: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Levels of SecurityLevels of Security

Three categories of security are distinguished:g y gUnconditional security:

o When a cryptosystem cannot be broken (inverted) even when infinite computational resources are even when infinite computational resources are available [highly theoretic claim].E.g.: One-Time-Pad (OTP), see next…

Computational security:o When for a given cryptosystem the most efficient

algorithm for breaking (inverting) it requires N algorithm for breaking (inverting) it requires N operations (with N large and known in advance). Concepts and tools of the theory of computational complexity classify the systems as Ω(N) (N is a complexity classify the systems as Ω(N) (N is a ”lower bound”)

Relative (or practical) security: to see next…

Page 24: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Relative (practical) SecurityRelative (practical) SecurityA cryptosystem is “relatively secure”(or secure from a practical point of view) if the computational cost of its breaking (in e sion) is bo nd to that of a ell(inversion) is bound to that of a well-studied, very hard to solve problem.This classification criterion is not ultimate This classification criterion is not ultimate, in general. A cryptosystem might turn from secure to A cryptosystem might turn from secure to insecure:

Because of new methods to approach the “hard” problems.Because of new ways to bound the same cryptosystem to another problem which results to cryptosystem to another problem which results to be computationally simpler.

Page 25: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

The Best Cryptosystem:One Time PadOne-Time-Pad

The most resistant (symmetric) ( y )cryptosystem (against frequency analysis) consists of:

Mapping the plaintext onto a string of m ≥ 1 Mapping the plaintext onto a string of m ≥ 1 bits (using some conversion technique -- which is not relevant by itself).

h h k fXORing the string with a key of m ≥ 1randomly chosen bits.

Property of the Key:Property of the Key:its length must be equal to the length of the plaintextit t b dit must be randomit must be used only once

Page 26: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

One Time PadOne Time Pad o OTP is unconditionally secure (Shannon 1948).

Informally, if a cryptanalyst has a ciphertext string (C1 C2…Ct ) encrypted using a random key string which has been used only once the cryptanalyst which has been used only once, the cryptanalyst can do no better than guess at the plaintext being any binary string of length t.(i bi i ll lik l l i )(i.e., t-bit strings are equally likely as plaintext.)

o The severe condition on the property of the keys d th ti lit f th t i ll b t reduces the practicality of the system in all but a

few specialized situations.

• Reportedly about 30 years ago communication line • Reportedly, about 30 years ago communication line between Moscow and Washington was secured by a one-time pad. Transport of the key-pad was done by

d itrusted courier.

Page 27: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Attempts to improve OTP p p

To reduce the inefficiency of the One-Time-Pad To reduce the inefficiency of the One Time Pad cryptosystem, while preserving its robustness, onemight for instance:

d f k i di ll ith ffi i tl use a pad of keys periodically, with a sufficiently long period.use some kind of key generator, working in a y g , gmore or less random way.combine the two above methods.and man othe s and many others ...

But in all cases, the robustness of the cryptosystem is affected, since the key is no longer truly random …, y g yHowever, the idea of “recycling” or “expanding” the key recurs in modern (symmetric) cryptosystems, though in a much more sophisticated way though in a much more sophisticated way …

Page 28: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Design Principles:Confusion & DiffusionConfusion & Diffusion

Confusion is the ability to alter (confuse) the letters of the original plaintext, decoupling

Diffusion is the ability to spread (diffuse) the letters of the original plaintext

the frequency spectra of the plain- and cipher- texts and making the relationship between h k d i h

over the whole ciphertext, so that any redundancy in the plaintext is spread out

th i h t tthe key and ciphertext as complex as possible.

over the ciphertext

o Let an arbitrary composition of a substitution (Confusion) and a permutation (Diffusion) be called a round. (the two operations are not always clearly separable)(the two operations are not always clearly separable)

o Modern symmetric cryptosystems apply a number of rounds in succession to encrypt plaintext.

Page 29: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

History of CryptographyHistory of Cryptography

During World War II mechanical devices calledDuring World War II mechanical devices called rotors were used to secure radio communications (polyalphabetic ciphers) (p y p p )The most famous encryption device was the Enigma Machine used by the German forces

substantially a keyboard linked to a scrambling device to permute the pressed keys followed by three rotors. The “cryptographic key” was the initial configuration ofThe cryptographic key was the initial configuration of rotors, plus the initial permutation.

A famous English cryptanalyst developed method g yp y pfor breaking the adversary algorithm

Alan Turing and the Turing Machine

Page 30: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

History of CryptographyHistory of CryptographyMost of the modern cryptosystems are based

b h b l b (ion number theory, abstract algebra (in particular, the algebra of finite fields) and computers.computers.Modern cryptography allow to address all the issue needed to implement security services ( h d d )(as authentication and non-repudiation) expecially for commercial applications. The use of cryptosystems is typically regulated The use of cryptosystems is typically regulated by protocols(i.e. sets of rules for ordered communications)( )Many modern cryptosystems appear as components of network protocols.

E.g.: IPSec, TLS/SSL, the OSI model, etc.

Page 31: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Cryptographic Paradigmsyp g p go Symmetric Cryptosystems

• Encryption and decryption algorithm use the same key• Encryption and decryption algorithm use the same key.• Generally are widely used to guarantee privacy, but they can also be used for authentication and data integrity.• E.g.: AES, 3DES2, TDEA, RC4, IdeaNext, BlowFish.

o Asymmetric (or Public-Key) Cryptosystems • Every user is in possession of a pair of (related) keys• Every user is in possession of a pair of (related) keys.• PUBLIC KEY: may be known to everybody;

used with the encryption algorithm.• PRIVATE KEY: known only to the recipient and rigorously PRIVATE KEY: known only to the recipient and rigorously

kept secret to everybody else;used with the decryption algorithm.

• E.g.: RSA, ECC, DH, XTR, DSA, ECDSA. g , , , , ,

o Identity Based Cryptosystems • A public-key system where the public key of each user is defined to be its Identity (i e a previously recognized and defined to be its Identity (i.e., a previously recognized and publicly known piece of information, which is not associated with the cryptosystem parameter generation)

Page 32: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Symmetric cryptosystemsSymmetric cryptosystems

BobAliceo Confidentiality of transactions

o Fast computation

BobAlice

o Fast computation

o “Non repudiation” not guaranteedg

o Key Management does not scale well:o ≈ n2 keys for n partieso ≈ n2 keys for n parties.

o Expensive Key Storage, Archiving and BackupArchiving and Backup

o Expensive Disaster Recovery

Page 33: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public-Key Cryptosystemsy yp y

o As a physical analogue, consider a metal box o As a physical analogue, consider a metal box with the lid secured by a combination lock.

o The combination of the lock (private key) is o The combination of the lock (private key) is known only to Bob. If the box (public key) is left open and made publicly available then anyone can place a message inside and lock the lid.

o Only Bob can retrieve the message. Even the entity which placed the message into the box is unable to retrieve it.

Page 34: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public-Key Cryptosystemsy yp y

A PK-encryption function must be a ‘ f i ’ i h ‘ d ’‘one-way function’ with a ‘trapdoor’.

A ‘one-way function’ is easy to perform but very difficult to reverse. A ‘trapdoor’ must be a secret parameter known only to the receiver which makes it easy to reverse the functionfunction

Examples of one-way functions:• multiplication of two large primes; the factorization

bl i t ti ll i f ibl f ffi i tl problem is computationally infeasible for sufficiently large numbers.

• m → me mod n; exponentiation modulo n ( n = pq )• x → ax in GF(2n) or GF(p); Discrete Log.• k → Ek(m) for fixed m where Ek is a symmetric

encryption scheme (...secure against known plaintextencryption scheme (...secure against known plaintextattacks).

Page 35: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public Key PrimitivesPublic Key PrimitivesPK Encryption procedure.yp pA sender A computes the ciphertext from a plaintextmessage m by computing a one-way function parametric in the public key of the recipient Bthe public key of the recipient B

c = EncKpub,B(m)o PK Decryption procedure.

To recover the received confidential message the recipient To recover the received confidential message the recipient B computes a one-way deciphering function (related to the encryption one) parametric in its private key

m = Dec (c)m = DecKpriv,B(c)Properties: DecKprivB(EncKpubB(m)) = m

EncKpubB(DecKprivB(m)) = mEncKpubB(DecKprivB(m)) mPublic key cryptographic paradigm enables also the possibilities to realize:

K A t i h lKey Agreement over an insecure channelDigital Signatures

Page 36: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Diffie Hellman Key ExchangeDiffie Hellman Key ExchangeIn 1976 Diffie and Hellman proposed a In 1976 Diffie and Hellman proposed a method for key exchange and basically introduced the concept of public key cryptographyThe method is based on exponentiation in fi it fi ld d th diffi lt f a finite field and on the difficulty of

computing the discrete logarithm in such a fielda field

Page 37: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Diffie Hellman Key ExchangeDiffie Hellman Key ExchangeBasic System parameters: a prime number: p, a

generator g of a multiplicative subgroup (with prime generator g of a multiplicative subgroup (with prime order: n) of the finite field (Zp ; + ; •)

random number 0<KsB<n-1random number 0<KsA<n-1

A B

KP bA

sB

KPubB = gKsB mod psA

KPubA = gKsA mod p

KP bB

KAB = KPubBKsA mod p KBA = KPubA

KsB mod p

KPubAKPubB

KAB = KPubBKsA mod p = (gKsA)KsB mod p =

= (gKsB)KsA mod p = = KPubA

KsB mod p = KBA

Page 38: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Security of the DH key exchangeSecu y o e ey e c a ge

A passive attacker who’s monitoring the i ti h l t b k th communication channel to break the

cryptosystem can use the knowledge of Zp finite field propertiesp p pgenerator: g public key: gKs

Alas the computation of a secret exponent Alas the computation of a secret exponent requires the application of a non-polynomial algorithm to solve the discrete logarithm

bl (DLP)problem (DLP)Besides, there is no method to solve the so-called DH-Problem, i.e. given g, ga, gb, find gab., g g, g , g , gGood security settings for current technology require n (the order of the group) be greater than 21024 (traditional cryptosystems) or greater than 21024 (traditional cryptosystems) or greater than 2160 (elliptic curve cryptosystems)

Page 39: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Man-in-the-middle attackMan in the middle attack

o The user A has to trust the public key of Bo The user A has to trust the public key of Bo If an active attacker C substitutes B’s public

key with his own public key, A is not capable to see the difference between two public keys.

o The effectiveness of the attack is due to the fact o The effectiveness of the attack is due to the fact that the public key is a generic element of a finite field which is not easily bounded to a specific user identityuser identity

o Certificates are tools for the official distribution o Certificates are tools for the official distribution of public keys, granting the correct and secure association of any user to her public key.

Page 40: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public Key InfrastructurePublic Key Infrastructure

h f f h hThe use of certificates within a PKI is the most used solution for avoiding the MITM attack.The public keys are kept stored in a key server The public keys are kept stored in a key server, and a certificate containing the user’s key is released to anybody who requests it.A “Certification Authority” (CA), itself a trusted organization, manages this service.N t k ibl di t i t th bli Network accessible directories store the public keys of the users who subscribe to the service.But how can certificates be trusted?But how can certificates be trusted?It is necessary to have digital signatures….

Page 41: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Digital Signatureg gAccording to ISO, the term Digital Signature ‘indicate a particular authentication technique used to establish the origin of a message in order to settle disputes of what message (if any) was sent’.disputes of what message (if any) was sent .

o A signature on a message is some data that• validates a message and verifies its origina da a ag a d o g• a receiver can keep as evidence• a third party can use to resolve disputes.

It should be

It has to be available to the sender and depends

• easy to compute

• easy to verify

the sender and depends on

• the message• difficult to forge• a secret parameter

Page 42: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Digital Signatureg g

o Use of a secret parameterHand-written signatures

I i i io Use of a secret parametero Message dependent

o Digital Signing procedure:

• Intrinsic to signer

• Same on all documents

• Physically attached to messageo g ta S g g p ocedu eA (the signer) creates a signature for a message m by:

• Compute s = SKsA(m) with a signature generation function

y y g

• Transmitt the pair <m, s>; s is called the signature for themessage m.

o Verification procedure.pTo verify that a signature s on a message m was created by A, an entity B (the verifier) performs the following steps:steps:

• Obtain the verification function VKPubA of A

• Compute u = VKPubA (m, s)Compute u VKPubA (m, s)

• Accept the signature as having been created by Aif u = true, and reject the signature if u = false.

Page 43: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Authentication of Public Keysy

o A Trusted Third Party a.k.a. the Certification Authority (CA) guarantees the authenticity of a user’s Authority (CA) guarantees the authenticity of a user s public key by signing a certificate, containing both the user’s identity and public key, making use of its secret key.y

o All users must have an authentic copy of the Certification Authority’s public key to verify the signatures of the certificatessignatures of the certificates.

Verifies Creates

CertificateC.A.Verifies

credentialsCertificate

ReceivesPresents Public Generates

Owner

(and checks)Certificate

Key and credentials

Key Set

Page 44: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public Key Infrastructure (PKI)Public Key Infrastructure (PKI)

The CAs can be organized in trees The CAs can be organized in trees, the root CA signs the certificates of other CAs, and so on up to the end userand so on up to the end user.Every user is equipped with a set of certificates of the root CAscertificates of the root CAs.Once a user receives a certificate, he checks if it is signed by a CA in his listt s s g ed by a C s st

if not, it starts to search the certificate of the CA and perform a hierarchical check of pthe CAs certificates

Page 45: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public Key Infrastructure (PKI)Public Key Infrastructure (PKI)Certificates have an expiration dateCertificates have an expiration dateBesides, the device where the private key is stored could be compromised (lost or p (broken).It is necessary to have procedures to revoke certificatesTwo standards:

Certificates Revocations List (CRL)Online Certificate Status Protocol (OCSP)

Page 46: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Public-Key Cryptosystems & PKIy yp y

o Users have a Public Key and a Private Keyo Users have a Public Key and a Private Key• Only need one key per party, total of n keys for n

parties

CA Signing Key

Certification AuthorityCertificate Server Store

Certificate

Look up

CA Public Key

Send P bli K

ReceiveLook up

Bob’s CertificateCheck revocation

Public KeyAuthenticate

Certificate

Store Bob’s

Alice retrieves Bob’s Private Key

Store Bob s Private Key

E t d iBob’s Public Key to send her

message m to Bob

Bob s Private KeyBob’s Public Key

Encrypted using Bob’s PK

Page 47: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Authenticated DH key exchange y g

The procedure for the agreement of aThe procedure for the agreement of acommon secret session key over aninsecure channel, where both parties haveto equally contribute to the computation ofthe secret, follows the following steps:

h f bli k tifi t• exchange of public-key certificates;• validation of the received certificates; • application of the DH Protocol where the • application of the DH Protocol where the

DH-Public Keys of each user are sent, over the channel, encrypted with the public key of the counter-party.

Page 48: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

The RSA CryptosystemThe RSA Cryptosystem

It is the most popular asymmetric (public key) cryptosystem.

It was invented by Rivest, Shamir and Adl i 1977 t MITAdleman in 1977 at MIT.

It was under patent until 2000It was under patent until 2000.

Presently widespread for instance in the Presently widespread, for instance in the well-known SSH protocol.

Page 49: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

The RSA Cryptosystem

Setup of the system. Each user must:

The RSA Cryptosystem

p y

o compute n p q and ( ) ( 1) ( 1)

o select at random two primes p and qo compute n = p q and ϕ (n) = (p − 1) (q − 1)

o select a random integer e such that:

F t’ th E lid’ l ith

0 < e < ϕ (n)g.c.d. (ϕ (n), e) = 1

Euler’s function

o use Fermat’s th. or Euclid’s algorithm to compute d (private key), such that:

o keep secret ks = (p, q, d, ϕ (n)) (the private key)

e d = 1 mod ϕ (n) (d is e−1 mod ϕ (n))

o keep secret ks (p, q, d, ϕ (n)) (the private key)o make public kp = (n, e) (the public key)

Page 50: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

The RSA CryptosystemThe RSA Cryptosystem

When Alice need to send a message x (clear t.) to Bob:

h b b’ bl k k ( )• she obtains Bob’s public key kp,B = (n, e)• she represents the message x as an integer in the

range [2 n 2] (conversion tech is irrelevant)range [2, n − 2] (conversion tech. is irrelevant)• she computes y = xe mod n and sends y to Bob

y is the encrypted message (ciphertext)y is the encrypted message (ciphertext)

To reobtain the clear text message x, Bob must:

• use his own secret key ks,B = (p, q, d, ϕ (n)) and compute yd mod n = x.

Page 51: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

ExampleExample

TASK: Alice need send to Bob the message x = 4.TASK: Alice need send to Bob the message x 4.Setup of the cryptosystem. Bob must:

Choose p = 3, q = 11 (two primes)C t 3 11 33Compute n = p × q = 3 × 11 = 33Compute the Euler’s function:ϕ (33) = (3 − 1) × (11 − 1) = 2 × 10 = 20ϕ ( ) ( ) ( )

Choose e = 3, acceptable since 0 < 3 < 20 and g.c.d.(20, 3) = 1, i.e., the integers 3, 20 are co-primeCompute d = 3−1 mod 20 = 7 (e.g., using Euclid’s Ext. Co pute d 3 od 0 (e g , us g uc d s tAlg.)

Bob’s private key is ks,B = (3, 11, 7, 20).Bob’s public key is k (33 3)Bob s public key is kp,B = (33, 3).This completes setup on Bob’s side (done only once).

Page 52: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

ExampleExampleSetup of the cryptosystem. Alice must:

Obtain Bob’s public key kp,B = (33, 3).This completes setup on Alices’s side (done only once).E i f h Ali Encryption of the message. Alice must:

Compute y = 43 mod 33 = 64 mod 33 = 31(e.g., using Square & Multiply Alg.)( g , g q p y g )Send y = 31 to Bob

This completes encryption on Alice’s side.Dencryption of the message. Bob private key kpriv,B = (7, 11, 3, 20)

Compute x 317 mod 33 27 512 614 111 mod 33Compute x = 317 mod 33 = 27.512.614.111 mod 33= 4 (e.g., using Square & Multiply Alg.)

Use x, it is the original plaintext Alice need to send , g pto Bob

This completes decryption on Bob’s side.

Page 53: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Other Public Key AlgorithmsOther Public Key AlgorithmsElGamal Cryptosystem

Based on DLP over finite field (adaption of DH)• Variants of the ElGamal Signing Algorithm are adopted as

Digital Signature Standard Algorithms: DSA / DSSDigital Signature Standard Algorithms: DSA / DSSCandidate algorithm for future protocols: ECC -Elliptic Curve Cryptosystem y y

Based on DLP defined over points of elliptic curves: The algorithm is itself not covered by patents, while some implementation is coveredimplementation is covered

NTRU: considered very promising but:It is covered by patentss co e ed by pa e sDigital signature method has been proven to be insecure 2 time; new method not yet completely analyzed

XTR ll d fi d d ffi i t ECCXTR: well defined and efficient as ECC It is covered by patents

Page 54: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Identity-Based Cryptographyy yp g p yMain Idea: PK-Encryption where Identities are Public Keys

Certificate Server

StoreCertificate Trusted Authority:

IBE Key ServerMaster Secret

s = 1872361923616378

(…….Public Parameters)

Look up B b’ C ifi

SendIdentity

ReceivePrivate Key Recovery

ServerBob’s Certificate,Check revocation

Authenticate Server

Store Bob’s

[email protected]@a.comPublic Parameters Bob’s Private Key

Store Bob s Private Key

Encrypted using Bob’s Identity

o Key Server has a “Master Secret” to generate keys.

o Private key is generated from Master Secret and Identity.

o Enabled by mathematical functions defined over points of elliptic curves defined over finite fields (ECDLP)

Page 55: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Hash Functions and Data IntegrityHash Functions and Data IntegrityCryptographic Hash functions, captures the yp g p , pconcept of “Integrity checksum”. A hash function compresses a message of

bit l th t di t f fi d l th arbitrary length to a digest of fixed length respecting the following fundamental conditions.

Looking at the digest, it is not possible to work out the original message.It i t ti ll i f ibl t fi d l It is computationally infeasible to find a couple of messages that hash to the same element.It is efficiently computable.y p

Page 56: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Hash Functions and Data IntegrityHash Functions and Data IntegrityWhen a transmitter sends a message coupled with a hash value, the recipient of the data recomputes the hash from the data that is received and compares that value to the one received and compares that value to the one transmitted by the provider of the data.

If the original hash value and the recomputed one d t t h th th d t h b h d i do not match, then the data has been changed in some way.

Hashing functions, per se, provide a kind of g , p , pdigital fingerprint, without authentication.

o A common way to obtain data authentication and source authentication without using a and source authentication without using a public key scheme is the computation of a digital fingerprint given by the so-called

h i i d (MAC )message authentication codes (MACs).

Page 57: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Hash functions and Data Integrityg y

The security of the hashing function is The security of the hashing function is related to the size of the resulting digest (in bits).( )SHA-1 is a standard for computing checksum that uses a 160 bit digest.SHA-1 does not use secret keys. The checksum is computed with a public hashing function and needs to be stored in a safe way.

Page 58: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Hash Functions and Passwords

Hash functions are often used to store Hash functions are often used to store passwords for users who are logging onto a multi-user system.yWhen the user tries to log in with his or her established password, the login program hashes it and compares the newly hashed hashes it, and compares the newly hashed password with the stored hash.If the two are equal, the system assumes the If the two are equal, the system assumes the user typed in the right password.

E.g.: Linux login authentication is based on the standard hash function MD5; optionally a MAC with standard hash function MD5; optionally a MAC with Blowfish cipher (….the key can be a salted version of the login password itself)

Page 59: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Cryptographic ImplementationCryptographic Implementation

When it comes down to the implementation of When it comes down to the implementation of cryptographic systems both HW and/or SW implementations have to be considered depending on the particular application on the particular application. A good software implementation is highly dependent on optimizations of the algorithm w.r.t. th f t f th ti l / l tfthe features of the particular cpu/platform:

the specific instruction set memory (cache) systemparallelism (ILP, TLP)

In the case of hardware two types of devices are considered: ASIC or FPGAconsidered: ASIC or FPGAA cryptographic algorithm or protocol may be implemented through a sw/hw partitioning

th d lmethodology.

Page 60: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Software Implementationp

The most used metric for comparing different implementations is the pthroughput, i.e., the number of bits encrypted per secondThis could be a secondary metric compared to:

C d iCode sizeMemory requirementPower consumptionPower consumptionSecurity

Page 61: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

HW ImplementationHW Implementation

When the CPU is too slow or not available When the CPU is too slow or not available for other reasons a dedicate hardware is usedThere are different metric for comparing hw implementations

Critical path (or achievable clock frequency) is Critical path (or achievable clock frequency) is often used

but some time the clock frequency is not a metric since other blocks of the system (typically CPU or y ( yp yBUSes) impose the clock frequency of the system

Silicon area (this is the cost unit of a chip)Power consumptionpTime to market….

Page 62: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

HW implementationHW implementation

Silicon compilers are based on heuristicsThe optimal synthesis is depending onThe optimal synthesis is depending on the particular constraints imposed:

Critical pathArea constraints

Different architectures could turn in non-obvious synthesis resultsy

Page 63: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Attacks against cryptographic systemsac s aga s c yp og ap c sys e s

There is no security without an attack.If we want to protect data or communicationsIf we want to protect data or communications we should know who is the attacker and what are his resources and actual possibilities to psuccess in moving around the implemented security system.Not taking into consideration the potentially attack’s techniques during the design of a secure system, can make the use of cryptographic tools meaningless

Page 64: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Attacks against cryptographic systemsAttacks against cryptographic systems

Theoretical/Algorithmic AttacksTheoretical/Algorithmic AttacksThis term generally is referred to the set of attacks that work at mathematical levelThe aim is to decrypt the message without the key or recover the key from a set of encrypted messages

Misuse based AttacksTry to find weaknesses in the way the algorithm is used in practice i e storing the key in a external used in practice, i.e., storing the key in a external memory, send keys in clear, sign a certificate with the SnakeOil co. certification authority private key, etcetc…[Bruce Schneier] Cryptography plays a role in computer security, but buggy computer systems and vulnerable communications are a reality that and vulnerable communications are a reality that cryptography has not solved.

Page 65: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Side Channel AttacksSide Channel Attacks

Once a crypto algorithm is specified and its security verified with respect to the y ppreviously cited threats, it should be implemented in practice…This part was thought to be a simple engineering task

l i h b d dBut recently it has been demonstrated that digital devices release important information which enable to conceive information which enable to conceive powerful Implementation Attacks

Page 66: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Side ChannelsSide Channels

Some “physical” effects are involved on the computation of an encryption algorithmThese are:

P iPower consumptionExecution timeElectro magnetic radiationElectro magnetic radiationPlatform Architecture Design can also leak secret information during the execution of a cryptographic algorithm (e g Branch Target cryptographic algorithm (e.g., Branch Target Buffer Attack)

Page 67: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Side channelsSide channels

The encryption process is a function of basically two input data, the plaintext and h kthe secret key

Physical phenomenon can be collected, and usually are called tracesand usually are called tracesThus the trace (power, time or electromagnetic) is a function of the key g ) yand the plaintext If the plaintext is known, it is possible to

l t th t t th k d th relate the trace to the key and thus retrieve information on the secret key

Page 68: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Power AnalysisPower AnalysisOne of the most known side channel leak is the

ti it ll th l ipower consumption...it allows the power analysisSmartcards are particularly subject to this attack since the interface of the card is composed by 5 since the interface of the card is composed by 5 simple contacts:

Vcc and GNDCl k d tClock and resetData in/out

If the current required on the Vcc is measured, If the current required on the Vcc is measured, then it is possible to obtain the power consumption of the deviceD t th CMOS l i th ti i Due to the CMOS logic the power consumption is a function of the switching activity of the deviceUnbalanced execution could be exploitedUnbalanced execution could be exploited

Page 69: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Simple power Analysisp p yE.g., in the case of ECC cryptosystem the device computes the analogous of modular multiplication computes the analogous of modular multiplication following a sequence of doubling and addition of curve pointsA i t dditi i t d l h th bit f th A point addition is executed only when the bit of the key is equal to one A D D A D D D A D

If the power consumption If the power consumption of the point addition is relevant, it is sufficient to analyse a single power analyse a single power trace to find when a doubling is executed and conseguently guess the g y gsecret key bits.

o A more powerful attack is called Differential Power o A more powerful attack is called Differential Power Analysis (DPA) and also systems protected against SPA are vulnerable to this technique.

Page 70: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Timing AttackTiming Attack

This has been the first presented side channel attackc a e attacThe SPA countermeasures protect implementation even against timing p g gattackRecently a timing attack has been y goptimized to work even remotely against some SSL server

Side channel has been always intended as a threat for physical available devices…

Page 71: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Electromagnetic Analysisg yLike power is consumed, electromagnetic waves are emitted from silicon deviceswaves are emitted from silicon devicesBut while power need a physical contact for been measured, waves run “free” in the air,Thus it is theoretically possible to measure it even from long distance

IBM h d th itt d f SSL IBM has measured the emitted waves of an SSL server from about 20 meters outside the building

Like Power Analysis it is possible to mount y psimple electromagnetic analysis and differential electromagnetic analysis

Most of the SPA/DPA countermeasures protect Most of the SPA/DPA countermeasures protect implementation against SEMA and DEMAResearches are still open to understand if SPA/DPA t d t ti SPA/DPA countermeasure are good protection again all SEMA/DEMA attacks

Page 72: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

Fault injectionFault injectionAll precedent attacks are called passive p pattacks, the device computes the encryption algorithm without being disturbed by the attackerattacker.The device can be disturbed during the computation i e glitches on the power computation, i.e. glitches on the power supply or the external clock signal can affect the computation and faults can appear on h i l l f i l dthe nominal values of internal data

E.g., if it is possible to set to 0 all input of the last round of AES then the output is just the last round of AES then the output is just the last round key

This is enough to retrieve the secret keyg y

Page 73: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

DevicesDevices

PCSmartcardSmartcardMobile phoneSet Top BoxSet Top BoxTelevisionMP3 playerMP3 player….

Page 74: Algoritmi e Architetture per Sistemi Crittograficihome.deib.polimi.it/pelosi/lib/exe/fetch.php?media=teaching:000... · Algoritmi e Architetture per Sistemi Crittografici Gerardo

ApplicationsApplications

BankingDigital Right Managementg g g

Pay TVDVDMusic download

TelecomMobile phoneWireless LANIInternet

Car immobilizer….