What are the vulnerabilities of XOR in the following scenario? What are the security vulnerabilities of the XOR operator in the following scenario:


The Key, The Cyphertext and the Plaintext are the same size in bits.
The Key is only used once and it's secret
The Plaintext is only used once and it's secret
Hence the Cyphertext is only used once, but it's public
Only the Cyphertext, and hence the size of the key is known to the adversary


However:


The Key was generated by a pseudorandom number generator
The Plaintext (which is a private key to something else) was also generated by a pseudorandom number generator


Therefore neither the key nor the plaintext is fully random, vulnerable to frequency attacks.







So I don't care about practical issues, like the difficulty of key sharing. I only care about security issues.

We can identify that this setup can be vulnerable to frequency analysis and such described here:


https://stackoverflow.com/a/1135204





But are there other vulnerabilities besides the pseudo-random nature of the key and the plaintext?
If both the key and the plaintext were truly random, would this provide perfect secrecy?
What you basically have is a binary additive stream cipher, using your pseudorandom number generator as the keystream generator.  Used properly (i.e. in such a way that the same keystream is never used twice), the security of such a cipher depends entirely on the strength of the pseudorandom number generator.

If the output of the generator cannot be practically distinguished from a stream of truly random bits without knowing the seed of the generator, and if the seed itself is chosen randomly from a large enough space to make brute force testing of all possible seeds impractical, then such a cipher is indeed secure (in the sense of protecting the confidentiality of the plaintext; note that such XOR-based ciphers are generally malleable, and thus vulnerable to active tampering attacks).

Unfortunately, most pseudorandom number generators are not designed to remain indistinguishable from random even to a deliberate attacker; a typical PRNG's output only looks random to a casual observer, but can be easily distinguished from random if you know how the generator works.  Algorithms that are designed to resist such distinguishing attempts are generally described as CSPRNGs, or simply as stream ciphers.

If the keystream were truly random, then what you have would be a one-time pad, and would therefore indeed provide perfect secrecy (but still be malleable).  The randomness of the plaintext does not matter here &mdash; the whole point of perfect secrecy (and its computational variant, semantic security) is that a cipher with perfect secrecy will reveal no information about the plaintext whatsoever (except for its length), no matter what the plaintext may be or how it's chosen.

That said, if you intend to use the plaintext as the key to another cipher, then it certainly should be generated in such a way as to make it impractical to guess (even using massive amounts of computing power to test possible guesses).  Otherwise an attacker could just ignore your XOR stream cipher / one-time pad entirely, and simply try to guess the key to the other cipher directly.