IndexSYMBOLS\ (backslash), 10- operator, 12/ operator, 12// operator, 12//= (floor division) assignment operator, 14_ (binary One Complement) bitwiseoperator, 15, 52| (binary OR) bitwise operator, 15, 52+ operator, 11, 12+= (add AND) assignment operator, 14+K A (notation in cryptographic protocols), 37/= (divide AND) assignment operator, 14= (subtract AND) assignment operator, 14= assignment operator, 14!= comparison operator, 13== comparison operator, 13% operator, 12%= (modulus AND) assignment operator, 14& (binary AND) bitwise operator, 15, 52* operator, 12** operator, 12**= (exponent AND) assignment operator, 14*= (multiply AND) assignment operator, 14^ (binary XOR) bitwise operator, 15, 52< comparison operator, 13<< (binary Left Shift) bitwise operator, 15, 52<= comparison operator, 13<>= comparison operator, 13> comparison operator, 13>= comparison operator, 13>> (binary Right Shift) bitwise operator, 15,52AA (notation in cryptographic protocols), 37A → B: m (notation in cryptographicprotocols), 37A[m] (notation in cryptographic protocols),37a+ file operator, 19addition + operator, 12Adleman, Leonard (researcher), 34, 226AES (Advanced Encryption Standard), 36,156, 167, 180–187AES-GCM, 261Affine cipher, 90–93algorithmsARX algorithms, 149asymmetric algorithms, 36DEC algorithm, 2deterministic algorithm, 101ENC algorithm, 2exploring, 2GEN algorithm, 2Mersenne Twister algorithm, 116published and proprietary encryption,61–62RSA algorithm, 104, 226–235, 242Secure Hash Algorithms (SHAs), 203–204,205, 209symmetric algorithms, 36Alice and Bob, as most famouscryptographic couple, 33–34analytical attacks, 48AND, 50–55and (logical AND), 14Implementing Cryptography Using Python®, First Edition. Shannon W. Bray.© 2020 John Wiley & Sons, Inc. Published 2020 by John Wiley & Sons, Inc.277
278 Index ■ B–CAppend file operator, 19arbiter, 35arbitrated authentication, 35–36ARC4 (ARCFOUR), 147–148arithmetic operators, 11–13Artjuhov, M. M., 100ARX algorithms, 149ASCII encoding, 70assignment operator, 10, 14associativity (as group axiom), 106asymmetric algorithms, 36Atbash cipher, 77attack models, 49–50attacksanalytical attacks, 48birthday attack, 59, 207–209brute-force attacks, 47–48length extension attack, 209–210reflection attack, 211reordering attack, 211replay attack, 211side-channel attacks, 48social engineering, 48Authenticate Then Decrypt, 211authenticationarbitrated authentication, 35data origin authentication, 34–35direct authentication, 35entity authentication, 35–36inter-realm authentication, 40message authentication codes, 60Bbackslash (\), 10Base64 encoding text, 70bcrypt library, 69Bernstein, Daniel, 149bin() function, 52binary data, 71binary digests, 204–205binascii library, 140birthday attack, 59, 207–209bitwise operators, 15, 52blind signatures, 33block cipher mode, 158block ciphersAES (Advanced Encryption Standard), 36,156, 167block modes of operation, 158CBC mode (formerly Cipher BlockChaining), 159–160CFB mode (Cipher Feedback mode),160–162CTR mode (Integer Counter mode orSegmented Integer Counter mode),162–164DIY block cipher using Feistel networks,165–166ECB mode (formerly Electronic Codebook),158–159OFB mode (Output Feedback mode),162–163overview, 156–158tricks with stream modes, 164–165block modes of operation, 180–187Blowfish, 36Bob and Alice, as most famouscryptographic couple, 33–34Boolean test, 16break loop, 18brute-force attacks, 47–48buffer sequence type, 20, 21Bundle, Pip as similar to, 5CCA- A (notation in cryptographic protocols),37CA<<A>> (notation in cryptographicprotocols), 37Caesar cipher, 74–76CBC mode (formerly Cipher BlockChaining), 159–160, 180, 185–186CBC-MAC (cipher block chaining messageauthentication code), 206–207CCA (Chosen-Ciphertext), 50Cert -CK CA( +K A ) (notation in cryptographicprotocols), 37certificate, self-signed, 45–46certificate authorities (CAs), 42certificate chains, 42–44certificate hierarchy, 42–44certificate revocation, 44–45CFB mode (Cipher Feedback mode),160–162ChaCha cipher, 151–156ChaCha20 stream cipher, 145channelsadding symmetric encryption, 215–218communication channels, 211concatenate message and MAC, 218–221creating client socket, 213–214creating server socket, 212–213creating threaded server with TCP, 214–215sending secure messages over IP networks,212–221setting up secure one, 210–221chmod command, 3Choctaw Indian language, as historicalcipher, 73Chosen-Ciphertext (CCA), 50Chosen-Plaintext (CPA), 50Chromebook, installing Python on, 4–5
- 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 292 and 293: Index ■ D-D 279CIA Triad, 35-36ci
- Page 294 and 295: Index ■ I-M 281hashlib module, 28
- Page 296 and 297: Index ■ Q-S 283Preneel, Bart, 145