My crypto course proposes the following padding schemes:

  1. $\operatorname{pad}(m) = m \mathbin\| 0^i$

  2. $\operatorname{pad}(m) = m \mathbin\| 10^i$

  3. $\operatorname{pad}(m) = m \mathbin\| 0^i \mathbin\| E(\left|m\right|)_l$

  4. $\operatorname{pad}(m) = E(\left|m\right|)_l \mathbin\| m \mathbin\| 0^i$

where $E(\left|m\right|)_l$ is the $l$-bit encoding of the length of $m$ and $l$ is the size of the block in the scheme. The question is:

  1. How can one reverse each padding?

  2. Which padding is more space efficient?

I'm at risk of overthinking these questions. Thus, I ask for your experience. To me, the first the more space efficient but not always applicable. It can only be reverted under certain assumptions. But these assumptions hold for 3 and 4 also, if I'm not mistaken. For 2, I don't see very well the advantage. It may help sometimes but others (say 1 has to be written in the next block) it may force to introduce another block. So, overcomplicating matters one could do an average analysis of cases.

What are, in your opinion, the correct answers to these questions?

  • $\begingroup$ hints: 1) m=0 2) search for padding in wiki 3) think again 4) see 3. $\endgroup$
    – kelalaka
    Commented Nov 11, 2018 at 22:44

1 Answer 1

  1. The more space efficient but cannot always be reverted, for instance if one inputs $m = 1$.

  2. The second space efficient but can always be reverted, this appears in Wikipedia entry as bit padding.

  3. and 4. They consume the same space (which is greater than 1. and 2.) but also, they're always reversable.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.