Index ■ I–M 281hashlib module, 28–29Header + Data Units (HDUs), 195Hellman, Martin, 162, 224helper filecreating one for constructing plaintextcommunications application, 251–252modifying of for implementing PKI inapplication using RSA certificates,258–259modifying of in implementing Diffie-Hellman key exchange, 266–270hexdigest, conversion to plaintext, 140–141hexdigest() method, 204hexlify module, 140hidden secret, for incorporating messagehashing, 201Hill 2x2, 83–87H(m) (notation in cryptographic protocols),37IIDEA, 36identity (as group axiom), 106identity operators, 16IF statement, 16image cryptographyAES and block modes of operation, 180–187applying examples, 186exploring simple CBC mode example,185–186exploring simple ECB mode example,181–185file cryptography using Fernet, 175–179overview, 175–176steganography, 187–197using Fernet, 179–180imagescryptography libraries, 174–175image cryptography, 175–187simple image cryptography, 171–174storing binary file inside, 192–194storing message inside, 188–191using cryptography with, 171–197working with large ones, 195–197immutable, 24import command, 28import math call, 28in membership operator, 15indentation, misuse of, 10index() method, 25indicesnegative index, 22positive index, 22infinite one-time pad, 164infrastructure, 255–256installingadditional packages, 5–8Chryptography package, 7–8IPython, 8Matplotlib, 5–7Pip, 5–7Python, 3–8testing, 9Wireshark, 253–254Integer Counter mode, 162–164integer factorization, 97inter-realm authentication, 40inverse (as group axiom), 106IPython, 8is identity operator, 16is not identity operator, 16is_prime() function, 103K-K A (notation in cryptographic protocols), 37K A,B (notation in cryptographic protocols), 37Kerberos protocol, 36, 39–40Kerckhoffs, Auguste, 61key distribution problem, 223key escrow, 33key exchange, 34key space, use of term, 49Known-Plaintext (KPA), 50Koblitz, Neal, 239Llambda functions, 125length extension attack, 209–210librariesbcrypt library, 69binascii library, 140configuring your first cryptographiclibrary, 47cryptography libraries, 174–175Fernet library, 175linear equations, solving systems of,117–119linear-feedback register (LPSR), 146list() function, 25list sequence type, 20–21, 24, 25logical operators, 13–14loops, use of, 17–19M(m 1, . . . , m n ) (notation in cryptographicprotocols), 37MAC encryption, for incorporating messagehashing, 200macOS, installing Python on, 4
282 Index ■ N–PMatplotlibdescribed, 3, 5installing, 5–7MD5, 203MDC (modification digest code), 34–35membership operators, 15Merkle, Ralph, 224Mersenne Twister algorithm, 116Message Authentication Codes (MACs)birthday attack, 59, 207–209cipher block chaining messageauthentication code (CBC-MAC),206–207crafting forgeries, 209–210hash-based ones, 201–205NIST compliance, 205–206overview, 200–201message digest, 67message hashing, 200message integrityMessage Authentication Codes (MACs),200–210setting up secure channel, 210–221message space, use of term, 49"A method for obtaining digital signaturesand public key cryptosystems" (Rivest,Shamir, and Adleman), 34Meyer, C. H., 159Miller, Gary L., 100Miller, Victor S., 239Miller-Rabin primality test, 100–104minus - operator, 12(m) K (notation in cryptographic protocols), 37modification digest code (MDC), 34–35modular arithmetic, 96–97modular inversesFermat’s little theorem to find inverse, 110–111overview, 109–110modules, defined, 28modulus % operator, 12multiple-domain Kerberos, 40–41multiplication * operator, 12mutable, 24Nnamesas case sensitive in Python, 9examples of, 9numbers as not starting, 9National Institute of Science and Technology(NIST), 205Needham, Roger (protocol inventor), 36Needham-Schroeder protocols, 36–38Network Time Protocol (NTP), 42NIST compliance, 205–206not (logical NOT), 14not in membership operator, 15NPM, Pip as similar to, 5NumPy, 3, 5–7, 117OOFB (output feedback) style, 157OFB mode (Output Feedback mode), 162–163one-time pad (OTP), 51, 141one-time pad (OTP) function, 56–58one-way hashescryptographic one-way hashes, 59–60overview, 58–59online word list, use of, 125–126open method, 27, 28operatorsarithmetic operators, 11–13bitwise operators, 15, 52comparison operators, 13identity operators, 16logical operators, 13–14membership operators, 15relational operators, 13use of, 11–12OR, 50–55or (logical OR), 14OTP (one-time pad), 51, 141OTP (one-time pad) function, 56–58Otway-Rees protocol, 38Output Feedback mode (OFB mode), 162–163output feedback (OFB) style, 157Ppasswordsbest practices for, 66–69hashing of, 67salting of, 67–68storage of, 66stretching of, 68tools for, 68–69PEM (privacy enhanced electronic mail),70–71perfect forward secrecy (PFS), 60–61perfect secrecy, 51, 56perfect security, 50–51Pip, installing, 5–7PKI (public-key infrastructure)described, 223–224implementing of in application using RSAcertificates, 255–261plaintextconstructing plaintext communicationsapplication, 248–253conversion of hexdigest to, 140–141Playfair, 79–82plus + operator, 11, 12preimage resistance, 59
- 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 296 and 297: Index ■ Q-S 283Preneel, Bart, 145