-2

Homework question

The full question is the following:

Suppose you are told that the one time pad encryption of the message "attack at dawn" is 09e1c5f70a65ac519458e7e53f36 (the plaintext letters are encoded as 8-bit ASCII and the given ciphertext is written in hex). What would be the one time pad encryption of the message "attack at dusk" under the same OTP key?

To me it seems that all you'd have to do is find what the hexadecimal representation of attack at dusk is, add that to attack at dawn message and then use the key to convert attack at dusk to an encrypted value. However, I don't know how to store the hexadecimal value in C++ (or any language for that matter). This is what I thought you would do: string attackAtDawn = 61747461636b206174206461776e;

Mike
  • 101
  • 2
  • Depending on how the OTP is applied... if `ciphertext(plaintext) = plaintext ^ nonce` then `ciphertext(plaintext2) = plaintext2 ^ nonce = plaintext2 ^ plaintext ^ plaintext ^ nonce = (plaintext2 ^ plaintext) ^ ciphertext(plaintext)` – Ben Voigt Jul 17 '14 at 22:02
  • That's why having true random shared secrets (the one time pad) is no substitute for a good encryption algorithm. – Ben Voigt Jul 17 '14 at 22:04

1 Answers1

1

You're going to want to get a clear picture of what "hexadecimal value" means vs. "hexadecimal string." To me, the "hexadecimal value" is a numeric type where the byte 6f is actually stored on the machine as binary 0110 1111 (which is 6f). In many languages, C++ included, you can achieve this by prepending "0x" to the value:

unsigned int some_hex = 0x6f;

Whereas, mainly for I/O purposes when dealing with human-readable files, you will use a hex string that are ASCII/Unicode values for each digit 0-9 and a-f, which is what your "string AttackAtDawn" is. To the machine, however, the value "6f" is the character encoding for the digit 6 and the letter f, which would need to be converted to a numeric form such as unsigned int in order to perform mathematical operations on the hex value.

Rob
  • 21
  • 1