public CipherSuiteInfo(BulkCipherAlgorithm cipher, CipherType cipherType, byte encKeyLen, byte blockLen, byte ivLen, byte recordIVLen, MACAlgorithm mac, KeyExchangeAlgorithm exchangeAlgo) { _bulk_cipher = cipher; _cipherType = cipherType; _enc_key_length = encKeyLen; _block_length = blockLen; _fixed_iv_length = ivLen; _record_iv_length = recordIVLen; _mac = mac; _exchangeAlgo = exchangeAlgo; switch (mac) { case MACAlgorithm.HMAC_MD5: _mac_length = _mac_key_length = 16; break; case MACAlgorithm.HMAC_SHA1: _mac_length = _mac_key_length = 20; break; case MACAlgorithm.HMAC_SHA256: _mac_length = _mac_key_length = 32; break; case MACAlgorithm.HMAC_SHA384: _mac_length = _mac_key_length = 48; break; case MACAlgorithm.HMAC_SHA512: _mac_length = _mac_key_length = 64; break; default: throw new ArgumentOutOfRangeException(); } _isECC = exchangeAlgo == KeyExchangeAlgorithm.ECDH_anon || exchangeAlgo == KeyExchangeAlgorithm.ECDH_ECDSA || exchangeAlgo == KeyExchangeAlgorithm.ECDH_RSA || exchangeAlgo == KeyExchangeAlgorithm.ECDHE_ECDSA || exchangeAlgo == KeyExchangeAlgorithm.ECDHE_RSA; }
public CipherSuiteInfo(BulkCipherAlgorithm cipher, CipherType cipherType, byte encKeyLen, byte blockLen, byte ivLen, byte recordIVLen, MACAlgorithm mac, KeyExchangeAlgorithm exchangeAlgo) { _bulk_cipher = cipher; _cipherType = cipherType; _enc_key_length = encKeyLen; _block_length = blockLen; _fixed_iv_length = ivLen; _record_iv_length = recordIVLen; _mac = mac; _exchangeAlgo = exchangeAlgo; switch (mac) { case MACAlgorithm.HMAC_MD5: _mac_length = _mac_key_length = 16; break; case MACAlgorithm.HMAC_SHA1: _mac_length = _mac_key_length = 20; break; case MACAlgorithm.HMAC_SHA256: _mac_length = _mac_key_length = 32; break; case MACAlgorithm.HMAC_SHA384: _mac_length = _mac_key_length = 48; break; case MACAlgorithm.HMAC_SHA512: _mac_length = _mac_key_length = 64; break; default: throw new ArgumentOutOfRangeException (); } _isECC = exchangeAlgo == KeyExchangeAlgorithm.ECDH_anon || exchangeAlgo == KeyExchangeAlgorithm.ECDH_ECDSA || exchangeAlgo == KeyExchangeAlgorithm.ECDH_RSA || exchangeAlgo == KeyExchangeAlgorithm.ECDHE_ECDSA || exchangeAlgo == KeyExchangeAlgorithm.ECDHE_RSA; }
public void SetCipherSuite(CipherSuite suite, AsymmetricAlgorithm signAlgo) { CipherSuiteInfo info = SupportedCipherSuites.GetSuiteInfo(suite); if (info == null) { throw new NotSupportedException(); } _bulk_cipher = info.BulkCipherAlgorithm; _cipherType = info.CipherType; _enc_key_length = info.EncKeyLength; _block_length = info.BlockLength; _fixed_iv_length = info.FixedIVLength; _record_iv_length = info.RecordIVLength; _mac = info.MACAlgorithm; _mac_length = info.MACLength; _mac_key_length = info.MACKeyLength; _keyExchange = info.KeyExchangeAlgorithm; // TODO: TLS1.2spec ? switch (_prfType) { case PRFAlgorithm.MD5_AND_SHA1: _prf = new MD5_AND_SHA1(); break; case PRFAlgorithm.SSL3: _prf = new SSL3_PRF(this); break; default: throw new NotSupportedException(); } switch (_keyExchange) { case KeyExchangeAlgorithm.ECDHE_ECDSA: _keyExchanger = new ECDHE_ECDSA((openCrypto.EllipticCurve.Signature.ECDSA)signAlgo); break; case KeyExchangeAlgorithm.DHE_DSS: _keyExchanger = new DHE_DSS((DSACryptoServiceProvider)signAlgo); break; case KeyExchangeAlgorithm.RSA: _keyExchanger = new KeyExchange.RSA((RSACryptoServiceProvider)signAlgo); break; default: throw new NotImplementedException(); } }
public void SetCipherSuite(CipherSuite suite, AsymmetricAlgorithm signAlgo) { CipherSuiteInfo info = SupportedCipherSuites.GetSuiteInfo (suite); if (info == null) throw new NotSupportedException (); _bulk_cipher = info.BulkCipherAlgorithm; _cipherType = info.CipherType; _enc_key_length = info.EncKeyLength; _block_length = info.BlockLength; _fixed_iv_length = info.FixedIVLength; _record_iv_length = info.RecordIVLength; _mac = info.MACAlgorithm; _mac_length = info.MACLength; _mac_key_length = info.MACKeyLength; _keyExchange = info.KeyExchangeAlgorithm; // TODO: TLS1.2spec ? switch (_prfType) { case PRFAlgorithm.MD5_AND_SHA1: _prf = new MD5_AND_SHA1 (); break; case PRFAlgorithm.SSL3: _prf = new SSL3_PRF (this); break; default: throw new NotSupportedException (); } switch (_keyExchange) { case KeyExchangeAlgorithm.ECDHE_ECDSA: _keyExchanger = new ECDHE_ECDSA ((openCrypto.EllipticCurve.Signature.ECDSA)signAlgo); break; case KeyExchangeAlgorithm.DHE_DSS: _keyExchanger = new DHE_DSS ((DSACryptoServiceProvider)signAlgo); break; case KeyExchangeAlgorithm.RSA: _keyExchanger = new KeyExchange.RSA ((RSACryptoServiceProvider)signAlgo); break; default: throw new NotImplementedException (); } }