I2C toy code
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

53 rader
2.6 KiB

  1. Tech Note 0002
  2. How to avoid non-intrusive timing attacks with online computations
  3. Tom St Denis
  4. Introduction
  5. ------------
  6. A timing attack is when an attacker can observe a side channel of the device (in this case time). In this tech note
  7. we consider only non-intrusive timing attacks with respect to online computations. That is an attacker can
  8. determine when a computation (such as a public key encryption) begins and ends but cannot observe the device
  9. directly. This is specifically important for applications which transmit data via a public network.
  10. Consider a Diffie-Hellman encryption which requires the sender to make up a public key "y = g^x mod p". Libtomcrypt
  11. uses the MPI bignum library to perform the operation. The time it takes to compute y is controlled by the number
  12. of 1 bits in the exponent 'x'. To a large extent there will be the same number of squaring operations. "1" bits in
  13. the exponent require the sender to perform a multiplication. This means to a certain extent an attacker can
  14. determine not only the magnitude of 'x' but the number of one bits. With this information the attacker cannot directly
  15. learn the key used. However, good cryptography mandates the close scrutiny of any practical side channel.
  16. Similar logic applies to the other various routines. Fortunately for this case there is a simple solution. First,
  17. determine the maximum time the particular operation can require. For instance, on an Athlon 1.53Ghz XP processor a
  18. DH-768 encryption requires roughly 50 milliseconds. Take that time and round it up. Now place a delay after the call.
  19. For example,
  20. void demo(void) {
  21. clock_t t1;
  22. // get initial clock
  23. t1 = clock();
  24. // some PK function
  25. // now delay
  26. while (clock() < (t1 + 100));
  27. // transmit data...
  28. }
  29. This code has the effect of taking at least 100 ms always. In effect someone analyzing the traffic will see that the
  30. operations always take a fixed amount of time. Since no two platforms are the same this type of fix has not been
  31. incorporated into libtomcrypt (nor is it desired for many platforms). This requires on the developers part to profile
  32. the code to determine the delays required.
  33. Note that this "quick" fix has no effect against an intrusive attacker. For example, power consumption will drop
  34. significantly in the loop after the operation. However, this type of fix is more important to secure the user of the
  35. application/device. For example, a user placing an order online won't try to cheat themselves by cracking open their
  36. device and performing side-channel cryptanalysis. An attacker over a network might try to use the timing information
  37. against the user.