コード例 #1
0
        public IEnumerable <HelloExtension> GenerateHelloExtensions()
        {
            if (_endConfig.End == ConnectionEnd.Server)
            {
                yield break;
            }

            var suites = _cipherSuiteProvider
                         .GetAllSupportedSuites(_cipherSuitesRegistry);

            _config.SupportedAlgorithms = suites
                                          .Select(x => (_cipherSuitesRegistry.MapHashAlgorithm(x), _cipherSuitesRegistry.MapSignatureAlgorithm(x)))
                                          .Distinct()
                                          .ToArray();

            using (var ms = new MemoryStream())
            {
                var writer = new EndianBinaryWriter(EndianBitConverter.Big, ms);

                writer.Write((ushort)(_config.SupportedAlgorithms.Count * 2));
                foreach (var(hash, sig) in _config.SupportedAlgorithms)
                {
                    writer.Write(hash.Id);
                    writer.Write(sig.Id);
                }

                yield return(new HelloExtension(ExtensionType.SignatureAlgorithms, ms.ToArray()));
            }
        }
コード例 #2
0
        public bool IsSupported(CipherSuite suite)
        {
            if (!_registry.IsSupported(suite))
            {
                return(false);
            }

            if (!_cipherAlgorithmRegistry.IsSupported(_registry.MapCipherAlgorithm(suite)))
            {
                return(false);
            }
            if (!_cipherParameterFactoryProvider.IsSupported(_registry.MapCipherAlgorithm(suite)))
            {
                return(false);
            }
            if (!_hashAlgorithmRegistry.IsSupported(_registry.MapHashAlgorithm(suite)))
            {
                return(false);
            }
            if (!_prfHashRegistry.IsSupported(_registry.MapHashAlgorithm(suite)))
            {
                return(false);
            }
            if (!_signatureAlgorithmsRegistry.IsSupported(_registry.MapSignatureAlgorithm(suite)))
            {
                return(false);
            }
            if (!_signatureCipherParameterFactoryProvider.IsSupported(_registry.MapSignatureAlgorithm(suite)))
            {
                return(false);
            }
            if (!_keyExchangeProvider.IsSupported(_registry.MapKeyExchange(suite)))
            {
                return(false);
            }

            return(true);
        }