Implement TRNG attack
This commit is contained in:
parent
d94acaa277
commit
e5c5959908
2 changed files with 11 additions and 3 deletions
|
@ -177,6 +177,14 @@
|
|||
"args": [],
|
||||
"cwd": "${workspaceFolder:AES Intrinsic}",
|
||||
"preLaunchTask": "Build AES Intrinsic Project"
|
||||
},
|
||||
{
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"name": "Run TRNG Attack",
|
||||
"program": "${workspaceFolder:TRNG Attack}/attack_student.py",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder:TRNG Attack}"
|
||||
}
|
||||
],
|
||||
"compounds": []
|
||||
|
|
|
@ -14,14 +14,14 @@ if __name__ == '__main__':
|
|||
traces = np.reshape(traces, (traces.size//tracelen, tracelen)) # reshape of matrix, each row contains the trace for one RO
|
||||
|
||||
traces_bin = traces > 128 # conversion of waveforms to rectangles - everything below threshold is 0, otherwise 1 (they are boolean values actually)
|
||||
rising_edges = np.logical_not(traces[:,0:-2] & traces[:,1:-1]) & traces[:,2:] # finding rising edges, each rising edge is represented by True
|
||||
rising_edges = np.logical_not(traces_bin[:,0:-2]) & np.logical_not(traces_bin[:,1:-1]) & traces_bin[:,2:] # finding rising edges, each rising edge is represented by True
|
||||
|
||||
cnt = np.count_nonzero(rising_edges, axis=1) # count the number of rising edges in rows
|
||||
# cnt is now a 1D vector
|
||||
cnt = cnt.reshape(TRNG_PAIR_CNT,2).min(axis=1) # Reshape of the count array into matrix, where each row contains 2 values - the number of rising edges for two ROs in a pair. Then we select the smaller value.
|
||||
|
||||
#cnt_sel = cnt & ?x???? # select only the two least significant bits
|
||||
cnt_sel = cnt & 0x03 # select only the two least significant bits
|
||||
|
||||
#estimate = ''.join([np.binary_repr(x, width=2) for x in cnt_sel]) # binary representation of the values (the last 2 bits) and joining them into one string
|
||||
estimate = ''.join([np.binary_repr(x, width=2) for x in cnt_sel]) # binary representation of the values (the last 2 bits) and joining them into one string
|
||||
print('{0:0>32x}'.format(int(estimate, 2)))
|
||||
print(trng_val) # from data_info, output of the RNG in FPGA
|
||||
|
|
Loading…
Reference in a new issue