diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-17 21:46:19 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-17 21:46:19 +0700 |
commit | bd2fe5262f97293908320481e0eeefb0a92b364c (patch) | |
tree | f598e7fd9efd794f5abff6bd5345941b7d9be8ea /crypto/src/tls/OfferedPsks.cs | |
parent | TLS 1.3 PSK server-side work (diff) | |
download | BouncyCastle.NET-ed25519-bd2fe5262f97293908320481e0eeefb0a92b364c.tar.xz |
Server-side PSK selection
Diffstat (limited to 'crypto/src/tls/OfferedPsks.cs')
-rw-r--r-- | crypto/src/tls/OfferedPsks.cs | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/crypto/src/tls/OfferedPsks.cs b/crypto/src/tls/OfferedPsks.cs index 9eddd2e23..1cc8a2a68 100644 --- a/crypto/src/tls/OfferedPsks.cs +++ b/crypto/src/tls/OfferedPsks.cs @@ -26,6 +26,22 @@ namespace Org.BouncyCastle.Tls } } + internal class SelectedConfig + { + internal readonly int m_index; + internal readonly TlsPsk m_psk; + internal readonly short[] m_pskKeyExchangeModes; + internal readonly TlsSecret m_earlySecret; + + internal SelectedConfig(int index, TlsPsk psk, short[] pskKeyExchangeModes, TlsSecret earlySecret) + { + this.m_index = index; + this.m_psk = psk; + this.m_pskKeyExchangeModes = pskKeyExchangeModes; + this.m_earlySecret = earlySecret; + } + } + private readonly IList m_identities; private readonly IList m_binders; private readonly int m_bindersSize; @@ -49,16 +65,6 @@ namespace Org.BouncyCastle.Tls this.m_bindersSize = bindersSize; } - internal byte[] GetBinderForIdentity(PskIdentity matchIdentity) - { - for (int i = 0, count = m_identities.Count; i < count; ++i) - { - if (matchIdentity.Equals(m_identities[i])) - return (byte[])m_binders[i]; - } - return null; - } - public IList Binders { get { return m_binders; } @@ -74,6 +80,16 @@ namespace Org.BouncyCastle.Tls get { return m_identities; } } + public int GetIndexOfIdentity(PskIdentity pskIdentity) + { + for (int i = 0, count = m_identities.Count; i < count; ++i) + { + if (pskIdentity.Equals(m_identities[i])) + return i; + } + return -1; + } + /// <exception cref="IOException"/> public void Encode(Stream output) { |