示例#1
0
        public CipherSuiteInfo(ECipherSuite cipherSuite, ECipherAlgorithm cipher, ECipherType cipherType,
                               byte encKeyLen, byte blockLen, byte ivLen, byte recordIVLen,
                               EMACAlgorithm mac, EKeyExchangeAlgorithm exchangeAlgo)
        {
            CipherSuite          = cipherSuite;
            CipherAlgorithm      = cipher;
            CipherType           = cipherType;
            EncKeyLength         = encKeyLen;
            BlockLength          = blockLen;
            FixedIVLength        = ivLen;
            RecordIVLength       = recordIVLen;
            MACAlgorithm         = mac;
            KeyExchangeAlgorithm = exchangeAlgo;
            switch (mac)
            {
            case EMACAlgorithm.HMAC_MD5: MACLength = MACKeyLength = 16; break;

            case EMACAlgorithm.HMAC_SHA1: MACLength = MACKeyLength = 20; break;

            case EMACAlgorithm.HMAC_SHA256: MACLength = MACKeyLength = 32; break;

            case EMACAlgorithm.HMAC_SHA384: MACLength = MACKeyLength = 48; break;

            case EMACAlgorithm.HMAC_SHA512: MACLength = MACKeyLength = 64; break;

            default: throw new ArgumentOutOfRangeException();
            }
            IsECC = exchangeAlgo == EKeyExchangeAlgorithm.ECDH_anon ||
                    exchangeAlgo == EKeyExchangeAlgorithm.ECDH_ECDSA ||
                    exchangeAlgo == EKeyExchangeAlgorithm.ECDH_RSA ||
                    exchangeAlgo == EKeyExchangeAlgorithm.ECDHE_ECDSA ||
                    exchangeAlgo == EKeyExchangeAlgorithm.ECDHE_RSA;
        }
示例#2
0
 public HttpsSmsgHello(HttpsSession session, ECipherSuite cipherSuite, byte[] sessionID, byte[] serverRandom)
     : base(session, ERecordType.Handshake)
 {
     Write((byte)EHandshake.ServerHello);
     Write24BitInt(0x000000); // position = 6, length, must be fixed up on compile.
     Write((ushort)session.Protocol);
     Write(serverRandom);     // 32 bytes server random data
     if (sessionID == null)
     {
         Write((byte)0x00); // session id = null
     }
     else
     {
         Write((byte)sessionID.Length);
         Write(sessionID);
     }
     Write((ushort)cipherSuite); // cipher suite used
     Write((byte)0x00);          // compression method used = null
     FixupLength24Bit(6, (int)Length - 9);
 }