# How is a ciphertext encrypted using random numbers decrypted using a symmetric key algorithm

We use true random number generators as a source of keys for encryption. What I can not wrap my head around is: How is this cipher text decrypted in case of symmetric key algorithm as we need the same random number to decrypt the cipher text.

What I could guess is:

• Is this random number used as a session key and transmitted using any asymmetric key algorithm?

• Are PRNGs and true random number generators used as a seed?

• Your second idea will raise the same problem : If you need to use a true random number as a seed to generate the key, you will need the same seed when you try to decrypt the message. The key is usually exchanged using asymmetric key algorithm (RSA key exchange, or (EC)DHE). – Faulst Aug 27 '18 at 7:14

Usually the symmetric key is exchanged with Public-key cryptography (which is asymmetric).

Quote from Wikipedia:

Because of the computational complexity of asymmetric encryption, it is usually used only for small blocks of data, typically the transfer of a symmetric encryption key (e.g. a session key). This symmetric key is then used to encrypt the rest of the potentially long message sequence. The symmetric encryption/decryption is based on simpler algorithms and is much faster.

Concerning random-number-generators in cryptography:

Cryptographically secure pseudorandom number generators are typically used when the design of a cryptographic scheme needs a random number. These include i.e:

As you have guessed any Probabilistic Encryption scheme (i.e. one which produces a randomized ciphertext output) requires that you transmit the seed for that randomness with the message. This value is called an Initialization Vector (IV) or a nonce and the combination of the Key and the IV/nonce is required to decrypt the message.

An picture of how this works for a block cipher in cipher block chaining (CBC) is depicted in the diagram: The $\bigoplus$ symbol represents the XOR operation. From this diagram it should be fairly obvious that choosing a different random IV (and XORing it with the input) would result in very different ciphertext values.

Let's assume I am sending you a message and we have already shared a key. I would generate a random IV value and encrypt the message with that key/IV pair. I would transmit the IV and the ciphertext to you and then you would use the pre-shared key and the message-specific IV to decrypt the ciphertext.

The requirements on IV/nonce input vary depending on the encryption mode and cipher. In general IVs should be secure random values and nonces need only be unique (so a counter works as long as you don't repeat the same nonce for the same key).

Note that while the example above illustrates a block cipher, a probabilistic stream cipher will use similarly a IV/nonce along with a key. The IV would permute the initial state of the stream such that each encryption is unique.