## ← Padding Solution - Applied Cryptography

• 2 Followers
• 25 Lines

### Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=WJYefbuUr8A" data-team="udacity"></div> ``` 1 Language

Showing Revision 2 created 05/25/2016 by Udacity Robot.

1. The answer is, the only reasonable choice is the third one.
2. The reason for that is, either of the first 2 make it very easy for Alice to cheat.
3. For the first choice, we're only looking at the first bit out of the encryption,
4. so if she tries a few different keys, she is likely to find ones that produce outputs
5. that differ in the first bit. Very easy to find one with this property.
6. For the second one, it's not easy to find exactly this property.
7. Finding this equality would be just as hard as it is with the third property,
8. but the problem is Bob does not know the 127 bits that are added.
9. So Bob is only looking at the first character here
10. and finding 2 keys that have this property would be very easy.
11. So in this case, the only 1 that makes sense is this one.
12. When we're thinking about encrypting files and other things,
13. this isn't quite the right answer for padding in most cases.
14. This solution only works when Bob knows the actual size of the input
15. and agrees with Alice in advance to know that all padded bits should be 0's.
16. When you don't know the size, this doesn't quite work because if the message ends
17. with 0 bits, and we start the padding with 0 bits, we don't know where the actual end was.
18. So the usual solution to this, and there are several possible solutions,
19. is to start the padding with a 1 bit and then all 0's to the end of the message.
20. That means if the message actually ended here, if this was the end of the block,
21. if the message was an even number of blocks,
22. we'd need an extra block of just padding to indicate that we got to the end.
23. In this case, since Alice and Bob both know that there's only 1 bit for the coin toss,
24. as long as they agree in advance that the padding will be all 0 bits,
25. that would be okay.