Perfect Forward Secrecy #1254

Open
aaannndddyyy opened this Issue Feb 9, 2015 · 21 comments

Comments

Projects
None yet
8 participants
@aaannndddyyy
Contributor

aaannndddyyy commented Feb 9, 2015

  1. Do you create a random public/private keypair per session, or do you directly create per session symmetric keys?

  2. Please rekey after a given time! Let's say after 2 hours or 500 text messages or 10MB of transferred data, depending on which happens first.

unrelated: Please do not cryptographically sign any chat messages or data packets (video, file transfer). I couldn't find information if that is done somewhere, maybe you can point me to the spec.

@srkunze

This comment has been minimized.

Show comment
Hide comment
@srkunze

srkunze Feb 9, 2015

Please do not cryptographically sign any chat messages or data packets (video, file transfer)

How come?

srkunze commented Feb 9, 2015

Please do not cryptographically sign any chat messages or data packets (video, file transfer)

How come?

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 10, 2015

Contributor

@srkunze because you could then prove that i said what i said.

Contributor

aaannndddyyy commented Feb 10, 2015

@srkunze because you could then prove that i said what i said.

@SafwatHalaby

This comment has been minimized.

Show comment
Hide comment
@SafwatHalaby

SafwatHalaby Feb 12, 2015

Perfect Forward Secrecy does not contradict message signing. You can have both.

Perfect Forward Secrecy does not contradict message signing. You can have both.

@irungentoo

This comment has been minimized.

Show comment
Hide comment
@irungentoo

irungentoo Feb 12, 2015

Owner

I think he's speaking about deniability.

Toxcore doesn't sign anything.

Do you create a random public/private keypair per session, or do you directly create per session symmetric keys?

The answer is both. It creates a session keypair with NaCl and sends it to the other peer, the other peer then uses that public key and their session secret key to generate a shared key used for symmetric encryption. (You do the same thing with their session public key and your session secret key and get the same key). That key is then used to encrypt everything sent via the connection.

Please rekey after a given time! Let's say after 2 hours or 500 text messages or 10MB of transferred data, depending on which happens first.

Yes, that's planned. How does rekeying every 2^16 packets sound? Personally I think that rekeying isn't that needed because if someone gets access to your machines ram while you are running Tox they can get all your messages from the message log of whatever client you are running. If someone has enough access to your system to obtain the session key then they don't even need it to know what you were doing with Tox.

But since it's not hard to implement and doesn't have any drawbacks I have no issues with implementing it.

Owner

irungentoo commented Feb 12, 2015

I think he's speaking about deniability.

Toxcore doesn't sign anything.

Do you create a random public/private keypair per session, or do you directly create per session symmetric keys?

The answer is both. It creates a session keypair with NaCl and sends it to the other peer, the other peer then uses that public key and their session secret key to generate a shared key used for symmetric encryption. (You do the same thing with their session public key and your session secret key and get the same key). That key is then used to encrypt everything sent via the connection.

Please rekey after a given time! Let's say after 2 hours or 500 text messages or 10MB of transferred data, depending on which happens first.

Yes, that's planned. How does rekeying every 2^16 packets sound? Personally I think that rekeying isn't that needed because if someone gets access to your machines ram while you are running Tox they can get all your messages from the message log of whatever client you are running. If someone has enough access to your system to obtain the session key then they don't even need it to know what you were doing with Tox.

But since it's not hard to implement and doesn't have any drawbacks I have no issues with implementing it.

@codedust

This comment has been minimized.

Show comment
Hide comment
@codedust

codedust Feb 12, 2015

Contributor

@aaannndddyyy

Toxcore doesn't sign anything.

To be more precise, toxcore uses the crypto_box method from the NaCl library for encryption:

The crypto_box function is not meant to provide non-repudiation. On the contrary: the crypto_box function guarantees repudiability. A receiver can freely modify a boxed message, and therefore cannot convince third parties that this particular message came from the sender. The sender and receiver are nevertheless protected against forgeries by other parties.
http://nacl.cr.yp.to/box.html

@irungentoo

The answer is both. It creates a session keypair with NaCl and sends it to the other peer

Hopefully, only the public key from that keypair is transferred. ;)

Personally I think that rekeying isn't that needed because if someone gets access to your machines ram while you are running Tox they can get all your messages from the message log of whatever client you are running.

The point is to make it even more difficult for an attacker (with a lot of computing power) who has no access to your machine to decrypt your whole communication during one session. Note that sessions can get quite long on mobile devices.

Anyone interested in this may read these two blog post from OWS explaining how (and why) they designed the protocol behind Textsecure:
https://whispersystems.org/blog/asynchronous-security/
https://whispersystems.org/blog/advanced-ratcheting/

Contributor

codedust commented Feb 12, 2015

@aaannndddyyy

Toxcore doesn't sign anything.

To be more precise, toxcore uses the crypto_box method from the NaCl library for encryption:

