# Simple XOR cipher with pseudo random plain text of arbitrary length

We all know that simple repeated XOR cipher over plaintext is trivially vulnerable to known plaintext attack, even when just a part of plain text is known and even to ciphertext only attack if you know the underlying message structure. But what if the plaintext is random/pseudo random. My reasoning is it should be secure against cipher-text only attack in this case(only confidentiality with indistinguishably, authentication is assumed for now), because if it was insecure this way, CTR mode would not be IND-CPA (which it is thought to be). Because, IF YOU REVERSE THE ROLES BETWEEN KEY AND THE PLAINTEXT,which we can do because it is just XOR and Plain-Text is pseudo-random, one can just send two plain texts with repeated blocks as challenge plain text. If anything about the key (or the plain text) could be revealed that way, the adversary could distinguish which plaintext it was (or equivalently with key in xor cipher) from challenge cipher text of CTR as well.

EDIT:

Further clarification: My reasoning is that if repeating XOR cipher for random plaintext is insecure, then key distribution by encrypting it with any stream/streaming mode ciphers (see my last sentence) should be insecure as well, thus I am just trying to be sure I am not missing anything.I am sharing a key k over some parties securely. Using a key derived using ECIES, each party will have derived keystream $$s_1,s_2...s_n$$. So, GCM mode ciphertext for each node will be $$k⊕s_n||[authtag]$$. Ignoring tag, what an attacker sees is same as if $$s_1||s_2||s_3...$$ encrypted with $$k$$ using repeated xor. But it is also same if you encrypt $$m||m||...m$$ in GCM mode which internally uses CTR so I only mentioned CTR because I am not interested in authentication. So, it should be safe to share keys like this IMO. Of course there are other options for key sharing like I mentioned earlier but asking it

• What is your question? If your plaintext is fully random it has no intrinsic meaning. Key reuse for OTP is never a good idea; use a stream cipher. – Maarten Bodewes Apr 21 at 7:28
• @MaartenBodewes I am not trying to reuse the key. My reasoning is that if repeating xor cipher for random plaintext is insecure, then key distribution by encrypting it with any stream/streaming mode ciphers (see my last sentence) should be insecure as well, thus I am just trying to be sure I am not missing anything. I am sharing a key $k$ over some nodes. Using a key derived using ECIES, each node will have derived keystream $s_1$,$s_2$...$s_n$. So, GCM mode ciphertext for each node will be $k ⊕ s_n || [authtag]$. Ignoring tag, what an attacker sees is same as if $s_1||s_2||s_3$ is.... – Manish Adhikari Apr 21 at 7:59
• ...@MaartenBodewes encrypted with $k$ using repeated xor. But it is also same if you encrypt $m||m||...m$ in gcm mode. So, it should be safe to share keys like this IMO. – Manish Adhikari Apr 21 at 8:03
• The problem is that your post doesn't contain a concise question. Furthermore it asks for evaluation of a protocol / scheme. Both are considered reasons for closing the question on this site. If you have a specific question please edit it into your post. – Maarten Bodewes Apr 21 at 8:04
• @MaartenBodewes EDITED – Manish Adhikari Apr 21 at 8:08