Skip to content

Commit

Permalink
Add Results on key corr vs no. of sample
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor committed Jun 14, 2021
1 parent 586fbbd commit 25aa43b
Show file tree
Hide file tree
Showing 3 changed files with 25,436 additions and 5 deletions.
Binary file added .CPA.py.swp
Binary file not shown.
9 changes: 4 additions & 5 deletions CPA.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import numpy as np
import os
import scipy.io as spio
import matplotlib.pyplot as plt

#import matplotlib.pyplot as plt

sbox = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
Expand Down Expand Up @@ -156,7 +155,7 @@ def Corr_with_correct_key(pt,traces,master_key, target_byte):


###Experiment2: Do CPA over number of sample
target_byte = 4
target_byte = 5
x_axis_value = []
key_corr_over_trunc_traces_lst = []
for no_trace in range(100,traces.shape[0], 100):
Expand All @@ -169,7 +168,7 @@ def Corr_with_correct_key(pt,traces,master_key, target_byte):
PATH_Results = os.path.join(cwd,"Results")
PATH_Results_specific = os.path.join(PATH_Results,"AES_my_own_2021-06-09_17_51_39")
os.chdir(PATH_Results_specific)
spio.savemat("key_corr_over_trunc_traces_lst.mat", {'key_corr_over_trunc_traces_lst': key_corr_over_trunc_traces_lst}, do_compression=True, oned_as='row')
spio.savemat("key_corr_over_trunc_traces_lst_targer_byte"+ str(target_byte)+".mat", {'key_corr_over_trunc_traces_lst': key_corr_over_trunc_traces_lst}, do_compression=True, oned_as='row')
os.chdir('../..')


Expand All @@ -193,4 +192,4 @@ def Corr_with_correct_key(pt,traces,master_key, target_byte):
# if (master_key[target_byte] != hypothesis_key[target_byte]):
# print("Wrong " + str(target_byte))
# else:
# print("Correct " + str(target_byte))
# print("Correct " + str(target_byte))
Loading

0 comments on commit 25aa43b

Please sign in to comment.