Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

First off, I'm extremely sorry if this comes off as a "homework dump", but to clarify, it isn't. I don't want the answer, I want to know how to get to the answer. My cryptography professor gave us an assignment to do, and without explaining this concept, he believes we all understand how to do it, and I definitely don't.

The problem is in two parts:

  • The one-time pad encryption of the message attack at dawn is 6c73d5240a948c86981bc294814d (the plaintext letters are encoded as 8-bit ASCII and the given ciphertext is written in hexadecimal) What would be the one time pad encryption of the message attack at dusk under the same OTP key?

  • The one-time pad encryption of the message attack at dusk is 6c73d5240a948c86981bc294814d (the plaintext letters are encoded as 8-bit ASCII and the given ciphertext is written in hexadecimal) What would be the one time pad encryption of the message attack at noon under the same OTP key?

Thanks for any/all help

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

If you know the plaintext and the ciphertext, getting the key is trivial.

$$c=m \oplus k$$

Try moving the terms around. Hint: $m$ and $k$ can be functionally swapped (change position with each other), ie. only one term needs to be secret. You already know one term. I've pretty much given you the answer.


About the decoding procedure: The ASCII table linked by Reid is a good resource. Alternatively you can use an online ASCII to Hex encoder to

  • get the binary representation of the ciphertext
  • get the binary representation of the known plaintext

and then do the prodecure on paper. Once you understand that you can write a Python script to do the job for you.


only one term needs to be secret: That's what I said above and I'll clarify because that statement is not accurate.

You need to know any 2 terms of the equation $x=a \oplus b$. to solve for any other term. That means $a=x \oplus b$ and of course $x= b \oplus a$. Therefore any stream cipher (or OTP) is secure as long as the adversary only knows one term (namely the ciphertext).

share|improve this answer
    
I get that part, I don't understand how to change "6c73d5240a948c86981bc294814d" into "Attack at Dawn" –  Jaken Herman Sep 23 '13 at 23:14
    
@JakenHerman: Try an ASCII table. Alternatively, he could be using the encoding a=1,b=2,c=3,.... –  Reid Sep 23 '13 at 23:17
    
The question states, that it's encoded as 8-bit ascii, so no it cannot be a=1... –  Maeher Sep 23 '13 at 23:20
    
@Maeher: Oops! I didn't see that. Well, then, the ASCII table I linked to is of key importance. :P –  Reid Sep 24 '13 at 0:03
add comment

(The below may be a bit cryptic if you don't know Python.)

The idea is not to decode the message, but to manipulate it. Since your ciphertext is

C = OTPkey ^ "attack at dawn"

all you need to do is to XOR the last 4 bytes of the ciphertext with the original text "dawn" and then again with "dusk", for example:

C ^ "attack at dawn" ^ "attack at dusk" //equals to
OTPkey ^ "attack at dawn" ^ "attack at dawn" ^ "attack at dusk" //equals to
OTPkey ^ "attack at dusk"

Or in Python:

def strxor(s1,s2):
    return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))

strxor(strxor("6c73d5240a948c86981bc294814d".decode('hex'), "attack at dawn"), "attack at dusk").encode('hex')

>>>'6c73d5240a948c86981bc2808548'

Same with the second question.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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