Index ■ D–D 279CIA Triad, 35–36cipher block chaining messageauthentication code (CBC-MAC), 206–207Cipher Block Chaining (now CBC mode),159–160Cipher Feedback mode (CFB), 160–162cipher space, use of term, 49ciphersAffine cipher, 90–93ARC4 (ARCFOUR), 147–148Atbash cipher, 77block ciphers, 156–169Caesar cipher, 74–76ChaCha cipher, 151–156column transposition, 87–90Hill 2x2, 83–87historical ones, 72–93Playfair, 79–82ROT-13, 76Salsa20 cipher, 149–151stream ciphers, 141–156substitution ones, 73–77Vernam cipher, 148–149Vignère cipher, 77–79, 129–137ciphertext (C)C, 2Ciphertext Only (COA), 49classical cryptographydata obfuscation (DO), 69–72historical ciphers, 72–93password best practices, 66–69clientcreating one for constructing plaintextcommunications application, 250–251modifying of for implementing PKI inapplication using RSA certificates, 257client file, modifying of in implementingDiffie-Hellman key exchange, 264–266client socket, creating, 213–214clock synchronization, 42closure (as group axiom), 106Cocks, Clifford (mathematician andcryptographer), 224–226codescommenting on, 10message authentication codes, 60collision resistance, 59column transposition, 87–90comments, on code, 10“Communication Theory and SecrecySystems” (Shannon), 50comparison operators, 13Composer, Pip as similar to, 5concatenate message and MAC, forincorporating message hashing, 200conditionals, use of, 16–17continue loop, 18count() method, 25CPA (Chosen-Plaintext), 50cryptanalysisdefined, 47with Python, 123–137understanding of, 47–49cryptographic family, 33–34cryptographic library, configuring your first,47cryptographic one-way hashes, 59–60cryptographic protocols, 32–33, 46–47. Seealso specific protocolscryptographically secure pseudorandomnumber generator (CSPRNG), 115,141–144, 146cryptographyhistory of, 31, 242origin of term, 32study of, 32–49understanding of, 32–47Cryptography library, 174–175, 189Cryptography package, installing, 7–8Cryptosteganography library, 175cryptosteganography module, 175, 188,189, 192CTR (counter) style, 157CTR mode (Integer Counter mode orSegmented Integer Counter mode),162–164custom functions, 26–27Ddatabinary data, 71obfuscating of, 69–72data obfuscation (DO), 69–72data origin authentication, 34–35De Cannière, Christophe, 145De Vita Caesarum, Divus Iulis ("The Lives ofthe Caesars, the Deified Julius"commonly known as The TwelveCaesars), 74–76DEC algorithm, 2decode() method, 71decoding, 71decryptionAuthenticate Then Decrypt, 211constructing BLOB decryption with RSAcertificates, 232–235constructing simple text decryption withRSA certificates, 231–232of files using AES, 169def keyword, 26DES, 36, 156deterministic algorithm, 101dictionaries, 25–26
280 Index ■ E–HDiffie, Whitfield, 162, 224Diffie-Hellman class file, creating,270–275Diffie-Hellman key exchangeimplementing of, 261–276overview, 242–245purpose of, 34as used by TLS, 33digest() method, 204dir(), 28direct authentication, 35division / operator, 12DO (data obfuscation), 69–72double quote ("), 11downloading and installing, Python, 3–8EECB mode (formerly Electronic Codebook),158–159, 180, 181–185ECC keys, generating, 240–241Ehrsam, W. F., 159Electronic Codebook (now ECB mode),158–159electronic money, 33elements, orders of, 107–109El-Gamal encryption, 235–238elliptic curve cryptography (ECC)generating ECC keys, 240–241key lengths and curves, 241–242overview, 238–240elliptic curves, 238–239Ellis, James, 225else loop, 18–19ENC algorithm, 2encode() methods, 71encoding matrix, 117Encrypt and Authenticate, 210–211Encrypt Then Authenticate, 211encryptionconstructing BLOB encryption with RSAcertificates, 232–235constructing simple text encryption withRSA certificates, 231–232El-Gamal encryption, 235–238MAC encryption, 200–201symmetric encryption, 8, 36, 39, 49, 176,215–218encryption key (K), 2encryption protocols, as another name forcryptographic protocols, 32entity authentication, 35eSTREAM, 145Euler’s theorem, 100, 111–114exponent ** operator, 12extend() method, 24FFA (frequency analysis), 48–49, 120–123FCS (Frame Check Sequence), 58–59Federal Information Processing StandardsPublication (FIPS PUB 180-4), 205Feistel cipher/Feistel network, 165–166Ferguson, Niels, 162Fermat’s little theorem, 100, 110–111Fernetfile cryptography using, 175–179image cryptography using, 179–180Fernet library, 175file operations, 19filesdecryption of using AES, 169downloading using Python, 27–28encryption of using AES, 169use of, 19FIPS PUB 180-4 (Federal InformationProcessing Standards Publication),205Flexible Image Transport System (FITS), 3,195–197floor division// operator, 12for loop, 17forgeries, crafting of, 209–210forward secrecy (FS), 60Frame Check Sequence (FCS), 58–59frequency, determination of, 126–129frequency analysis (FA), 48–49, 120–123functions, custom functions, 26–27GGEN algorithm, 2greatest common divisor (GCD), 96–97,111group axioms, 106group law, 106group theoryorders of elements, 107–109overview, 106–107groups, concept of, 106Hhash code, 67hash function, 58Hash-based Message Authentication Code(HMAC)binary digests, 204–205CBC-MAC, 206–207described, 60message digest with SHA, 203–204overview, 201–202using HMAC to sign message, 202–203
- 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 294 and 295: Index ■ I-M 281hashlib module, 28
- Page 296 and 297: Index ■ Q-S 283Preneel, Bart, 145