Chapter 15

Further foundations: ciphers, analysis, files, parsing, and probability

This chapter gathers further foundations that entries elsewhere in the book rely on, in cryptography, program analysis, file handling, parsing and probability. Its cryptography entries explain pseudorandom functions §15.1 and permutations, block ciphers §15.3 and the round structure of AES (the Advanced Encryption Standard), the counter and cipher block chaining §15.6 modes of operation, CMAC §15.7 (cipher-based message authentication code), the Merkle–Damgård construction §15.8 of a hash function from a compression function, and password hashing §15.10 with memory-hard key derivation. Its program-analysis entries extend the analysis chapter with reduced products §15.11 and relational abstract domains §15.12, counterexample-guided abstraction refinement §15.13, interprocedural summaries §15.14 and bit-vector logic §15.15.

The next entries cover details that robust tools must get right when they build software and handle files and data: conditional compilation §15.16 and build fingerprints §15.17; archive extraction that escapes its target directory; Unicode normalization §15.19; duplicate keys in JSON §12.26 (JavaScript Object Notation); the difference between a file descriptor §15.21 and a path name; making a file and its directory entry durable with fsync §15.22; opening files without following symbolic links §13.10; the reuse of inode numbers, by which a file system identifies files; and the Python §12.23 modules for exact fractions, decimal arithmetic, heaps, signals, file status, archives, XML (Extensible Markup Language), compression and JSON schemas. A group on input semantics separates the integrity §1.9 of content from the authority to supply it and covers algorithmic-complexity attacks §15.35, event epochs and sequence numbers, thresholds and sentinel values, and prefix-free encodings §15.38. The chapter ends with the mathematics behind many arguments in the book: Boolean algebra §15.39 and De Morgan’s laws, set inclusion §15.40 as an order on policies, the difference between a probability distribution and the set of possible executions, the union bound §15.42, conditional probability §15.43, correlation and covariance §15.44, the central limit theorem §15.45 and the law of large numbers §15.46.

In this chapter

  1. 15.1 Pseudorandom function (PRF)
  2. 15.2 Pseudorandom permutation (PRP)
  3. 15.3 Block cipher
  4. 15.4 AES round structure
  5. 15.5 Counter mode (CTR)
  6. 15.6 Cipher block chaining (CBC)
  7. 15.7 Cipher-based MAC (CMAC)
  8. 15.8 Merkle–Damgård construction
  9. 15.9 Hash compression function
  10. 15.10 Password hashing and memory-hard KDF
  11. 15.11 Reduced product abstract domain
  12. 15.12 Relational abstract domain
  13. 15.13 Counterexample-guided abstraction refinement (CEGAR)
  14. 15.14 Interprocedural summary
  15. 15.15 Bit-vector logic
  16. 15.16 Conditional compilation
  17. 15.17 Build fingerprint
  18. 15.18 Archive path traversal
  19. 15.19 Unicode normalization
  20. 15.20 Duplicate JSON key
  21. 15.21 File descriptor versus pathname
  22. 15.22 fsync and directory durability
  23. 15.23 O_NOFOLLOW and descriptor-relative access
  24. 15.24 Inode reuse
  25. 15.25 fractions module
  26. 15.26 decimal module
  27. 15.27 heapq module
  28. 15.28 signal module
  29. 15.29 stat module
  30. 15.30 tarfile module
  31. 15.31 XML parsing
  32. 15.32 zlib module
  33. 15.33 jsonschema and referencing
  34. 15.34 Content integrity versus input authority
  35. 15.35 Algorithmic complexity attack
  36. 15.36 Event epoch and sequence identity
  37. 15.37 Threshold and sentinel semantics
  38. 15.38 Prefix-free encoding
  39. 15.39 Boolean algebra and De Morgan laws
  40. 15.40 Set inclusion and policy order
  41. 15.41 Probability distribution versus execution set
  42. 15.42 Union bound
  43. 15.43 Conditional probability
  44. 15.44 Correlation and covariance
  45. 15.45 Central limit theorem
  46. 15.46 Law of large numbers