Alice and Bob in Wonderland a First Glimpse in the World of Security and Cryptography
Total Page:16
File Type:pdf, Size:1020Kb
NXP SEMICONDUCTORS Alice and Bob in Wonderland A first glimpse in the world of security and cryptography September 2018 Mario Lamberger Agenda Introduction The Good The Bad The Ugly The Future COMPANY PUBLIC Introduction About myself MSc, PhD in technical mathematics, TU Graz Post-doc assistant at IAIK @ TU Graz – Java + network security, cryptography Habilitation in IT-Security @ IAIK/TU Graz 20+ publications in mathematics, cryptography, IT-security Principal Cryptographer and Security Assessment expert @ NXP – Joined 2011 – Works on crypto libraries, certification topics, analysis on random number generators – Lead of „NXP Security School“, trainings on cryptography, certification topics, implementation security Trained more than 2500 employees COMPANY PUBLIC THE GOOD Security in general COMPANY PUBLIC Key security requirements “Hello Confidentiality World” Integrity Keeping secrets Ensuring unmodified secret (business value data transport & “Hello “Hello of data, privacy – unmodified SW World” World” encryption is the execution technology of choice) Authenticity Alice Availability Verifying identities for Ensuring that the source of data/SW, “Fake” Bob services remain (trusted access control available operations) Bob “Fake” Alice COMPANY PUBLIC CONFIDENTIALITY Historic examples: This ... is ... Sparta! Scytale: – Oldest known military encryption scheme. – It was used by the Spartans already 2500 years ago to encrypt messages. – For encryption a wooden cylinder has been used with a certain diameter (acting as the key). The Scytale is a transposition cipher. Alternative hypothesis: Message authentication COMPANY PUBLIC Historic examples: Alea iacta est! Caesar cipher – The Caesar-Cipher is named after Julius Caesar (100-40 B.C.). – It was used for military correspondence. – For encryption the letters of the message where replaced by different letters of the same alphabet. The Caesar cipher is a substitution cipher. Other examples: – Vigenère cipher – Hill cipher – ... COMPANY PUBLIC Ceasar cipher in our days... Cipher text Ns hwduytlwfumd, f Hfjxfw hnumjw, fqxt pstbs fx Hfjxfw'x hnumjw, ymj xmnky hnumjw, Hfjxfw'x htij tw Hfjxfw xmnky, nx tsj tk ymj xnruqjxy fsi rtxy bnijqd pstbs jshwduynts yjhmsnvzjx. Ny nx f yduj tk xzgxynyzynts hnumjw ns bmnhm jfhm qjyyjw ns ymj uqfnsyjcy nx wjuqfhji gd f qjyyjw xtrj kncji szrgjw tk utxnyntsx itbs ymj fqumfgjy. Ktw jcfruqj, bnym f xmnky tk Shift 3, F btzqi gj wjuqfhji gd I, G btzqi gjhtrj = 5 J, fsi xt ts. Ymj rjymti nx sfrji fkyjw In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the Ozqnzx Hfjxfw, bmt zxji ny ns mnx simplest and most widely known encryption techniques. It is a type uwnafyj htwwjxutsijshj. of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named after Julius Caesar, who used it in his private correspondence. COMPANY PUBLIC Symmetric Cryptography Symmetric key information Enc Dec COMPANY PUBLIC Important Features and Principles of Block Ciphers n-bit block size Kerckhoff’s principle: – The attacker always knows the Plaintext (P) algorithm; the only information unknown to him/her is the key. – DES (1976) 010 010 Key Cipher 010 k-bit key Brute force attack (K) .. – Basically, given P and C, try out all 010 possible K – Possible on every cipher Ciphertext (C) COMPANY PUBLIC Modern Encryption Practice: Block Ciphers Practical version of block substitution cipher for fixed key – Easy computation rule instead of huge table 1 1 2 2 3 3 ... ... 4 4 Introduce computation rule to compute table elements: ... ... [m] = E (m, k) S Goal is to design „good“ rule E : S COMPANY PUBLIC https://www.youtube.com/watch?v=mlzxpkdXP58 COMPANY PUBLIC Performance, performance, performance... AES instructions (Intel, ARM, NXP, ...) PXOR %xmm5, %xmm0 AESENC %xmm6, %xmm0 Intel: AESENC %xmm7, %xmm0 AESENC %xmm8, %xmm0 AESENC takes 4 cycles, so 40 cycles for full AES (at 2GHz 800MB per second!) AESENC %xmm9, %xmm0 AESENC %xmm10, %xmm0 AESENC %xmm11, %xmm0 Remember the brute-force attack from before? AESENC %xmm12, %xmm0 AESENC %xmm13, %xmm0 AESENC %xmm14, %xmm0 Above Intel PC: 5 10 encryptions per sec AESENCLAST %xmm15, %xmm0 10 years 7 23 ⋅ Computing power of Bitcoin network: 5 10 encryptions per sec 2,1581810 = 2.158.000.000.000 years ≈ ⋅ 12 13.799.000.000 years age of our universe ⋅ COMPANY PUBLIC Widely used block ciphers Triple-DES – IBM + NSA – Based on DES (1976) AES – V. Rijmen/J. Daemen SM4 – Chinese cipher – Chinese wireless LAN cipher standard (WAPI) COMPANY PUBLIC How to encrypt large amounts of data ? Block by block ECB point in time 1 point in timepoint 1 in timepoint 2 in time 22 pointpointpoint ininin time timetime t tt ... ...... Cipher block chaining CBC IVm1 Ctr block 1n nm1 Ctr nblockm 22 n nn mmCtrtt block t nnn Counter mode CTR cii = ES(cmi-1i, k )mi,E kS), i>0 k ES k ES EkS kk EEESSS kkk m1 n m2 n mt n ...... c1 nc1 c2 n c2 n nn ... cccttt nnn SenderSender Receiver Receiver ...... point in time 1 c1 pointn inc time2 2 nn ccttpoint in time tnn Ctr block 1 n Ctr block 2 n ... Ctr block t n mii = DS(cii, k) ci-1, i>0 DS k DS kk DDSS kk ES k ES k ES k ... c1 IV n n c2m1 n n m2 ct nn ... mmtnt nn m1 n m2 n ... mt n COMPANY PUBLIC What would you prefer ? CBC/CTR mode output COMPANY PUBLIC INTEGRITY Cryptographic Hash Functions – Protecting Integrity Analogy: digital fingerprints NOT to be confused with: Data – Hash tables in databases Compression: Data of arbitrary length is mapped to a fixed length of bits (Typical values: = 256 bits) Hash Easy to compute : Hash functions should be very efficient! Cryptographic properties: NO COLLUSION NO COLLISIONS! A hash function should be hard to invert! It should be hard to find two data elements with the same hash value COMPANY PUBLIC Cryptographic Hash Functions Applications – “Historic” Important building block: >100 occurences in Windows operating system 98246 012345 6789… ? Representative Commitment Randomizer SHA256(“Mario”) = 61 C8 E1 6A D9 0D 4E 6D A3 17 18 0F A4 45 E2 62 E9 31 3B BF 21 FD 4D 30 B3 B9 B4 42 58 86 B2 F5 SHA256(“Marion”) = 34 17 CF DF 67 C5 1B 20 FE 04 24 BC 47 D5 69 2E 87 59 FB 06 B3 6D 48 28 A6 AD 1C 65 4A 9D C3 67 COMPANY PUBLIC Cryptographic Hash Functions Applications – Today Bitcoin mining Proof of work (c) https://coincentral.com Solving “hash puzzles” (SHA-256) August 2017, the mining difficulty (block #479669) (bit security ~2 . ) 71 65 0000000000000000005d68cd57cfb4f925aa1e3e729feb0cb81a64393306ad4f COMPANY PUBLIC Hash functions – a quick look under the hood MD4-family of hash functions Current state-of-the-art: SHA-2 family (FIPS 180-4) Alternative construction: SHA-3 (sponge contruction) – Again a competition, – Again J. Daemen COMPANY PUBLIC AUTHENTICITY AKA RECYCLING IN CRYPTO Message Authentication Codes (block cipher based) Recycling in cryptography: point in time 1 point in time 2 point in time t ... CBC mode of operation IV n m1 n m2 n mt n CBC MAC ci = ES(ci-1 mi, k), i>0 ES k ES k ES k (ISO/IEC 9797-1 MAC Algorithm 1) ... CMAC c1 n c2 n ct n Sender (NIST SP 800-38B) Receiver c1 n c2 n ... ct n mi = DS(ci, k) ci-1, i>0 DS k DS k DS k IV n m1 n m2 n ... mt n COMPANY PUBLIC HMAC – keyed-hash message authentication code Originally defined in 1996 Used extensively by IETF (RFC2104) Widely standarized NIST FIPS 198-1 ( )|| || ′ ′ ⊕ ⊕ 1 Hash Hash ( , ) COMPANY PUBLIC Using Encryption for Authentication Basic authentication principles: – Something known – Something possessed – Something inherent How to NOT do it: ID E = Enc(ID, Key) Key Key E COMPANY PUBLIC A simple example for an authentication protocol All modern authentication protocols use a time-variant parameter – Nonce (random challenge) – Timestamp – Sequence number Challenge – response protocol Challenge R Key Key E = Enc(R, Key) Different for each authentication run! COMPANY PUBLIC PUBLIC KEY CRYPTO AKA ASYMMETRIC CRYPTO The problem so far ... How do Alice and Bob get their symmetric keys in the first place ? What if Alice and Bob are not the only people on earth ? A B E F 15 keys C D 7 10 people 25 10 keys 9 18 After⋅ 2500 years it≈ was⋅ time for a new concept ... COMPANY PUBLIC COMPANY PUBLIC Public Key Signatures CREATE Remember 00110…..11001 11111…..10011 11111…..10011 hash digitally digitally signeddocument hash private key sender signed hash collisions ? hash 00110…..11001 compare VERIFY 00110…..11001 11111…..10011 digitally signeddocument public key sender COMPANY PUBLIC Asymmetric/ Public Key Cryptography Based on hard and long-studied mathematical problems from number theory, algebra, … In theory, no initial key exchange between Alice and Bob The idea: – Each participating party owns a key pair – A key pair consists of • A public key (can be known to everybody) • A private key (must stay under the sole control of the owner) COMPANY PUBLIC RSA (Rivest, Shamir, Adleman, 1978) Based on the so called factorization problem: dC – Given two prime numbers, it is easy to multiply them. d Given the product, it is difficult to find the prime numbers. B A: nA,eA B: n ,e RSA Keys – Every participant has B B C : nC,eC – a modulus n = p·q (public), the product of two large prime numbers – a public exponent e (for performance reasons, one often chooses small prime numbers with few 1’s) e = 216 + 1 are common choices (e = 3,17 in old designs) dA – a private exponent d.