diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-17 00:40:40 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-17 00:40:40 +0700 |
commit | ae8243b18d515b4942e41989b5d78fd05026ccd3 (patch) | |
tree | 5ee2bea0d14234e008b929d20751edde34716325 /crypto/src/tls/HandshakeMessageInput.cs | |
parent | BiString updates from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-ae8243b18d515b4942e41989b5d78fd05026ccd3.tar.xz |
TLS 1.3 PSK server-side work
Diffstat (limited to 'crypto/src/tls/HandshakeMessageInput.cs')
-rw-r--r-- | crypto/src/tls/HandshakeMessageInput.cs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/crypto/src/tls/HandshakeMessageInput.cs b/crypto/src/tls/HandshakeMessageInput.cs index d7cd19994..c15112cc0 100644 --- a/crypto/src/tls/HandshakeMessageInput.cs +++ b/crypto/src/tls/HandshakeMessageInput.cs @@ -6,17 +6,51 @@ using Org.BouncyCastle.Utilities.IO; namespace Org.BouncyCastle.Tls { + // TODO Rewrite without MemoryStream public sealed class HandshakeMessageInput : MemoryStream { + private readonly int m_offset; + internal HandshakeMessageInput(byte[] buf, int offset, int length) - : base(buf, offset, length, false) + : base(buf, offset, length, false, true) { +#if PORTABLE + this.m_offset = 0; +#else + this.m_offset = offset; +#endif } public void UpdateHash(TlsHash hash) { Streams.WriteBufTo(this, new TlsHashSink(hash)); } + + internal void UpdateHashPrefix(TlsHash hash, int bindersSize) + { +#if PORTABLE + byte[] buf = ToArray(); + int count = buf.Length; +#else + byte[] buf = GetBuffer(); + int count = (int)Length; +#endif + + hash.Update(buf, m_offset, count - bindersSize); + } + + internal void UpdateHashSuffix(TlsHash hash, int bindersSize) + { +#if PORTABLE + byte[] buf = ToArray(); + int count = buf.Length; +#else + byte[] buf = GetBuffer(); + int count = (int)Length; +#endif + + hash.Update(buf, m_offset + count - bindersSize, bindersSize); + } } } |