Issues while trying to solve Octave problems

37 Views Asked by At

I'm currently facing issues to solve this problem using Octave.

The problem is divided in 2 parts.

The first part (that I already solved) :

Bob sends to you KB = 123283019.
Copy value KB to your Octave Command Window and compute the common secret key KAB=K.
Create a message d consisting of your date of birth in the decimal format YYYYMMDD, i.e.M=YYYYMMDD. 
Transform K and d to binary format using function >> dec2bin() thus obtaining binary variables 
db and Kb.
Encrypt db using Vernam cipher with agreed secret key KAB=K obtaining ciphertext c1b in binary format using function
>> c1b=binaryxor().
Transform c1b to decimal format obtaining c1 using function
>> c1=bin2dec(c1b)
Send ciphertext [c1] to the Bob.

I founded c1 = 108430000.

The issue I'm currently facing is located in the second problem :

Bob encrypts sum of money n he intends to spend as a gift to you in your birthday by computing the same agreed secret key KBA=K and using the same Vernam cipher. 
The gift itself he keeps secret. 
He sends this ciphertext c2=129650693 in decimal format to you.
Decrypt c2 and find the sum of money.
Is Bob's behaviour correct from the cryptographic point of view?
Please think over what information can be computed by adversary, intercepting two ciphertexts 
c1 and c2 between Alice and Bob.
Since your know that it is not secure to use the same key in Vernam cipher (which is also called one-time pad) to encrypt two messages, lets decrypt c2 and obtain sum n. 
Send this sum in cleartext to the Bob and warn him to avoid such mistakes in the future.

The first time I read it I instantly understood that it was the exact same problem but in reverse. The thing is that I don't found a correct value.

This is what I tried :

  1. Copy the ciphertext c2 provided by Bob: c2 = 129650693;

  2. Transform K to binary format using the dec2bin() function: Kb = dec2bin(K);

  3. Transform c2 to binary format using the dec2bin() function: c2b = dec2bin(c2);

  4. Decrypt c2b using the Vernam cipher with the secret key K: n_binary = binaryxor(c2b, Kb);

  5. Transform the decrypted binary value 'n_binary' to decimal format using the bin2dec() function to obtain the sum of money (n): n = bin2dec(n_binary);

and n = 1.4907e+07 every time... But ofc this decimal number is way too big for the problem (money offered by Bob)

If someone know how to solve this issue, I would be so greatful, thanks in advance.

0

There are 0 best solutions below