Timing attacks are common software attacks. The basic idea is to analyze the software processing time changes caused by changes in input data values, so as to reverse push valid data.
BCTC's current security test also includes the Timing attack on the PIN code. Although PIN does not have a sample effect due to the number of retries, it is indeed a hidden danger from the security perspective.
PIN processing is the process of comparing data with standard values. The common comparison method is as follows:
BOOL ArrayCompare (U08 * src, U08 * dst, 2010length) {2010i; for (I = 0; I <length; I ++) {if (src [I]! = Dst [I]) {returnFALSE ;}} returnTRUE ;}
We can see that in this comparison method, the exit cycle time varies with the input data, in theory, a large number of samples can be used to analyze all PIN Data Based on Time Difference. To avoid Timing attacks, it is necessary to modify the comparison method as follows:
BOOL ArrayCompare (U08 * src, U08 * dst, 2010length) {2010i; BOOL res; res = TRUE; for (I = 0; I <length; I ++) {res & = (src [I] = dst [I]);} returnres ;}
After the following modification, the command cycle is not affected by the input data value, avoiding Timing attacks.