262-rekey-circuits.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. Filename: 262-rekey-circuits.txt
  2. Title: Re-keying live circuits with new cryptographic material
  3. Author: Nick Mathewson
  4. Created: 28 Dec 2015
  5. Status: Open
  6. 1. Summary and Motivation
  7. Cryptographic primitives have an upper limit of how much data should
  8. be encrypted with the same key. But currently Tor circuits have no
  9. upper limit of how much data they will deliver.
  10. While the upper limits of our AES-CTR crypto is ridiculously high
  11. (on the order of hundreds of exabytes), the AEZ crypto we're
  12. considering suggests we should rekey after the equivalent in cells
  13. after around 280 TB. 280 TB is still high, but not ridiculously
  14. high.
  15. So in this proposal I explain a general mechanism for rekeying a
  16. circuit. We shouldn't actually build this unless we settle on
  17. 2. RELAY_REKEY cell operation
  18. To rekey, the circuit initiator ("client") can send a new RELAY_REKEY cell
  19. type:
  20. struct relay_rekey {
  21. u16 rekey_method IN [0, 1];
  22. u8 rekey_data[];
  23. }
  24. const REKEY_METHOD_ACK = 0;
  25. const REKEY_METHOD_SHAKE256_CLIENT = 1;
  26. This cell means "I am changing the key." The new key material will be
  27. derived from SHAKE256 of the aez_key concatenated with the rekey_data
  28. field, to fill a new shake_output structure. The client should set
  29. rekey_data at random.
  30. After sending one of these RELAY_REKEY cells, the client uses the new
  31. aez_key to encrypt all of its data to this hop, but retains the old
  32. aez_key for decrypting the data coming back from the relay.
  33. When the relay receives a RELAY_REKEY cell, it sends a RELAY_REKEY
  34. cell back towards the client, with empty rekey_data, and
  35. relay_method==0, and then updates its own key material for all
  36. additional data it sends and receives to the client.
  37. When the client receives this reply, it can discard the old AEZ key, and
  38. begin decrypting subsequent inbound cells with the new key.
  39. So in summary: the client sends a series of cells encrypted with the
  40. old key, and then sends a REKEY cell, followed by relay cells
  41. encrypted with the new key:
  42. OldKey[data data data ... data rekey] NewKey[data data data...]
  43. And after the server receives the REKEY cell, it stops sending relay
  44. cells encrypted with the old keys, sends its own REKEY cell with the
  45. ACK method, and starts sending cells encrypted with the new key.
  46. REKEY arrives somewhere in here
  47. I
  48. V
  49. OldKey[data data data data rekey-ack] NewKey[data data data ...]
  50. 2.1. Supporting other cryptography types
  51. Each relay cipher must specify its own behavior in the presence of a
  52. REKEY cell of each type that it supports. In general, the behavior
  53. of method 1 ("shake256-client") is "regenerate keys as if we were
  54. calling the original KDF after a CREATE handshake, using SHAKE256 on
  55. our current static key material and on a 32-byte random input."
  56. The behavior of any unsupported REKEY method must be to close the
  57. circuit with an error.
  58. The AES-CTR relay cell crypto doesn't support rekeying. See 3.2 below
  59. if you disagree.
  60. 2.2. How often to re-key?
  61. Clients should follow a deterministic algorithm in deciding when to
  62. re-key, so as not to leak client differences. This algorithm should
  63. be type-specific. For AEZ, I recommend that clients conservatively
  64. rekey every 2**32 cells (about 2 TB). And to make sure that this
  65. code actually works, the schedule should be after 2**15 cells, and
  66. then every 2**32 cells thereafter.
  67. It may be beneficial to randomize these numbers. If so, let's try
  68. subtracting between 0 and 25% at random.
  69. 2.3. How often to allow re-keying?
  70. We could define a lower bound to prevent too-frequent rekeying. I'm
  71. not sure I see the point here; the process described above is not
  72. that costly.
  73. 3. Alternative designs
  74. 3.1. Should we add some public key cryptography here?
  75. We could change the body of a REKEY cell and its ack to be more like
  76. CREATE/CREATED. Then we'd have to add a third step from the client
  77. to the server to acknowledge receipt of the 'CREATED' cell and
  78. changing of the key.
  79. So, what would this added complexity and computational load buy us?
  80. It would defend against the case where an adversary had compromised
  81. the shared key material for a circuit, but was not able to compromise
  82. the rekey process. I'm not sure that this is reasonable; the
  83. likeliest cases I can think of here seem to be "get compromised, stay
  84. compromised" for a circuit.
  85. 3.2. Hey, could we use this for forward secrecy with AES-CTR?
  86. We could, but the best solution to AES-CTR's limitations right now is
  87. to stop using our AES-CTR setup. Anything that supports REKEY will
  88. also presumably support AEZ or something better.
  89. 3.3. We could upgrade ciphers with this!
  90. Yes we could. We could define this not only to change the key, but
  91. to upgrade to a better ciphersuite. For example, we could start by
  92. negotiating AES-CTR, and then "secretly" upgrade to AEZ. I'm not
  93. sure that's worth the complexity, or that it would really be secret
  94. in the presence of traffic analysis.