コード例 #1
0
current_sample += j
C_0_1, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 2, C_0_0,
                            threshold)
current_sample += j
C_0_2, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 1, C_0_1,
                            threshold)
current_sample += j
C_0_3, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 0, C_0_2,
                            threshold)
current_sample += j
C_0 = helper.byte_to_int(C_0_3, C_0_2, C_0_1, C_0_0)
if (silent != 1): print "C_0=", hex(C_0)
end_time = time.time()

[secretSeed, secretIv, secretDelta,
 secretT1] = helper.load_secret_data(sys.argv[2])

attack_success = helper.compareBytes(secretIv,
                                     [A_0, B_0, C_0, D_0, E_0, F_0, G_0, H_0])
if (silent != 1):
    print "#####################"
    print "A_0=", hex(A_0)
    print "B_0=", hex(B_0)
    print "C_0=", hex(C_0)
    print "D_0=", hex(D_0)
    print "E_0=", hex(E_0)
    print "F_0=", hex(F_0)
    print "G_0=", hex(G_0)
    print "H_0=", hex(H_0)

    print "iv=", secretIv
コード例 #2
0
 * E_2 = D_1 +T1_2
'''
if(silent != 1): print 'DPA9: Recovering C_0=D_1 from E_2 = D_1 +T1_2...'
C_0_0, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 3, -1, threshold)
current_sample += j
C_0_1, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 2, C_0_0, threshold)
current_sample += j
C_0_2, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 1, C_0_1, threshold)
current_sample += j
C_0_3, j = dpa.dpa_addition(T[:, current_sample:], 0, T1_1, 0, C_0_2, threshold)
current_sample += j
C_0 = helper.byte_to_int(C_0_3, C_0_2, C_0_1, C_0_0)
if(silent != 1): print "C_0=", hex(C_0)
end_time = time.time()

[secretSeed, secretIv , secretDelta, secretT1] = helper.load_secret_data(sys.argv[2])


attack_success = helper.compareBytes(secretIv, [A_0, B_0, C_0, D_0, E_0, F_0, G_0, H_0])
if(silent != 1):
    print "#####################"
    print "A_0=", hex(A_0)
    print "B_0=", hex(B_0)
    print "C_0=", hex(C_0)
    print "D_0=", hex(D_0)
    print "E_0=", hex(E_0)
    print "F_0=", hex(F_0)
    print "G_0=", hex(G_0)
    print "H_0=", hex(H_0)

    print "iv=", secretIv