Is it safe to distribute different portions of the same data encrypted with different AES keys? Assume I have a block of data consisting of three segments A, B and C. With "segments" I mean a particular section of a bit stream, so if the whole binary data was simply 00 01 02 ... FF, A might be 00 ... 5C, B could be 5D ... 72 and C would then be 73 ... FF.

K1 and K2 are 128 bit AES keys that were securely exchanged such that Alice has K1 and Bob has K2.


Alice gets data segments ABC encrypted with K1.
Bob gets only data segment B encrypted with K2.


My question is: if Bob got to know Alice's full cipher text for ABC (that was encrypted with K1), what could he deduce from the information he already has? Are there any circumstances under which Bob could decrypt segments A and/or C as well?

This is question is very similar to Vulnerabilities if encrypting the same data with 2 different keys, but not quite; I'm not asking about what Eve can deduce, but Bob.

I'm fairly new to encryption, and it was my understanding that AES is mostly XOR operations. For strict XOR operations, I think if you know any two a, b or c where a ^ b = c, you can calculate the third variable using XOR on the other two, as I think this was how parity bits for RAID systems work.

I keep finding hints as to AES is not just XOR, like How is XOR used for encryption? which in turn links to Why do block ciphers need a non-linear component (like an S-box)?. But I'm not sure I'm understanding the implications of the answers given there.

I think what the answers to those questions say is that for AES, K1 and K2 are just used to continuously generate a pseudo random bit stream, and only that is then XOR'ed with the data. So all Bob could deduce was the pseudo random bit stream section that has been used for Alice's B, but the generator function is such that this doesn't give Bob a clue about K1 or the bits generated earlier for A or later for C.

Is this universally true? Or, as I have seen often mentioned, are there limitations as to how many bits B may have to keep a 128 bit K1, A and C reasonably secret from Bob?
We assume that Bob knows B and Enc(K1, ABC) but doesn't know K1, A or C. Then the only information Bob can learn about ABC is the length of AC (not even the length of A and C individually). If Bob knows Enc(K1, M), Bob can't even tell whether B is a substring of M. This is assuming that Enc is any sensible symmetric cipher, including AES-CBC (with a random IV), AES-CTR (with a initial counter value that doesn't overlap any counter value used for another input with the same key), AES-GCM (with a non-repeated nonce), AES-CCM (with a non-repeated nonce), etc.

AES itself is a permutation on 128-bit blocks, not a way to encrypt a message. involves some xor operations internally, but this is not a xor between the message and something else. There is no simple arithmetic relation involving related inputs and related outputs, otherwise we'd consider it to be completely broken. Given AES_Enc(K, A) and AES_Enc(K, B) where A and B are 128-bit strings, the only thing you can deduce about A and B is whether they're equal or not (A = B if and only if AES_Enc(K, A) = AES_Enc(K, B)).

There are ways to encrypt a message that involve xoring the message with a keystream which is produced using AES as a building block: ciphertext = plaintext ⊕ keystream. AES-CTR is a relatively simple one, where the keystream is built by encrypting successive values. Suppose you have the encryption of two messages with the same key:

ciphertext1 = plaintext1 ⊕ keystream1
ciphertext2 = plaintext2 ⊕ keystream2


keystream1 and keystream2 are indistinguishable from random to someone who doesn't know the key. Therefore ciphertext1 and ciphertext2 are also indistinguishable from random. Any relationship between the plaintexts is completely hidden by this random data, and not visible as a relationship between the ciphertexts.

Badly used modes of operation, for example using a non-random IV, can cause keystream1 and keystream2 to be related in some way. But that's due to badly using the encryption mechanism. The standard mechanisms themselves don't have such weaknesses.

Note that this assumes that Bob doesn't know the key. If Bob knows some part of K1, all bets are off. Never reveal part of a secret key.