コード例 #1
0
 public PseudoRandomFunctionTLSGeneric(string type)
 {
     if (type.Equals("MD5")) {
         _type = TLSGenericType.MD5;
     } else if (type.Equals("SHA1")) {
         _type = TLSGenericType.SHA1;
     } else if (type.Equals("SHA256")) {
         _type = TLSGenericType.SHA256;
     } else if (type.Equals("SHA384")) {
         _type = TLSGenericType.SHA384;
     } else if (type.Equals("SHA512")) {
         _type = TLSGenericType.SHA512;
     } else {
         throw new Exception("Unsupported PRF type");
     }
 }
コード例 #2
0
        public TLSGenericDeriveBytes(TLSGenericType type, byte[] secret, byte[] seed)
        {
            /* Here should be all supported types */
            switch (type) {
            case TLSGenericType.MD5:
                _hmac = new HMACGeneric(secret, "MD5", 64);
                break;
            case TLSGenericType.SHA1:
                _hmac = new HMACGeneric(secret, "SHA1", 64);
                break;
            case TLSGenericType.SHA256:
                _hmac = new HMACGeneric(secret, "SHA256", 64);
                break;
            case TLSGenericType.SHA384:
                _hmac = new HMACGeneric(secret, "SHA384", 128);
                break;
            case TLSGenericType.SHA512:
                _hmac = new HMACGeneric(secret, "SHA512", 128);
                break;
            default:
                throw new Exception("Unsupported TLSGenericType");
            }

            /* Set the seed as our parameter */
            _seed = seed;

            /* Reset the HMAC generators */
            Reset();
        }