Hide

Problem C
M2: Ground Station

This is the $3$rd of $4$ steps in the Rover problem. The complete problem specification is on the NSA Cyber Challenge website.

Encoding

The first seven lines of the input and every output line contains binary data encoded as a string using the “hexlify” method (named for the way Python implements it in the binascii module). The binary $32$-bit unsigned integer represented in hexadecimal as 0xDEADBEEF would simply be converted into an ASCII string “deadbeef” (always use lower-case letters). The most significant bytes come first.

Input

The first lines of the input will be the parameters to use for the rest of the input. The first line will contain the device ID (a single byte). The second line will contain the the key. The keys are $32$ bytes so they will be represented by $64$ characters. The third line is the Initialization Vector ($16$ bytes). The fourth line is the B1 Nonce ($13$ bytes). The fifth line is the B2 Nonce ($15$ bytes). The sixth line is the A0 Nonce ($14$ bytes). The seventh line is the initial value for the counter ($2$ bytes).

After reading those initial parameters, the subsequent lines will contain a single string command. Valid commands are “stop”, “north”, “east”, “south”, “west”. Read these commands until reading the word “end” on a line by itself.

Output

For command received, output the full command packet including the sync byte, the device ID, the data length, the encrypted command byte, and the $4$ bytes of the tag.

Sample Input 1 Sample Output 1
65
1042e7e22dc64b089be48c2b9f31e8ac68b153d5a13843b3b490613efb8e81dc
095f272c79d7f9ac3b02b4ba9a70ab00
00040100000000000000000000
000000000000000000000000000000
01008d493b30ae8b3c9696766cfa
2c43
stop
north
west
north
stop
east
north
end
fd01652c43c9c76fd885
fd01652c45ef61ff2eb4
fd01652c4720cae56e04
fd01652c494f0ef4b9f0
fd01652c4bbabaab02f3
fd01652c4da85aa99be6
fd01652c4f7b8dcd3688

Please log in to submit a solution to this problem

Log in