Index ■ Q–S 283Preneel, Bart, 145prime factorization, 97prime number theorem, 98prime numbersFermat’s little theorem, 100generating large ones, 104–106Miller-Rabin primality test, 100–104overview, 97–98prime number theorem, 98school primality test, 98–99Print() function, 13privacy enhanced electronic mail (PEM),70–71protocolscryptographic protocols, 32–33, 46–47Kerberos protocol, 36, 39–40multiple-domain Kerberos, 40–41Needham-Schroeder protocols, 36–38Network Time Protocol (NTP), 42Otway-Rees protocol, 38public-key protocol, 36–37symmetric key protocol, 36Transmission Control Protocol (TCP), 212User Datagram Protocol (UDP), 212pseudorandom number generation (PRNG),115, 141–144pseudorandomnessbreaking C’s rand() function, 116overview, 115public key MAC encryption, forincorporating message hashing, 200–201public-key certificates, 42public-key infrastructure (PKI)described, 223–224implementing of in application using RSAcertificates, 255–261public-key protocolas second protocol of Needham-Schroederprotocols, 36–37as similar to protocol proposed by Otwayand Rees, 38public-key transformationconstructing BLOB encryption anddecryption with, 232–235constructing simple text decryption withRSA certificates, 231–232exploring basics of RSA, 226–229generating RSA certificates, 229–230overview, 224–226PyFITS, described, 3Pythonbasics of, 9–29downloading and installing, 3–8installing additional packages, 5installing Cryptography package, 7–8reasons to use, 2–3upgrading packages, 5using AES with, 167–169Python 2, as unsupported, 3Qquotesdouble quote ("), 11single quote (’), 11RR file operator, 19r+ file operator, 19R A (notation in cryptographic protocols), 37Rabin, Michael, 100rainbow table, 67RC4, 147reflection attack, 211relational operators, 13remove() method, 25reordering attack, 211replay attack, 211requests module, 27reserved words, 9reverse cipher, creating, 29reverse() method, 25reverseCipher function, 29Rivest, Ron, 34, 226ROT-13, 76RSA algorithm, 104, 226–235, 242RSA certificatesconstructing BLOB encryption anddecryption with, 232–235constructing simple text encryption anddecryption with, 231–232generating, 229–231implementing PKI in application using,255–261RSAES-OAEP, 231SSalsa20 cipher, 149–151Schneier, Bruce, 162school primality test, 98Schroeder, Michael, 36SEC (Standards of Efficient Cryptography), 241secondary resistance, 59secret sharing, 33secret splitting, 33Secure Hash Algorithms (SHAs), 203–204,205, 209securing elections, 33security protocols, as another name forcryptographic protocols, 32Segmented Integer Counter mode, 162–164
284 Index ■ T–Zself-signed certificate, 45–46semantics, understanding Python semantics,20sequence types, 20–26servercreating one for constructing plaintextcommunications application, 248–250modifying of for implementing PKI inapplication using RSA certificates,256–257server file, modifying of in implementingDiffie-Hellman key exchange, 262–264server socket, creating, 212–213SHA, 203–204Shamir, Edi, 34, 226Shannon, Claude (father of informationtheory), 31, 50Shannon’s theorem, 50–51shared key (SK), 34side-channel attacks, 48SIMD (single instruction, multiple data),151–152single quote (’), 11Skipjack, 36Smith, J. L., 159social engineering, 48sort() method, 25Spartan scytale, 73Standards of Efficient Cryptography (SEC),241Steganographia (Trithemius), 187–188steganographyoverview, 187–188storing binary file inside image, 192–194storing message inside image, 188–191working with large images, 195–197str sequence type, 20stream ciphersARC4, 147–148ChaCha cipher, 151–156overview, 141–147Salsa20 cipher, 149–151Vernam cipher, 148–149stream modes, 164–165stretching (of passwords), 68stringsuse of, 11using quotes to define, 21subtraction - operator, 12symmetric algorithms, 36symmetric encryption, 8, 36, 39, 49, 176, 215–218symmetric key, 35symmetric key confidentiality, forincorporating message hashing, 201symmetric key protocol, 36symmetric public key confidentiality, forincorporating message hashing, 201Tt A (notation in cryptographic protocols),37Ticket Granting Servers (TGS), 40timestamping, 33Transmission Control Protocol (TCP), 212,214–215Transport Layer Security (TLS), 33Triple DES, 156Trithemius, Johannes (author),Steganographia, 187Trivium, 145trusted third party (TTP), 35Tuchman, W. L., 159tuple() function, 25tuple sequence type, 20, 21, 24, 25The Twelve Caesars, 74–76UUbuntu, installing Python on, 4unhexlify module, 140Unicode sequence type, 20User Datagram Protocol (UDP), 212Vvalidation, formal validation ofcryptographic protocols, 46–47values, as stored in variables, 10variables, use of, 10–11Vernam, Gilbert, 148Vernam cipher, 148–149Vignère cipher, 77–79, 129–137WW file operator, 19W+ file operator, 19while loop, 18whitespace, as meaningful, 10Windows, installing Python on, 4Wireguard, 145Wireshark, installing and testing, 253–254XX.509, 41–42XOR, 50–55xrange sequence type, 20, 21Zzero-knowledge proofs, 33
- Page 2 and 3:
ImplementingCryptography UsingPytho
- Page 4 and 5:
To Stephanie, Eden, Hayden, and Ken
- Page 6 and 7:
viAbout the Authorbook, Shannon is
- Page 8 and 9:
Contents at a GlanceIntroductionxvi
- Page 10 and 11:
xiiContentsUsing Conditionals 16Usi
- Page 12 and 13:
xivContentsPseudorandomness115Break
- Page 14 and 15:
xviContentsInstalling and Testing W
- Page 16 and 17:
xviiiIntroductionprivacy advocates.
- Page 18 and 19:
CHAPTER1Introduction to Cryptograph
- Page 20 and 21:
Chapter 1 ■ Introduction to Crypt
- Page 22 and 23:
Chapter 1 ■ Introduction to Crypt
- Page 24 and 25:
Chapter 1 ■ Introduction to Crypt
- Page 26 and 27:
Chapter 1 ■ Introduction to Crypt
- Page 28 and 29:
Chapter 1 ■ Introduction to Crypt
- Page 30 and 31:
Chapter 1 ■ Introduction to Crypt
- Page 32 and 33:
Chapter 1 ■ Introduction to Crypt
- Page 34 and 35:
Chapter 1 ■ Introduction to Crypt
- Page 36 and 37:
Chapter 1 ■ Introduction to Crypt
- Page 38 and 39:
Chapter 1 ■ Introduction to Crypt
- Page 40 and 41:
Chapter 1 ■ Introduction to Crypt
- Page 42 and 43:
Chapter 1 ■ Introduction to Crypt
- Page 44 and 45:
Chapter 1 ■ Introduction to Crypt
- Page 46 and 47:
Chapter 1 ■ Introduction to Crypt
- Page 48 and 49:
CHAPTER2Cryptographic Protocolsand
- Page 50 and 51:
Chapter 2 ■ Cryptographic Protoco
- Page 52 and 53:
Chapter 2 ■ Cryptographic Protoco
- Page 54 and 55:
Chapter 2 ■ Cryptographic Protoco
- Page 56 and 57:
Chapter 2 ■ Cryptographic Protoco
- Page 58 and 59:
Chapter 2 ■ Cryptographic Protoco
- Page 60 and 61:
Chapter 2 ■ Cryptographic Protoco
- Page 62 and 63:
Chapter 2 ■ Cryptographic Protoco
- Page 64 and 65:
Chapter 2 ■ Cryptographic Protoco
- Page 66 and 67:
Chapter 2 ■ Cryptographic Protoco
- Page 68 and 69:
Chapter 2 ■ Cryptographic Protoco
- Page 70 and 71:
Chapter 2 ■ Cryptographic Protoco
- Page 72 and 73:
Chapter 2 ■ Cryptographic Protoco
- Page 74 and 75:
Chapter 2 ■ Cryptographic Protoco
- Page 76 and 77:
Chapter 2 ■ Cryptographic Protoco
- Page 78 and 79:
Chapter 2 ■ Cryptographic Protoco
- Page 80 and 81:
Chapter 2 ■ Cryptographic Protoco
- Page 82 and 83:
66 Chapter 3 ■ Classical Cryptogr
- Page 84 and 85:
68 Chapter 3 ■ Classical Cryptogr
- Page 86 and 87:
70 Chapter 3 ■ Classical Cryptogr
- Page 88 and 89:
72 Chapter 3 ■ Classical Cryptogr
- Page 90 and 91:
74 Chapter 3 ■ Classical Cryptogr
- Page 92 and 93:
76 Chapter 3 ■ Classical Cryptogr
- Page 94 and 95:
78 Chapter 3 ■ Classical Cryptogr
- Page 96 and 97:
80 Chapter 3 ■ Classical Cryptogr
- Page 98 and 99:
82 Chapter 3 ■ Classical Cryptogr
- Page 100 and 101:
84 Chapter 3 ■ Classical Cryptogr
- Page 102 and 103:
86 Chapter 3 ■ Classical Cryptogr
- Page 104 and 105:
88 Chapter 3 ■ Classical Cryptogr
- Page 106 and 107:
90 Chapter 3 ■ Classical Cryptogr
- Page 108 and 109:
92 Chapter 3 ■ Classical Cryptogr
- Page 110 and 111:
CHAPTER4Cryptographic Mathand Frequ
- Page 112 and 113:
Chapter 4 ■ Cryptographic Math an
- Page 114 and 115:
Chapter 4 ■ Cryptographic Math an
- Page 116 and 117:
Chapter 4 ■ Cryptographic Math an
- Page 118 and 119:
Chapter 4 ■ Cryptographic Math an
- Page 120 and 121:
Chapter 4 ■ Cryptographic Math an
- Page 122 and 123:
Chapter 4 ■ Cryptographic Math an
- Page 124 and 125:
Chapter 4 ■ Cryptographic Math an
- Page 126 and 127:
Chapter 4 ■ Cryptographic Math an
- Page 128 and 129:
Chapter 4 ■ Cryptographic Math an
- Page 130 and 131:
Chapter 4 ■ Cryptographic Math an
- Page 132 and 133:
Chapter 4 ■ Cryptographic Math an
- Page 134 and 135:
Chapter 4 ■ Cryptographic Math an
- Page 136 and 137:
Chapter 4 ■ Cryptographic Math an
- Page 138 and 139:
Chapter 4 ■ Cryptographic Math an
- Page 140 and 141:
Chapter 4 ■ Cryptographic Math an
- Page 142 and 143:
Chapter 4 ■ Cryptographic Math an
- Page 144 and 145:
Chapter 4 ■ Cryptographic Math an
- Page 146 and 147:
Chapter 4 ■ Cryptographic Math an
- Page 148 and 149:
Chapter 4 ■ Cryptographic Math an
- Page 150 and 151:
Chapter 4 ■ Cryptographic Math an
- Page 152 and 153:
Chapter 4 ■ Cryptographic Math an
- Page 154 and 155:
CHAPTER5Stream Ciphers and Block Ci
- Page 156 and 157:
Chapter 5 ■ Stream Ciphers and Bl
- Page 158 and 159:
Chapter 5 ■ Stream Ciphers and Bl
- Page 160 and 161:
Chapter 5 ■ Stream Ciphers and Bl
- Page 162 and 163:
Chapter 5 ■ Stream Ciphers and Bl
- Page 164 and 165:
Chapter 5 ■ Stream Ciphers and Bl
- Page 166 and 167:
Chapter 5 ■ Stream Ciphers and Bl
- Page 168 and 169:
Chapter 5 ■ Stream Ciphers and Bl
- Page 170 and 171:
Chapter 5 ■ Stream Ciphers and Bl
- Page 172 and 173:
Chapter 5 ■ Stream Ciphers and Bl
- Page 174 and 175:
Chapter 5 ■ Stream Ciphers and Bl
- Page 176 and 177:
Chapter 5 ■ Stream Ciphers and Bl
- Page 178 and 179:
Chapter 5 ■ Stream Ciphers and Bl
- Page 180 and 181:
Chapter 5 ■ Stream Ciphers and Bl
- Page 182 and 183:
Chapter 5 ■ Stream Ciphers and Bl
- Page 184 and 185:
Chapter 5 ■ Stream Ciphers and Bl
- Page 186 and 187:
CHAPTER6Using Cryptography with Ima
- Page 188 and 189:
Chapter 6 ■ Using Cryptography wi
- Page 190 and 191:
Chapter 6 ■ Using Cryptography wi
- Page 192 and 193:
Chapter 6 ■ Using Cryptography wi
- Page 194 and 195:
Chapter 6 ■ Using Cryptography wi
- Page 196 and 197:
Chapter 6 ■ Using Cryptography wi
- Page 198 and 199:
Chapter 6 ■ Using Cryptography wi
- Page 200 and 201:
Chapter 6 ■ Using Cryptography wi
- Page 202 and 203:
Chapter 6 ■ Using Cryptography wi
- Page 204 and 205:
Chapter 6 ■ Using Cryptography wi
- Page 206 and 207:
Chapter 6 ■ Using Cryptography wi
- Page 208 and 209:
Chapter 6 ■ Using Cryptography wi
- Page 210 and 211:
Chapter 6 ■ Using Cryptography wi
- Page 212 and 213:
Chapter 6 ■ Using Cryptography wi
- Page 214 and 215:
200 Chapter 7 ■ Message Integrity
- Page 216 and 217:
202 Chapter 7 ■ Message Integrity
- Page 218 and 219:
204 Chapter 7 ■ Message Integrity
- Page 220 and 221:
206 Chapter 7 ■ Message Integrity
- Page 222 and 223:
208 Chapter 7 ■ Message Integrity
- Page 224 and 225:
210 Chapter 7 ■ Message Integrity
- Page 226 and 227:
212 Chapter 7 ■ Message Integrity
- Page 228 and 229:
214 Chapter 7 ■ Message Integrity
- Page 230 and 231:
216 Chapter 7 ■ Message Integrity
- Page 232 and 233:
218 Chapter 7 ■ Message Integrity
- Page 234 and 235:
220 Chapter 7 ■ Message Integrity
- Page 236 and 237:
222 Chapter 7 ■ Message Integrity
- Page 238 and 239:
224 Chapter 8 ■ Cryptographic App
- Page 240 and 241:
226 Chapter 8 ■ Cryptographic App
- Page 242 and 243:
228 Chapter 8 ■ Cryptographic App
- Page 244 and 245:
230 Chapter 8 ■ Cryptographic App
- Page 246 and 247: 232 Chapter 8 ■ Cryptographic App
- Page 248 and 249: 234 Chapter 8 ■ Cryptographic App
- Page 250 and 251: 236 Chapter 8 ■ Cryptographic App
- Page 252 and 253: 238 Chapter 8 ■ Cryptographic App
- Page 254 and 255: 240 Chapter 8 ■ Cryptographic App
- Page 256 and 257: 242 Chapter 8 ■ Cryptographic App
- Page 258 and 259: 244 Chapter 8 ■ Cryptographic App
- Page 260 and 261: CHAPTER9Mastering CryptographyUsing
- Page 262 and 263: Chapter 9 ■ Mastering Cryptograph
- Page 264 and 265: Chapter 9 ■ Mastering Cryptograph
- Page 266 and 267: Chapter 9 ■ Mastering Cryptograph
- Page 268 and 269: Chapter 9 ■ Mastering Cryptograph
- Page 270 and 271: Chapter 9 ■ Mastering Cryptograph
- Page 272 and 273: Chapter 9 ■ Mastering Cryptograph
- Page 274 and 275: Chapter 9 ■ Mastering Cryptograph
- Page 276 and 277: Chapter 9 ■ Mastering Cryptograph
- Page 278 and 279: Chapter 9 ■ Mastering Cryptograph
- Page 280 and 281: Chapter 9 ■ Mastering Cryptograph
- Page 282 and 283: Chapter 9 ■ Mastering Cryptograph
- Page 284 and 285: Chapter 9 ■ Mastering Cryptograph
- Page 286 and 287: Chapter 9 ■ Mastering Cryptograph
- Page 288 and 289: Chapter 9 ■ Mastering Cryptograph
- Page 290 and 291: IndexSYMBOLS\ (backslash), 10- oper
- Page 292 and 293: Index ■ D-D 279CIA Triad, 35-36ci
- Page 294 and 295: Index ■ I-M 281hashlib module, 28