Today, I didn't really touch the Cryptopals code, but I did make plans. I'll quote them here in the hopes that they illuminate why I always end up putting special effort in challenge 11.
Ingredients for random encryption: short prefix short suffix key cbc or ecb if cbc, iv
Usage: The library must define an ecb detection oracle (posit: cannot conclude cbc if ecb not detected, could be other obfuscation) oracle takes a Callable[[bytes], bytes], returns True if ECB, False otherwise
Construct the encryptor thus:
prefix: bytes (len in [5, 10]) suffix: bytes (len in [5, 10]) key: bytes (len = 16) iv: Optional[bytes] (len = 16)
Constructing the plaintext stream requires a Chain SizedIterable
Can create a single class that bundles up all relevant data and assembles them when called, with minor polymorphism
Rationale for determinism: I believe that the spirit of the challenge is in unpredictability and lack of influence, not the application of randomness at specific junctures per se. If I write tests in terms of a range of input parameters, then it's still the case that the oracle must make judgments about code that it can only control the behavior of so far as feeding it input text.
If it does in fact become necessary to generate random ciphertext, then I can write a trivial wrapper around this class.
As we can see, I'm trying to not follow the letter of the challenge, because that would involve writing automated tests that explicitly inject randomness, and honestly random tests that are implicitly random are bad enough. I may look into an idea I had quite some time ago for some other code, to write tests as hypothesis tests that default to pre-specified deterministic behavior, but have the option to run a broader set of strategies. It would be a little awkward, but I think the best way to handle that would be to opt into it by setting an environment variable to a truthy value and just bomb out of the "full hypothesis" session if it's falsy.
Good plan. I'll see about getting to at least some of it by the weekend. For now, I'd like to give myself a bit more time to wind down.