The crypto_box function is not meant to provide non-repudiation. On the contrary: the crypto_box function guarantees repudiability. A receiver can freely modify a boxed message, and therefore cannot convince third parties that this particular message came from the sender. The sender and receiver are nevertheless protected against forgeries by other parties.
http://nacl.cr.yp.to/box.html

@irungentoo

The answer is both. It creates a session keypair with NaCl and sends it to the other peer

Hopefully, only the public key from that keypair is transferred. ;)

Personally I think that rekeying isn't that needed because if someone gets access to your machines ram while you are running Tox they can get all your messages from the message log of whatever client you are running.

The point is to make it even more difficult for an attacker (with a lot of computing power) who has no access to your machine to decrypt your whole communication during one session. Note that sessions can get quite long on mobile devices.

Anyone interested in this may read these two blog post from OWS explaining how (and why) they designed the protocol behind Textsecure:
https://whispersystems.org/blog/asynchronous-security/
https://whispersystems.org/blog/advanced-ratcheting/

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 12, 2015

Contributor

2¹⁶ sounds a bit big, imho. You'd want to provide not that much of cipherdata for a given key to the cryptoanalyst.

And yes, the other issue above was about deniability, therefore, I wrote it is unrelated. I was not sure if you do it that way but already thought you might be doing it, so I didn't file a separate issue for it.

Contributor

aaannndddyyy commented Feb 12, 2015

2¹⁶ sounds a bit big, imho. You'd want to provide not that much of cipherdata for a given key to the cryptoanalyst.

And yes, the other issue above was about deniability, therefore, I wrote it is unrelated. I was not sure if you do it that way but already thought you might be doing it, so I didn't file a separate issue for it.

@dubslow

This comment has been minimized.

Show comment
Hide comment
@dubslow

dubslow Feb 13, 2015

Contributor

That's 2^16 packets, and packets aren't very big. That's on the order of 64-128KiB.

Contributor

dubslow commented Feb 13, 2015

That's 2^16 packets, and packets aren't very big. That's on the order of 64-128KiB.

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 13, 2015

Contributor

2¹⁶*128KB is more than 8GB. Or do you mean, that it is a total of 128KB?
Remember: otr does that for every single message. I don't think that is a needed level, but 8GB might be a bit much.

Contributor

aaannndddyyy commented Feb 13, 2015

2¹⁶*128KB is more than 8GB. Or do you mean, that it is a total of 128KB?
Remember: otr does that for every single message. I don't think that is a needed level, but 8GB might be a bit much.

@dubslow

This comment has been minimized.

Show comment
Hide comment
@dubslow

dubslow Feb 13, 2015

Contributor

One packet is typically on the order of a kilobyte, though my estimate ranges from 1-2 KiB per packet.

Contributor

dubslow commented Feb 13, 2015

One packet is typically on the order of a kilobyte, though my estimate ranges from 1-2 KiB per packet.

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 13, 2015

Contributor

ok, 128MB sounds much better already. that's still a LOT of text messges

Contributor

aaannndddyyy commented Feb 13, 2015

ok, 128MB sounds much better already. that's still a LOT of text messges

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 13, 2015

Contributor

2⁸ packets would be nice for text messages if one short text message corresponds to one packet. But that would be too foten often[edit] for you, I guess.

Contributor

aaannndddyyy commented Feb 13, 2015

2⁸ packets would be nice for text messages if one short text message corresponds to one packet. But that would be too foten often[edit] for you, I guess.

@irungentoo

This comment has been minimized.

Show comment
Hide comment
@irungentoo

irungentoo Feb 13, 2015

Owner

How about a time limit like every hour?

Owner

irungentoo commented Feb 13, 2015

How about a time limit like every hour?

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 13, 2015

Contributor

I'm totally fine with either 2¹¹ packets or every hour or a combination thereof. Dunno about the other folks here. edit: in case of combination thereof, the exponent could even be slightly higher, namely 2¹² or 2¹³, IMHO. You could count packets and and time since rekey and if one reaches the limit it initiates rekeying and resets both counters.

Contributor

aaannndddyyy commented Feb 13, 2015

I'm totally fine with either 2¹¹ packets or every hour or a combination thereof. Dunno about the other folks here. edit: in case of combination thereof, the exponent could even be slightly higher, namely 2¹² or 2¹³, IMHO. You could count packets and and time since rekey and if one reaches the limit it initiates rekeying and resets both counters.

@codedust

This comment has been minimized.

Show comment
Hide comment
@codedust

codedust Feb 14, 2015

Contributor

What do you think about implementing the ratchet protocol from Textsecure? It's not as trivial as simply changing the key after x packets but it would improve security even more.

Contributor

codedust commented Feb 14, 2015

What do you think about implementing the ratchet protocol from Textsecure? It's not as trivial as simply changing the key after x packets but it would improve security even more.

@irungentoo

This comment has been minimized.

