diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-07-26 17:00:38 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-07-26 17:00:38 +0700 |
commit | cd51dffe999cf5e440e04970689e1cb10e623d98 (patch) | |
tree | b2cdc426eee50a119ce8278dcb482adc6233eeaa /crypto/src/tls/HandshakeMessageOutput.cs | |
parent | PSK binder based on explicit PRF hash (diff) | |
download | BouncyCastle.NET-ed25519-cd51dffe999cf5e440e04970689e1cb10e623d98.tar.xz |
ClientHello 'splitting' to handle PSK binders
Diffstat (limited to 'crypto/src/tls/HandshakeMessageOutput.cs')
-rw-r--r-- | crypto/src/tls/HandshakeMessageOutput.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crypto/src/tls/HandshakeMessageOutput.cs b/crypto/src/tls/HandshakeMessageOutput.cs index ae07b9682..97e9a84af 100644 --- a/crypto/src/tls/HandshakeMessageOutput.cs +++ b/crypto/src/tls/HandshakeMessageOutput.cs @@ -58,5 +58,50 @@ namespace Org.BouncyCastle.Tls Platform.Dispose(this); } + + internal void PrepareClientHello(TlsHandshakeHash handshakeHash, int totalBindersLength) + { + TlsUtilities.CheckUint16(totalBindersLength); + + // Patch actual length back in + int bodyLength = (int)Length - 4 + totalBindersLength; + TlsUtilities.CheckUint24(bodyLength); + + Seek(1L, SeekOrigin.Begin); + TlsUtilities.WriteUint24(bodyLength, this); + +#if PORTABLE + byte[] buf = ToArray(); + int count = buf.Length; +#else + byte[] buf = GetBuffer(); + int count = (int)Length; +#endif + + handshakeHash.Update(buf, 0, count); + + Seek(0L, SeekOrigin.End); + } + + internal void SendClientHello(TlsClientProtocol clientProtocol, TlsHandshakeHash handshakeHash, + int totalBindersLength) + { +#if PORTABLE + byte[] buf = ToArray(); + int count = buf.Length; +#else + byte[] buf = GetBuffer(); + int count = (int)Length; +#endif + + if (totalBindersLength > 0) + { + handshakeHash.Update(buf, count - totalBindersLength, totalBindersLength); + } + + clientProtocol.WriteHandshakeMessage(buf, 0, count); + + Platform.Dispose(this); + } } } |