Sec-02 Cryptography Introduction - Comlab · 5 9 Security Cryptographic algorithms zThe security of...

25
1 Network Network Security Security Marco Carli Marco Carli 2 Security Cryptography Cryptography “cryptography” <--> Greek: κρυπτο+γραφη (hidden/secret+writing) cryptography: the study of mathematical techniques related to information security that have the following objectives: Confidentiality: ensuring information is accessible only by authorized persons Data integrity: ensuring information is has not been altered by unauthorized or unknown means Authentication: verification of the identity of an entity Non-repudiation: preventing the denial of previous commitments or actions the most widely used tool for securing information and services it is one tool (not the only)

Transcript of Sec-02 Cryptography Introduction - Comlab · 5 9 Security Cryptographic algorithms zThe security of...

  • 1

    Network Network SecuritySecurity

    Marco CarliMarco Carli

    2

    Security

    CryptographyCryptography“cryptography” Greek: κρυπτο+γραφη(hidden/secret+writing)

    cryptography: the study of mathematical techniques related to information security that have the following objectives:

    Confidentiality: ensuring information is accessible only by authorized personsData integrity: ensuring information is has not been altered by unauthorized or unknown meansAuthentication: verification of the identity of an entityNon-repudiation: preventing the denial of previous commitments or actions

    the most widely used tool for securing information and services

    it is one tool (not the only)

  • 2

    3

    Security

    Crittografia e Crittografia e CrittoanalisiCrittoanalisiCrittologia:Scienza che ha lo scopo di studiare comunicazioni sicure

    Crittografia:Branca della Crittologia che ha come scopo la progettazione di algoritmi di cifratura e decifratura, al fine di garantire la segretezza e o l’autenticità dei messaggi

    Crittoanalisi:

    Branca della Crittologia che ha come scopo l’analisi di un cifrario per risalire all’informazione originaria, e/o la generazione di informazione cifrata contraffatta che possa essere accettata come autentica

    4

    Security

    CryptographyCryptographyConsiste nell’alterazione controllata di un messaggio (sequenza alfanumerica di caratteri) in maniera da renderlo non comprensibile a chi non dispone degli strumenti adeguati

  • 3

    5

    Security

    ModelloModello didi sistemasistema crittograficocrittografico tradizionaletradizionale

    6

    Security

    CryptographyCryptography: Basic Terminology: Basic Terminology

    plaintext - the original message

    ciphertext - the coded message

    cipher - algorithm for transforming plaintext to ciphertext

    key - info used in cipher known only to sender/receiver

    encipher (encrypt) - converting plaintext to ciphertext

    decipher (decrypt) - recovering ciphertext from plaintext

    Encryption DecryptionPlaintext Ciphertext

    OriginalPlaintext

  • 4

    7

    Security

    Semplice esempio di algoritmo crittografico: Semplice esempio di algoritmo crittografico: cifrari con cifrari con shiftshift

    Testo in chiaro: C A S A

    Testo cifrato: R P H P

    Chiave K = 15

    X ← M+K mod 26 K∈{0,1,…,25}

    Caesar cipher:

    Chiave K=3

    8

    Security

    Cryptographic algorithmsCryptographic algorithmsFunzioni matematiche usate per cifrare e decifrare un testo

    Possono essere caratterizzati da:type of encryption operations used

    • substitution / transposition / product

    number of keys used• single-key or private / two-key or public

    way in which plaintext is processed• block / stream

  • 5

    9

    Security

    Cryptographic algorithmsCryptographic algorithmsThe security of a cipher might rest in the secrecy of its restricted algorithm, however:

    whenever a users leaves a group, the algorithm must changecould be scrutinized by people smarter than you

    Modern cryptography relies on keys, a selected value from a large set (a keyspace), e.g., a 1024-bit number. 21024 values!

    Security is based on secrecy of the key, not the details of the algorithmChange of authorized participants requires only a change in key

    10

    Security

    Principio di Principio di KerckhoffsKerckhoffsLa sicurezza di un crittosistema, o cifrario,

    deve dipendere solo dalla segretezza della chiave

    e non dalla segretezza dell’algoritmo usato

    Jean Guillaume Hubert Victor Francois Alexandre Auguste Kerckhoffs von Nieuwenhof(1835-1903), filologo olandese, “La Criptographie Militaire” [1883]

  • 6

    11

    Security

    Cryptographic algorithmsCryptographic algorithmsdifferenti tipologie di algoritmi:

    Restricted algorithmil modo di operare dell’algoritmo non è conosciuto

    Key-based algorithmnormalmente l’algoritmo funziona in maniera conosciuta, la sicurezza è basata su una chiaveil vantaggio di usare delle chiavi e’ che e’ difficile mantenere segreto un algoritmo; soprattutto se questo deve essere conosciuto da entrambe le parti

    Algoritmi Key-based di tipo:simmetriciasimmetrici

    12

    Security

    Cryptography AttacksCryptography AttacksBrute-force search

    si tenta ogni possibile chiave su un frammento di testo in chiaroin media per avere successo occorre provare la metà delle chiavipossibili

    Cryptographic analysisSi basa sulla natura dell’algoritmo e sfrutta qualche conoscenzadelle caratteristiche generali del testo in chiaro e/o qualcheesempio di coppie testo in chiaro/testo cifrato

    • Doesn’t have to discover the key necessarily• The loss of a key without cryptoanalysis is called a compromise

  • 7

    13

    Security

    Types of Cryptanalytic AttacksTypes of Cryptanalytic AttacksWhat do we mean with “a bad guy breaks an encryption scheme”?

    There are three basic attacks:Ciphertext-only attack

    • The attacker has to recover the plaintext from only the ciphertextKnown-plaintext attack

    • Portions of the cipher are known as plaintext. The rest may be easier to recover

    Chosen-plaintext attack• The attacker can choose what plaintext to encrypt, again making it easier to

    recover other ciphertextChosen-ciphertext attack

    • The attacker can choose ciphertext and obtain the plaintext

    14

    Security

    CiphertextCiphertext onlyonly -- AttackAttackThe bad guy has seen (and presumably stored) some ciphertextthat can be analyzed

    One possible strategy to figure out the plaintext is to try all keysit is essential that he/she is able to recognize when he/she hassucceeded (often called recognizable plaintext attack)it is necessary to have enough ciphertext

    E’ l’attacco più difficile da realizzare ed è quello da cui è piùfacile difendersi

    In molti casi però l’attaccante può supporre delle caratteristicheriguardo il plaintext (e.g. se si sta trasmettendo un file PostScript, questo inizierà con una sequenza di caratteri nota..)

    attacco a parole probabili

  • 8

    15

    Security

    Known plaintext Known plaintext -- AttackAttackThe bad guy knows a pair

    How it is possible to obtain it...the secret data does not remain secret forever (e.g. the name of an attacked city)

    From that pairs, the attacker can try to figure out the mapping of some fraction of the text

    Some cryptographic schemes might be good enough to be secure against ciphertext only attacks but not against to known plaintext attacks

    in these cases, it is important to minimize the possibility for a bad guy to obtain pairs

    16

    Security

    Chosen plaintext Chosen plaintext -- AttackAttackThe bad guy can choose any plaintext and get the corresponding ciphertext from the system

    e.g. there is a telegraph service that encrypt and transmit messages; the bad guy can ask the telegraph company to transmit any plaintext he/she wants

    Some cryptographic schemes might be good enough to be secure against ciphertext only attacks and known plaintextattacks but not against to chosen plaintext attacks

    E’ l’attacco da cui è più difficile difendersi

  • 9

    17

    Security

    Computational DifficultyComputational DifficultyCryptographic algorithms should be reasonably efficient to compute for good guys (who know the keys)

    Cryptographic algorithms are not impossible to break without thekey: a bad guy can simply try all possible keys until one works

    The security depends on how much work is necessary to break itIt is the complexity of launching the attack that secures us

    Attack complexities:data complexity: a large number of expected inputs (e.g., ciphertext)processing complexity: a large number of operations requiredstorage complexity: a large amount of storage units required

    Often a scheme can be made more secure by making the key longer

    18

    Security

    Computational and Unconditional SecurityComputational and Unconditional Securitycomputational security

    given limited computing resources (e.g. time needed for calculations is greater than age of universe, or the cost required for the attack is not affordable), the cipher cannot be broken

    unconditional securityno matter how much computer power is available, the cipher cannot be broken since the ciphertext provides insufficient information to uniquely determine the corresponding plaintext

  • 10

    19

    Security

    Language Redundancy and CryptanalysisLanguage Redundancy and Cryptanalysishuman languages are redundanteg "th lrd s m shphrd shll nt wnt"

    letters are not equally commonly used

    in English e is by far the most common letter then T,R,N,I,O,A,S

    other letters are fairly rare

    cf. Z,J,K,Q,X

    have tables of single, double & triple letter frequencies

    20

    Security

    As the example shows, we don't actually need all the letters in order to understand written English text.

    Here vowels were removed, but they're not the only redundancy. cf written Hebrew has no vowels for same reason.

    Are usually familiar with "party conversations", can hear one person speaking out of hubbub of many, again because of redundancy in aural language also.

    This redundancy is also the reason we can compress text files, the computer can derive a more compact encoding without losing any information.

    Basic idea is to count the relative frequencies of letters, and note the resulting pattern.

  • 11

    21

    Security

    English Letter FrequenciesEnglish Letter Frequencies

    22

    Security

    Language Redundancy and CryptanalysisLanguage Redundancy and Cryptanalysis

    key concept - monoalphabetic substitution ciphers do not change relative letter frequencies

    discovered by Arabian scientists in 9th century

    calculate letter frequencies for ciphertext

    compare counts/plots against known values

    if Caesar cipher look for common peaks/troughs peaks at: A-E-I triple, NO pair, RST tripletroughs at: JK, X-Z

    for monoalphabetic must identify each lettertables of common double/triple letters help

  • 12

    23

    Security

    Abu alAbu al--KindiKindi

    Abu al-Kindi's "A Manuscript on Deciphering Cryptographic Messages",

    published in the 9th century

    rediscovered in 1987 in Istanbul

    24

    Security

    Brute Force SearchBrute Force Searchalways possible to simply try every key

    most basic attack, proportional to key size

    assume either know / recognise plaintext

  • 13

    25

    Security

    Cryptography: basicCryptography: basicCryptographers invent clever secret codes

    Cryptoanalysts attempt to break these codes

    The two disciplines help each other..!

    Fundamental Tenet of CryptographyFundamental Tenet of Cryptography

    If lots of people have failed to solve a problem, then it probably won’t be solved (soon).

    26

    Security

    ““SecondoSecondo principio principio fondamentalefondamentale””Often breaking a cryptographic scheme is not the the only way ofgetting what you want!

    You can get further with a kind word and a gunthan you can with a kind word alone.

    - Willy Sutton, bank robber

  • 14

    27

    Security

    A chiave segreta (simmetrica): le due parti che comunicano condividono un segreto (la chiave crittografica)

    A chiave pubblica (asimmetrica): la chiave crittografica è composta da due parti, una che tutti conoscono (chiave pubblica) e una che solo l’interessato conosce (chiave privata)

    Hash algorithm (message digest/one way transformation): una funzione hash è una trasformazione matematica in una sola direzione che a partire da un messaggio arbitrario (lunghezza variabile) genera messaggio/numero di dimensione fissata

    DifferentiDifferenti tipi tipi didi crittografiacrittografia

    Symmetric (secretSymmetric (secret--key) cryptographykey) cryptography

  • 15

    29

    Security

    ChipertextChipertextChiave segretaChiave segretacondivisacondivisa

    Chiave segretaChiave segretacondivisacondivisa

    Condivisione dellaCondivisione dellachiave segretachiave segreta

    Crittografia a chiave segreta (simmetrica)Crittografia a chiave segreta (simmetrica)La chiave utilizzata per cifrare è la medesima chiave utilizzata per decifrare (chiave simmetrica o Secret Key, Ks)

    Alcune volte detta: crittografia convenzionale o simmetrica

    30

    Security

    Encryption

    Ksimmetrica

    INPUT

    INPUT

    OUTPUT

    Schema di funzionamento: CifraturaSchema di funzionamento: Cifratura

    Messaggio in chiaro

    Messaggio cifrato

  • 16

    31

    Security

    Ksimmetrica

    Messaggio in chiaro

    Messaggio cifrato

    INPUT

    INPUT

    OUTPUT

    Decryption

    Schema di funzionamento: Schema di funzionamento: DecifraturaDecifratura

    32

    Security

    RequisitiRequisitiDue requisiti sono alla base di un utilizzo sicuro della cifraturasimmetrica:

    1. E’ necessario un algoritmo di cifratura robusto: un eventuale hacker non deve essere in grado di decifrare il testo cifrato o di scoprire la chiave anche se in possesso di un certo numero di testi cifrati e dei corrispondenti testi in chiaro.

    2. Mittente e ricevente devono scambiarsi la chiave segreta in modo sicuro e devono mantenere protetta la chiave. Tutte le informazioni scambiate in maniera riservata possono essere leggibili da un eventuale hacker che, venuto a conoscenza dell’algoritmo di cifratura, venisse in possesso anche della chiave simmetrica.

  • 17

    33

    Security

    OsservazioniOsservazioniIl problema di comunicare un messaggio di grosse dimensioni attraverso un canale insicuro si riduce a quello di comunicare una chiave di ridotte dimensioni attraverso un canale sicuro

    in questo caso si parla di meccanismi OOB (Out Of Band, fuori banda), come ad esempio incontrarsi di persona in un luogo sicuro per scambiarsi l’informazione.

    34

    Security

    OsservazioniOsservazioni

    E’ importante capire che, se le chiavi rimangono sempre le stesse, ed il numero di utenti che intendono utilizzare fra di loro un meccanismo di questo genere è elevato, si assiste ad un fenomeno noto come “esplosione del numero delle chiavi”.

    In un’organizzazione con n dipendenti in cui si utilizza la cifratura simmetrica, per ogni nuovo dipendente devono essere generate n chiavi.: solo così sarà possibile infatti avere un segreto condiviso fra ogni coppia di persone.

    Se poi si decidesse di aumentare il livello di sicurezza ricalcolando, con frequenza regolare, ciascuna chiave nel tempo, il numero sarebbe di gran lunga maggiore.

    Un sistema di questo genere è poco scalabile, perché per n grande (ad esempio in organizzazioni di livello nazionale) diventa ingestibile.

  • 18

    35

    Security

    CaratteristicheCaratteristicheRichiede una fase iniziale in cui ciascuna coppia di interlocutori si scambia la secret key in maniera sicura

    Il numero delle chiavi per realizzare una comunicazione reciproca tra N utenti (dispositivi) è pari a Nx(N-1)/2 (se le chiavi rimangono sempre le stesse)

    Viene generalmente utilizzato per proteggere, mediante codifica,informazioni (file) in un repository locale o trasmessi

    La robustezza dell’algoritmo è normalmente misurata dalla lunghezza delle chiavi: 40 bit (debole), 128 bit (forte)

    Algoritmi più diffusi: DES, 3DES, RC2, RC4, IDEA, AES

    36

    Security

    Security uses of secret key cryptographySecurity uses of secret key cryptographyTransmitting over an insecure channel

    the two parties agree on a shared secret key and use secret key cryptography to send messages

    Secure storage on insecure mediathe user uses a secret key to store and retrieve data on an (insecure) media

    Authenticationstrong authentication through a challenge-response mechanism

    Integrity checkgenerating a fixed-length cryptographic checksum associated with a message (Message Integrity Code - MIC)

    rA

    rBrA encrypted with KAB

    rB encrypted with KAB

  • 19

    37

    Security

    Difetti dei sistemi simmetriciDifetti dei sistemi simmetriciMetodo per scambio di chiavi assente

    Numero di chiavi troppo grande per gestire dei segreti condivisitra singoli utenti[ n(n-1) ]/2

    Asymmetric (publicAsymmetric (public--key) cryptographykey) cryptography

  • 20

    39

    Security

    Crittografia a chiave pubblica (asimmetriche)Crittografia a chiave pubblica (asimmetriche)Spesso detta crittografia asimmetrica

    La chiave utilizzata per cifrare (chiave di cifratura, Ke) è diversadalla chiave utilizzata per decifrare (chiave di decifratura, Kd)

    Le chiavi si usano in coppie, di cui una detta privata (segreta) e l’altra detta pubblica (disponibile a tutti)

    Un clear-text cifrato con la chiave privata può essere decifrato solo con la chiave pubblica e viceversa

    Ciascuna coppia di chiavi è caratterizzata da proprietà peculiari

    Data data datadata data data

    Data data datadata data data

    XXXX XXXXXXXX XXXX

    40

    Security

    Schemi di funzionamento: Schemi di funzionamento: IIoo casocaso

    Algoritmo asimmetrico

    Kprivata

    Messaggio in chiaro

    Messaggio cifrato

    INPUT

    INPUT

    OUTPUT

    Algoritmo asimmetrico

    Kpubblica

    INPUT

    INPUT

    Messaggio cifrato Messaggio in chiaro

    OUTPUT

  • 21

    41

    Security

    Schemi di funzionamento: Schemi di funzionamento: IIIIoo casocaso

    Algoritmo asimmetrico

    Kprivata

    Messaggio in chiaro

    Messaggio cifrato

    INPUT

    INPUT

    OUTPUT

    Algoritmo asimmetrico

    INPUT

    INPUT

    Messaggio cifrato Messaggio in chiaro

    OUTPUT

    Kpubblica

    42

    Security

    CaratteristicheCaratteristichePuò richiedere una fase iniziale in cui gli interlocutori si scambiano le rispettive chiavi pubbliche

    Il numero delle chiavi è proporzionale a N per la comunicazione reciproca tra N utenti (dispositivi)

    Viene generalmente utilizzato per distribuire chiavi simmetrichein un ambiente distribuito

    Algoritmi più diffusi: RSA, Diffie-Hellman, DSA

    La robustezza del sistema dipende anche dal sistema di certificazione delle chiavi di cifratura (se esiste..)

    L’impiego della crittografia a chiavi asimmetriche comporta l’implementazione di una PKI (Public Key Infrastructure)

  • 22

    43

    Security

    Transmitting over an insecure channeleach party has a paireach party encrypts with the public key of the other party

    Secure storage on insecure mediaencrypt with public key, decrypt with private keyuseful when you can let third party to encrypt data

    Authenticationpublic key gives the real benefitno n(n-1)/2 keys are needed

    Digital signaturebased on cryptographic checksum

    Security uses of public key cryptographySecurity uses of public key cryptography

    encrypt mA using eBdecrypt mB using dA

    decrypt mA using dBencrypt mB using eA

    encrypt r using eB decrypt to r using dBr

    44

    Security

    Vantaggio dei sistemi a chiave pubblicaVantaggio dei sistemi a chiave pubblicaOgni utente deve mantenere solo un segreto (la propria chiave privata)

    Le chiavi pubbliche degli altri utenti possono essere mantenuti tramite infrastrutture intermediarie sicure (PKI)

    Il numero delle chiavi è proporzionale a N per la comunicazione reciproca tra N utenti

  • 23

    45

    Security

    algoritmi di algoritmi di cifraturacifratura simmetrici e simmetrici e assimmetriciassimmetriciEntrambi gli algoritmi, simmetrici o asimmetrici, consentono di cifrare un messaggio; gli algoritmi simmetrici sono preferiti nei casi in cui sia necessaria una certa velocità di esecuzione della cifratura

    Un buon sistema crittografico usa al meglio i due tipi di algoritmo:Uso di algoritmo asimmetrico per lo scambio sicuro di chiavi e per l’autenticazione Uso di algoritmo simmetrico per lo scambio dei dati

    Hash functionsHash functions

  • 24

    47

    Security

    Hash AlgorithmsHash AlgorithmsAlso known as message digests or one way transformations

    Hash function is a mathematical transformation m that takes a message of arbitrary length and computes a fixed-length (short) number/string h(m)

    Properties:for any message m, it relatively easy to compute h(m)given h(m) there is no way to find m in a way easier than computing all possibilitiesit is computationally infeasible to to find two values that hash to the same thing

    Examples of hash algorithms: MD2, MD5, SHS

    HashINPUT

    OUTPUTh(m)

    m

    48

    Security

    Password Hashinga system may know/store just the hash of a passwd

    Message Integrityhash function used to generate a MICit is required a passwd

    Message fingerprintmaintaining a copy of a message digest of some data/program in place of the copy of the entire data (for integrity check)

    Digital signatureSigning the MD of a message instead of the entire message

    • for efficiency (MDs are easier to compute than public-key algorithms)

    Security uses of Hash AlgorithmsSecurity uses of Hash Algorithms

    Message + passwd hash

    passwd

    +

    = ?

    hash

  • 25

    49

    Security

    Dove la crittografia non ci aiutaDove la crittografia non ci aiutaProtezione di sistema:

    Accesso non autorizzato alle risorse HW e SWAlterazione dei programmi SW (virus, ecc.)Attacchi mirati a rendere inutilizzabili i dispositivi ed i programmi …

    Protezione dei servizi:Attacchi mirati a rendere indisponibili i serviziAlterazione dei contenuti informativi di databaseUtilizzo illecito di servizi ed informazioni