Show comment
Hide comment
@irungentoo

irungentoo Feb 15, 2015

Owner

@codedust I think their protocol only works when the transport protocol delivers packets in order without loss. The Tox crypto is done at the level below the protocol that makes sure that data is delivered in order.

Owner

irungentoo commented Feb 15, 2015

@codedust I think their protocol only works when the transport protocol delivers packets in order without loss. The Tox crypto is done at the level below the protocol that makes sure that data is delivered in order.

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 15, 2015

Contributor

I don't think, they require in-order delivery. Actually that's one thing they complained about in the silent circle ratched. What they have is a DH ratched combined with a hash ratched.
and to quote them "Nice properties like cryptographically-enforced message ordering and replay protection all come for free, without any complex record keeping required. The code is simpler, and the protocol security is more robust."

Contributor

aaannndddyyy commented Feb 15, 2015

I don't think, they require in-order delivery. Actually that's one thing they complained about in the silent circle ratched. What they have is a DH ratched combined with a hash ratched.
and to quote them "Nice properties like cryptographically-enforced message ordering and replay protection all come for free, without any complex record keeping required. The code is simpler, and the protocol security is more robust."

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 15, 2015

Contributor

that's what they say they do:

  • Combine the forward-secrecy of symmetric-key updating with the "future-secrecy" of an OTR-like Diffie-Hellman ratchet.
    By "future-secrecy" we mean that a leak of keys to a passive eavesdropper will be healed by introducing new DH ratchet keys.
  • Improve on OTR's future-secrecy with a "2-step" DH ratchet instead of "3-step".
    I.e. DH ratchet keys are used in a "send/receive" pattern, instead of "advertise/receive/send".
  • Detect replay / reorder / deletion of messages.
  • Allow decryption of out-of-order messages with minimal reduction in forward secrecy.
  • Don't leak metadata in cleartext (such as identities or sequence numbers).
Contributor

aaannndddyyy commented Feb 15, 2015

that's what they say they do:

  • Combine the forward-secrecy of symmetric-key updating with the "future-secrecy" of an OTR-like Diffie-Hellman ratchet.
    By "future-secrecy" we mean that a leak of keys to a passive eavesdropper will be healed by introducing new DH ratchet keys.
  • Improve on OTR's future-secrecy with a "2-step" DH ratchet instead of "3-step".
    I.e. DH ratchet keys are used in a "send/receive" pattern, instead of "advertise/receive/send".
  • Detect replay / reorder / deletion of messages.
  • Allow decryption of out-of-order messages with minimal reduction in forward secrecy.
  • Don't leak metadata in cleartext (such as identities or sequence numbers).
@jf99

This comment has been minimized.

Show comment
Hide comment
@jf99

jf99 Feb 19, 2015

When you change keys often, watch out that you're not running out of entropy. Otherwise this practice might lower the security. To avoid this, you could take the old key, add some new random bits to it and use the hash of both as the new key. This way, the new key is never less secure (=less random) than the old one.

jf99 commented Feb 19, 2015

When you change keys often, watch out that you're not running out of entropy. Otherwise this practice might lower the security. To avoid this, you could take the old key, add some new random bits to it and use the hash of both as the new key. This way, the new key is never less secure (=less random) than the old one.

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Feb 19, 2015

Contributor

axolotl also helps in that respect. it does not always do a new DH key exchange.
And yes, a good point @jf99. We wouln't wanna get insecure keys or block waiting for entropy.

Contributor

aaannndddyyy commented Feb 19, 2015

axolotl also helps in that respect. it does not always do a new DH key exchange.
And yes, a good point @jf99. We wouln't wanna get insecure keys or block waiting for entropy.

@codedust

This comment has been minimized.

Show comment
Hide comment
@codedust

codedust Jan 16, 2016

Contributor

FYI: There is an Axolotl implementation in C out there: https://github.com/WhisperSystems/libaxolotl-c

Contributor

codedust commented Jan 16, 2016

FYI: There is an Axolotl implementation in C out there: https://github.com/WhisperSystems/libaxolotl-c

@aaannndddyyy

This comment has been minimized.

Show comment
Hide comment
@aaannndddyyy

aaannndddyyy Jan 16, 2016

Contributor

It would be great if tox could use that.
Axolotl is one of the advantages signal has over tox. (the others are offline messages and lower ressource usage).
Axolotl also allows for encrypted offline messages once/if tox gets them, and effective authenticated group encryption via conference keys.
null

Contributor

aaannndddyyy commented Jan 16, 2016

It would be great if tox could use that.
Axolotl is one of the advantages signal has over tox. (the others are offline messages and lower ressource usage).
Axolotl also allows for encrypted offline messages once/if tox gets them, and effective authenticated group encryption via conference keys.
null

@ovalseven8 ovalseven8 referenced this issue in TokTok/c-toxcore Nov 5, 2016

Open

Implement session rekeying #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment