Cryptography on a Customized Network Mathematics And
Total Page:16
File Type:pdf, Size:1020Kb
Cryptography on a Customized Network Ricardo Martinho Ferreira Miranda Thesis to obtain the Master of Science Degree in Mathematics and Applications Examination Committee Chairperson: Prof. Maria Cristina Sales Viana Serodioˆ Sernadas Supervisor: Prof. Paulo Alexandre Carreira Mateus Co-supervisor: Bruno Neto de Oliveira Tavares Member of the Committee: Prof. Andre´ Nuno Carvalho Souto November 2017 Acknowledgements I want to thank both my supervisors Paulo Mateus and Bruno Tavares for all their support and guid- ance. I would also like to thank my dearest friend Sofia Brito, whose counseling and motivation were crucial aspects in the overcoming of the most difficult moments. i ii Resumo Construir uma rede segura para ser utilizada em aplicac¸oes˜ reais onde ha´ restric¸oes˜ impostas as` capacidades dos elementos da rede e a` transferenciaˆ de informac¸ao˜ necessita uma analise´ crip- tografica´ costumizada de forma a proteger as comunicac¸oes˜ e detectar e minimizar as vulnerabilidades do sistema que poderao˜ ser exploradas. Neste documento, uma rede com essas condic¸oes˜ e´ apre- sentada, procura-se encontrar um esquema topologico´ otimo´ antes de se escolherem os componentes criptograficos´ da rede embutidos nas comunicac¸oes˜ e armazenamento e posteriormente analiza-se a sua seguranc¸a. De entre as alternativas escrutinadas, apenas uma e´ escolhida como a soluc¸ao,˜ por comparac¸ao˜ em termos de performance, seguranc¸a e adaptac¸ao˜ as` restric¸oes˜ impostas. Esta soluc¸ao˜ e´ implementada usando as linguagens de programac¸ao˜ C e Java. Prova-se que os esquemas de encriptac¸ao˜ e protocolos escolhidos sao˜ opc¸oes˜ altamente adequadas e o seu uso na pratica´ e´ acon- selhado. Estes resultados sao˜ apenas validos´ para este espec´ıfico caso de estudo, uma vez que na eventualidade de alguma das restric¸oes˜ ser alterada entao˜ e´ provavel´ que exista uma soluc¸ao˜ diferente da sugerida e mais apropriada. Palavras-chave: indistinguibilidade de texto cifrado; modo de operac¸ao˜ de cifra de bloco; seguranc¸a semantica;ˆ sistema de encriptac¸ao˜ simetrico.´ iii iv Abstract Building a secure network to be used in real-world applications where there are constraints strictly imposed to the capabilities of the network’s elements and to the data flow requires a customized crypto- graphic analysis in order to protect the communications and detect and minimize the system’s exploitable vulnerabilities. In this document a network under such conditions is presented and one is challenged with providing an optimal topological scheme prior to choosing the network’s cryptographic components embedded in the communication and data storage protocols and posteriorly analyzing their security. Among the scrutinized alternatives a single one of them is elected as the solution by a comparison in terms of performance, security and suitability under the enforced restrictions. This solution is imple- mented using C and Java programming languages. The selected encryption schemes and protocols are proven to be highly reasonable options and their use in practice is advised. These results are only valid for this specific case of study, for if any of the established constraints is ruled out then it is most likely the insurgence of an enhanced solution. Keywords: ciphertext indistinguishability; block cipher mode of operation; semantic security; symmetric cryptosystem. v vi Glossary In The set fk 2 N : 1 ≤ k ≤ ng. P (A) Probability of occurrence of event A.. A∗ The Kleene star of A. I The set of unique identifiers of gathering devices. O f 2 O(g) , 9 + 9 8 jf(x)j ≤ Mjg(x)j M2R x02R x≥x0 . ∗ bitstring An element of Z2. byte A metric related with data-storage, composed by 1 octet. kB 1 kB = 1024 bytes. octet A sequence of 8 bits. vii viii List of Abbreviations bxc Floor function of x, for some x 2 R. 0j The bitstring composed of j ’0’s, for some j 2 N. 1j he bitstring composed of j ’1’s, for some j 2 N. [w]2 Binary representation of the word m. dxe Ceiling function of x, for some x 2 R. wjk Suffix of w of length k, for some k 2 N. wjk Prefix of w of length k, for some k 2 N. x k y Concatenation of words x and y. x n y Difference of x and y. jwj2 The number of bits of the word w. 3DES Triple DES. ACK Acknowledgement. AES Advanced Encryption Standard. BCMO block cipher mode of operation. CA certificate authority. CBC Cipher Block Chaining. CCM Counter with CBC-MAC. CFB Cipher Feedback. CPU central processing unit. CSPRNG cryptographically secure pseudo-random number generator. CTR Counter. CTR-H CTR mode with HMAC-256 checksum. DAL Downstream Algorithm Lifecycle. DB database. DDL Downstream Data Lifecycle. DES Data Encryption Standard. ix EAP Extensible Authentication Protocol. ECB Electronic Codebook. ECC Elliptic Curve Cryptography. FIFO First in first out. GCM Galois Counter Mode. GD Gathering device. GDj gathering device with unique identifier j 2 I. GMAC Galois Message Authentication Code. GTK Group Temporal Key. HMAC hash-based message authentication code. IEEE Institute of Electrical and Electronic Engineers. IEEESA Institute of Electrical and Electronic Engineers Standards Association. IND-CCA Indistinguishability under chosen-ciphertext attack. IND-CPA Indistinguishability under chosen-plaintext attack. IV initialization vector. KDF key derivation function. LAN local area network. MAC message authentication code. MIC message integrity code. MiM Man-in-the-middle. MnDM Mission and data manager. MPP Middle-point party. NIST National Institute of Standards and Technology. PBKDF2 password-based key derivation function 2. PCgF package ciphertext generator function. PCuF package ciphertext unpacking function. PMK Pairwise Master Key. PMS pre-mission system. POA Padding Oracle Attack. x PRF pseudo-random function. PRNG pseudo-random number generator. PSch packing scheme. PSK Pre-shared key. PTK Pairwise Transient Key. RFC Request for Comments. SEM-CPA Semantic security under chosen-plaintext attack. SPN Substitution Permutation Network. SSID Service Set Identifier. UAL Upstream Algorithm Lifecycle. UDL Upstream Data Lifecycle. WLAN wireless local area network. XOR exclusive-or operation. xi xii List of Tables 4.1 Comparison between CTR and CFB features. 58 xiii xiv List of Figures 2.1 Encryption round of a SPN. Corresponds to the round function g from cryptosystem 4. It is used in all rounds except the last. 11 2.2 Network Layout. 21 2.3 Extensible Authentication Protocol (EAP). 22 2.4 WPA2 four-way handshake. 23 2.5 WPA2 group-key handshake. 23 2.6 Man in the middle attack. Eve is able to intercept the message and/or jam the communi- cation channel at will. 25 3.1 General purpose and activity of the envisaged network. 36 3.2 General layout of the desired network. 37 3.3 Pre-deployment stage . 37 3.4 Topology of AP-based networks. 39 3.5 Topology of the ad-hoc network. 40 4.1 Key generation based on k users . 52 5.1 Pre-processing steps of the secret pass for the generation of the seed of the SHA-1 pseudo-random function. 62 5.2 Scatter plots of the average key generation time per number of gathering devices. 64 5.3 Upstream Algorithm Lifecycle . 69 5.4 Downstream Algorithm Lifecycle . 73 A.1 ECB mode encryption and decryption procedures using an arbitrary block cipher B.... 81 A.2 CBC mode encryption and decryption procedures using an arbitrary block cipher B.... 82 A.3 CFB mode encryption and decryption procedures using an arbitrary block cipher B.... 83 A.4 CTR mode encryption and decryption procedures using an arbitrary block cipher B.... 84 B.1 KeyGeneratorApp’s initial screen. 86 B.2 KeyGeneratorApp’s target choice screen. 87 B.3 KeyGeneratorApp’s file details. 88 B.4 KeyGeneratorApp’s key export final step. 89 xv B.5 KeyGeneratorApp’s key checker example screen. 89 B.6 Pre-deployment stage secret information’s revealment. 90 ∗ C.1 Message format F1 ....................................... 91 C.2 Message format F1 ........................................ 91 ∗ C.3 Message format F2 ....................................... 92 C.4 Message format F2 ........................................ 92 ∗ C.5 Message format F3 ....................................... 93 C.6 Message format F3 ........................................ 93 ∗ C.7 Message format F4 ....................................... 94 C.8 Message format F4 ........................................ 94 ∗∗ C.9 Message format F5 ....................................... 94 ∗ C.10 Message format F5 ....................................... 95 C.11 Message format F5 ........................................ 95 xvi Contents Resumo iii Abstract v Glossary vii List of Abbreviations ix List of Tables xiii List of Figures xv 1 Introduction 1 1.1 Summary . .1 2 Basic Concepts 3 2.1 Cryptanalysis . .4 2.2 Modern Cryptography . .6 2.2.1 Block Ciphers . .6 2.2.1.1 Linear and Differential Cryptanalysis . .7 2.2.1.2 DES and 3DES . .8 2.2.1.3 AES . .9 2.2.2 Block Cipher Modes of Operation . 11 2.2.2.1 ECB . 12 2.2.2.2 CBC . 12 2.2.2.3 CFB . 13 2.2.2.4 CTR . 13 2.2.2.5 CCM . 14 2.2.2.6 GCM . 15 2.2.2.7 Padding . 15 2.2.3 Asymmetric Cryptography . 16 2.3 Cryptographic Hash Functions . 16 2.3.1 SHA-256 . 17 xvii 2.3.2 HMAC . 18 2.4 Randomness . 18 2.4.1 Key Derivation . 19 2.5 Communication Protocols in Wireless Networks . 20 2.5.1 WEP . 20 2.5.2 WPA/WPA2 . 21 2.5.2.1 Initial Authentication . 21 2.5.2.2 4-way Handshake . 22 2.5.2.3 Group-key Handshake . 23 2.6 Known Attacks . 24 2.6.1 Brute Force and Dictionary Attacks . 24 2.6.2 Man In The Middle Attack . 24 2.6.3 Birthday Attack . 25 2.6.4 Replay Attack . 26 2.6.5 Padding Oracle Attack . 26 2.6.6 Stream Cipher Attacks .