diff options
Diffstat (limited to 'crypto/src/tls')
8 files changed, 15 insertions, 25 deletions
diff --git a/crypto/src/tls/TlsClientProtocol.cs b/crypto/src/tls/TlsClientProtocol.cs index ec1cd28d5..6aa1acf2f 100644 --- a/crypto/src/tls/TlsClientProtocol.cs +++ b/crypto/src/tls/TlsClientProtocol.cs @@ -1001,8 +1001,7 @@ namespace Org.BouncyCastle.Tls throw new TlsFatalAlert(AlertDescription.illegal_parameter); } - TlsAgreement agreement = (TlsAgreement)m_clientAgreements[keyShareEntry.NamedGroup]; - if (null == agreement) + if (!m_clientAgreements.TryGetValue(keyShareEntry.NamedGroup, out var agreement)) throw new TlsFatalAlert(AlertDescription.illegal_parameter); agreement.ReceivePeerValue(keyShareEntry.KeyExchange); diff --git a/crypto/src/tls/TlsExtensionsUtilities.cs b/crypto/src/tls/TlsExtensionsUtilities.cs index 46d42417c..836c1b506 100644 --- a/crypto/src/tls/TlsExtensionsUtilities.cs +++ b/crypto/src/tls/TlsExtensionsUtilities.cs @@ -592,7 +592,7 @@ namespace Org.BouncyCastle.Tls // Placeholder for length TlsUtilities.WriteUint16(0, buf); - foreach (X509Name authority in authorities) + foreach (var authority in authorities) { byte[] derEncoding = authority.GetEncoded(Asn1Encodable.Der); TlsUtilities.WriteOpaque16(derEncoding, buf); @@ -736,7 +736,6 @@ namespace Org.BouncyCastle.Tls if (null != filters) { - //foreach (DerObjectIdentifier certificateExtensionOid in filters.Keys) foreach (var filter in filters) { var certificateExtensionOid = filter.Key; @@ -1020,7 +1019,7 @@ namespace Org.BouncyCastle.Tls { byte[] derEncoding = TlsUtilities.ReadOpaque16(buf, 1); Asn1Object asn1 = TlsUtilities.ReadAsn1Object(derEncoding); - X509Name ca = X509Name.GetInstance(asn1); + var ca = X509Name.GetInstance(asn1); TlsUtilities.RequireDerEncoding(ca, derEncoding); authorities.Add(ca); } diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs index 4a89d6708..e2c3e3094 100644 --- a/crypto/src/tls/TlsUtilities.cs +++ b/crypto/src/tls/TlsUtilities.cs @@ -5010,7 +5010,7 @@ namespace Org.BouncyCastle.Tls { if (null != clientShares && 1 == clientShares.Count) { - KeyShareEntry clientShare = (KeyShareEntry)clientShares[0]; + KeyShareEntry clientShare = clientShares[0]; if (null != clientShare && clientShare.NamedGroup == keyShareGroup) { return clientShare; @@ -5602,7 +5602,7 @@ namespace Org.BouncyCastle.Tls int index = offeredPsks.GetIndexOfIdentity(new PskIdentity(psk.Identity, 0L)); if (index >= 0) { - byte[] binder = (byte[])offeredPsks.Binders[index]; + byte[] binder = offeredPsks.Binders[index]; TlsCrypto crypto = serverContext.Crypto; TlsSecret earlySecret = GetPskEarlySecret(crypto, psk); diff --git a/crypto/src/tls/crypto/impl/AbstractTlsCrypto.cs b/crypto/src/tls/crypto/impl/AbstractTlsCrypto.cs index a8fb26697..e29993c92 100644 --- a/crypto/src/tls/crypto/impl/AbstractTlsCrypto.cs +++ b/crypto/src/tls/crypto/impl/AbstractTlsCrypto.cs @@ -64,14 +64,10 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl public virtual TlsSecret AdoptSecret(TlsSecret secret) { // TODO[tls] Need an alternative that doesn't require AbstractTlsSecret (which holds literal data) - if (secret is AbstractTlsSecret) - { - AbstractTlsSecret sec = (AbstractTlsSecret)secret; + if (secret is AbstractTlsSecret abstractTlsSecret) + return CreateSecret(abstractTlsSecret.CopyData()); - return CreateSecret(sec.CopyData()); - } - - throw new ArgumentException("unrecognized TlsSecret - cannot copy data: " + Platform.GetTypeName(secret)); + throw new ArgumentException("unrecognized TlsSecret - cannot copy data: " + secret.GetType().FullName); } public abstract TlsHash CreateHash(int cryptoHashAlgorithm); diff --git a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedAgreement.cs b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedAgreement.cs index 863b96634..bca415dcf 100644 --- a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedAgreement.cs +++ b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedAgreement.cs @@ -39,7 +39,7 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC } else { - throw new ArgumentException("'privateKey' type not supported: " + Platform.GetTypeName(privateKey)); + throw new ArgumentException("'privateKey' type not supported: " + privateKey.GetType().FullName); } } diff --git a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedDecryptor.cs b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedDecryptor.cs index b0e9f125e..bbe9af4e6 100644 --- a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedDecryptor.cs +++ b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedDecryptor.cs @@ -37,7 +37,7 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC } else { - throw new ArgumentException("'privateKey' type not supported: " + Platform.GetTypeName(privateKey)); + throw new ArgumentException("'privateKey' type not supported: " + privateKey.GetType().FullName); } this.m_crypto = crypto; diff --git a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedSigner.cs b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedSigner.cs index 6db84cdd8..82bc58f96 100644 --- a/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedSigner.cs +++ b/crypto/src/tls/crypto/impl/bc/BcDefaultTlsCredentialedSigner.cs @@ -68,7 +68,7 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC } else { - throw new ArgumentException("'privateKey' type not supported: " + Platform.GetTypeName(privateKey)); + throw new ArgumentException("'privateKey' type not supported: " + privateKey.GetType().FullName); } return signer; diff --git a/crypto/src/tls/crypto/impl/bc/BcTlsSecret.cs b/crypto/src/tls/crypto/impl/bc/BcTlsSecret.cs index 683806347..fdd67fc71 100644 --- a/crypto/src/tls/crypto/impl/bc/BcTlsSecret.cs +++ b/crypto/src/tls/crypto/impl/bc/BcTlsSecret.cs @@ -14,17 +14,13 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC { public static BcTlsSecret Convert(BcTlsCrypto crypto, TlsSecret secret) { - if (secret is BcTlsSecret) - return (BcTlsSecret)secret; - - if (secret is AbstractTlsSecret) - { - AbstractTlsSecret abstractTlsSecret = (AbstractTlsSecret)secret; + if (secret is BcTlsSecret bcTlsSecret) + return bcTlsSecret; + if (secret is AbstractTlsSecret abstractTlsSecret) return crypto.AdoptLocalSecret(CopyData(abstractTlsSecret)); - } - throw new ArgumentException("unrecognized TlsSecret - cannot copy data: " + Platform.GetTypeName(secret)); + throw new ArgumentException("unrecognized TlsSecret - cannot copy data: " + secret.GetType().FullName); } // SSL3 magic mix constants ("A", "BB", "CCC", ...) |