On Sat, Jul 19, 2014 at 6:25 PM, Emmanuel Lécharny <elecha...@gmail.com> wrote:
> Le 19/07/2014 17:34, Jeff MAURY a écrit : > > No, I don't agree with that because the spec says that the new key > materials should be set current only when the change cipher spec message is > received from the server. So I think we can continue sending messages > encrypted with the old key if the handshake messages are after in the queue. > > What I read from the spec (RFC 6101, par 5.5) : > "the client sends a client hello message to which the server must > respond with a server hello message, or else a fatal error will occur > and the connection will fail " suggest the opposite. > This is related to the initial handshake. What we are discussing is more rehandshake and the fact that the server has messages to sent to will precede the handshake messages. I am reading the TLS spec (RFC 5246) not the SSL one (will do it). If you look at the TLS spec, the chapter 7.1 says: The ChangeCipherSpec message is sent by both the client and the server to notify the receiving party that subsequent records will be protected under the newly negotiated CipherSpec and keys. Reception of this message causes the receiver to instruct the record layer to immediately copy the read pending state into the read current state. Immediately after sending this message, the sender MUST instruct the record layer to make the write pending state the write active state. So in other words: - once a party has sent the ChangeCipherSpec message, it must start encrypting using the new key - once a party has received the ChangeCipherSpec, it must start decrypting using the new key. > In other words, if a client sends a CleientHello, anything the server > will send but ServerHello will generate an error. > > By all means, I think that once one peer has initiated a handshake, > everything but the SSL Handshake messages are forbidden, on both sides. > > > The problem is that if we encrypt before sending it's likely that we > will encrypt with the new key if the handshake message has been read > processed by the ssl engine > > That, I agree. IMO, we should never encrypt before sending. > > -- Jeff MAURY "Legacy code" often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury