Try solving TRNG Attack
This commit is contained in:
parent
da3db1a167
commit
46eb7d2776
|
@ -13,15 +13,15 @@ if __name__ == '__main__':
|
||||||
traces = np.fromfile("data.bin", dtype='uint8') # reading traces for individual ROs
|
traces = np.fromfile("data.bin", dtype='uint8') # reading traces for individual ROs
|
||||||
traces = np.reshape(traces, (traces.size//tracelen, tracelen)) # reshape of matrix, each row contains the trace for one RO
|
traces = np.reshape(traces, (traces.size//tracelen, tracelen)) # reshape of matrix, each row contains the trace for one RO
|
||||||
|
|
||||||
traces_bin = ??? # conversion of waveforms to rectangles - everything below threshold is 0, otherwise 1 (they are boolean values actually)
|
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(???) & ??? # finding rising edges, each rising edge is represented by True
|
rising_edges = np.logical_not(traces[:,0:-2] & traces[:,1:-1]) & traces[:,2:] # finding rising edges, each rising edge is represented by True
|
||||||
|
|
||||||
cnt = np.count_nonzero(???, axis=1) # count the number of rising edges in rows
|
cnt = np.count_nonzero(rising_edges, axis=1) # count the number of rising edges in rows
|
||||||
# cnt is now a 1D vector
|
# 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 = 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 & ?x???? # 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('{0:0>32x}'.format(int(estimate, 2)))
|
||||||
print(trng_val) # from data_info, output of the RNG in FPGA
|
print(trng_val) # from data_info, output of the RNG in FPGA
|
||||||
|
|
Loading…
Reference in a new issue