Malleability of stream encryption under a random initial value #
A ciphertext of ivStreamEncrypt is an n-bit initial value followed by the message XORed with
a keystream. XORing a mask delta at least as long as msg into the part after the initial value
(ivStreamXorBody) therefore gives a ciphertext in the support of the encryption of
msg ⊕ delta, whatever the keystream (ivStreamXorBody_mem_support_ivStreamEncrypt). On
whole-block messages, when the keystream from every n-bit initial value has blocks * n bits,
it decrypts to msg ⊕ delta (ivStreamDecrypt_ivStreamXorBody). The transformation needs
neither the key nor the keystream, and it is computable in polynomial time
(computableInPolyTime_ivStreamXorBody).
Boneh and Shoup exploit this malleability against randomized counter mode in Section 9.2.1
([BS23], printed pp. 360–361): "define ĉ to be the same as c except that
ĉ[1] := c[1] ⊕ u ⊕ v", which is the mask (u ⊕ v) ‖ 0. In Section 9.10, Attack 3 (printed
p. 391), they state it as "given the encryption of m, an attacker can create a valid encryption
of m ⊕ Δ for any Δ of his choice." Counter mode (ctrWordEncrypt), output feedback mode
(ofbWordEncrypt) and the one-block cipher prfCipher all encrypt by ivStreamEncrypt. Since
ctrWordEncrypt and ofbWordEncrypt are not exposed, a module client states its hypotheses for
ivStreamEncrypt (ctrWordKeystream family) and ivStreamEncrypt (ofbWordKeystream family). The
randomized CBC half of Section 9.2.1 is not covered.
Main definitions #
Cslib.Crypto.ivStreamXorBody: XOR a mask into a ciphertext after its initial value.
Main results #
Cslib.Crypto.ivStreamXorBody_mem_support_ivStreamEncrypt: the modified ciphertext is an encryption of the masked message, for a mask at least as long as the message.Cslib.Crypto.ivStreamDecrypt_ivStreamXorBody: what the modified ciphertext decrypts to.Cslib.Crypto.computableInPolyTime_ivStreamXorBody: efficiency of the transformation.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 9.2.1 (printed pp. 360–361) and Section 9.10, Attack 3 (printed pp. 390–391).
ivStreamXorBody is computable in polynomial time.
Malleability of stream encryption ([BS23], Section 9.2.1 and Section 9.10,
Attack 3): XORing a mask delta at least as long as msg into an encryption of msg after its
initial value gives an encryption of msg ⊕ delta, for every keystream.
The modified ciphertext of ivStreamXorBody_mem_support_ivStreamEncrypt decrypts to
msg ⊕ delta when msg is a whole number of n-bit blocks and the keystream from every n-bit
initial value has blocks * n bits.