I am interested in the implications of using AES-CBC in a streaming configuration.
Reading the specifications of a few protocols I notice that when using AES-CBC they include IV + ciphertext + HMAC in every frame of data sent.
If a stream of data is being sent would it be safe to instead send an IV initially, but then simply continue using the existing CBC context for the data sent later in the stream?
For example:
context = createAESCBC(mySecretKey, myUniqueIV)
cipherText1 = context.encrypt(pkcs.pad("hello world!"))
// write cipherText1 and HMAC to socket
cipherText2 = context.encrypt(pkcs.pad("foo bar"))
// write cipherText2 and HMAC to socket
instead of:
perFrameIV = generateIV()
context = createAESCBC(mySecretKey, perFrameIV)
cipherText1 = context.finalize(pkcs.pad("hello world!"))
// write perFrameIV and cipherText1 and MAC to socket
perFrameIV = generateIV()
context = createAESCBC(mySecretKey, perFrameIV)
cipherText2 = context.finalize(pkcs.pad("foo bar"))
// write perFrameIV and cipherText2 and MAC to socket
I am aware of AES-CTR, and AES-GCM. I am interested specificially in CBC.
createAESCBC
is likeEVP_EncryptInit_ex
. Andencrypt
is likeEVP_EncryptUpdate
such that callingencrypt
twice for "hello world" does NOT create equivalent cipher text. Do you mean to say that this is still broken with that in mind? – Uzoma Aug 05 '19 at 03:30