Hi, I am trying to modify the provided manual CPA attack example. Apologies if my security knowledge is lacking. This is my first real foray into hands on security attacks!

As a starting point, I simplified the provided example and removed ‘aes_indep_enc(pt)’ in the get_pt function of ‘simpleserial-aes.c’ and replaced it with just the sbox operation, like this:

for(int i=0; i<16; i++){

pt[i] = sbox[(pt[i]^key[i])];

}

The key array is populated in the get_key function before this and I copied the sbox into this file as well.

With this modification the attack still works. But beyond this, any modification I make throws a ‘true_divide’ error in numpy in line ‘cpaoutput[kguess] = sumnum / np.sqrt(sumden1 * sumden2)’.

So what I am really trying to do here is mimic this attack for a multiplication. so based on multiplying the ‘plaintext’ with a ‘key’ can i recover the key in the same way.

But changing the ‘^’ to ‘*’ causes this true divide error even when i still keep the sbox lookup which I wont for my actual attack.

Any suggestions would be appreciated!