Skip to main content
4 of 12
added 61 characters in body
kelalaka
  • 49.5k
  • 12
  • 118
  • 205

In OTP, one party generates a uniform randomly key, writes it in a roll of paper, or a book, or CD, or USB. They transmit it in person with reliable people to the other side.

The OTP keystream obviously is a long stream to long-time use, i.e. one can encrypt many messages over time without using any bits again.

Let the keystream is represented by $k_i$ and the first message is encrypted be $m$ with length $\ell$. Then the encryption is performed with the first $\ell$ part of the message. The used part is deleted and should never be used again

$$c_i = k_i \oplus m_i , \quad\text{for } 0\leq i < \ell$$ If you want to hide the length upto some degree, see bottom.

One time pad - how is the difference in length between the plain text & the OTP handled?

Two cases we have;

  1. The OTP keystream is shorter: in this case, one should not send reusing the keystream. Otherwise, two(or many)-time pad use occurs and that OTP is no longer informationally secure and can be broken.

  2. THe OTP keystream is longer: That is what we need, a longer keystream so that we can use the distinct part of it to encrypt many messages. Usually, performed sequentially.

Since OTP have to be agreed upon in advance, they may be longer than the plaintext. So in this case, how is the encryption done?

As mentioned above, you the necessary part, delete the used part, and the rest can be used for further encryptions.

Is the OTP truncated to the same length of the plaintext before encrypting or is some kind of padding used - how does it work?

No, there is no need for this. If you really exchanged the key only encrypted for one message, discard the unused part of the keystream. If you want to hide the length too, see below.

I am asking where your sender & receiver have a whole book of one time pads. Each page of the book is supposed to be for a particular day. So each page is a fixed length OTP. In this case, if the plaintext is smaller than the OTP, how is that handled

Left it as it is. You may need to send new messages on the same day again.

As per Boneh, if the ciphertext leaks the length of the plaintext, then it's not perfect secrecy

That is not the standard definition of perfect secrecy you can hide it up to a possible length. In Cryptography, we usually consider the message length is given. You cannot hide it completely. You may send a fixed message up to a fixed-length by padding there the 10..0 padding will be secure.

What will happen if one day you need to send a message is longer than the fixed-length?

  • Divide into parts? That still can leak information like you send two messages immediately and they are related...

  • Change your fixed-length in the next meeting? This will abound on the previous messages, too.

I am talking about the case where Alice & Bob exchange a book of One Time Pads. Each page of the Pad is used for one plaintext encryption. So each page is of a fixed length & is always longer than the plaintext which it encrypts. So how is the difference in length handled?

As mentioned padding and 10..0 padding will be enough.

kelalaka
  • 49.5k
  • 12
  • 118
  • 205