Ensure cipher and Tlsv1
333694
def proxy_manager_for(self, proxy, **proxy_kwargs):
        """"""
        context = create_urllib3_context(ciphers=self.CIPHERS,
                                         ssl_version=ssl.PROTOCOL_TLSv1)
        proxy_kwargs['ssl_context'] = context
        return super(TLSv1Adapter, self).proxy_manager_for(proxy,
                                                           **proxy_kwargs)
1161203
def enable_encryption(self, output_key, input_key):
        """"""
        self._chacha = chacha20.Chacha20Cipher(output_key, input_key)
850007
def process_tls(self, data, name):
        
        ret = []
        try:
            lines = [x.strip() for x in data.split('\n')]
            for idx, line in enumerate(lines):
                if line == '':
                    continue

                sub = self.process_host(line, name, idx)
                if sub is not None:
                    ret.append(sub)

        except Exception as e:
            logger.error('Error in file processing %s : %s' % (name, e))
            self.roca.trace_logger.log(e)
        return ret
939309
function supportsSSL()
    {
        $v = curl_version();
        if(is_array($v)) {
            return in_array('https', $v['protocols']);
        } elseif (is_string($v)) {
            return preg_match('/OpenSSL/i', $v);
        } else {
            return 0;
        }
    }
793252
def cipher_block (self, state):
        """"""
        # PKCS7 Padding
        state=state+[16-len(state)]*(16-len(state))# Fails test if it changes the input with +=

        self._add_round_key(state, 0)

        for i in range(1, self._Nr):
            self._sub_bytes(state)
            self._shift_rows(state)
            self._mix_columns(state, False)
            self._add_round_key(state, i)

        self._sub_bytes(state)
        self._shift_rows(state)
        self._add_round_key(state, self._Nr)
        return state
627755
public static function _requireSSL() {
        if (!self::_isSSL()) {
            if (isset($_SERVER) && isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) {
                header("HTTP/1.1 301 Moved Permanently");
                header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                exit();
            } else {
                _Log::fatal('$_SERVER variables are not set.  Unable to require SSL');
                throw new _Exception('$_SERVER variables are not set.  Unable to require SSL');
            }
        }
    }
548627
def validate(self, cipher_text, max_timedelta=None):
        
        if isinstance(cipher_text, six.string_types):
            cipher_text.encode()
        cipher_text = base64.urlsafe_b64decode(cipher_text)
        decrypted = self.encryption_suite.decrypt(cipher_text).decode().split(self.separator)
        message_list, dt = decrypted[:-1], decrypted[-1]
        dt = int(''.join(re.findall(r'\d+', dt)))
        now = int(time.time())
        if max_timedelta and max_timedelta < now - dt:
            raise ValueError('Expired')
        return message_list, dt
347669
private static void initJava8SunDefaultEnabledCipherSuites(Map<String, SslCipher> ciphers,
                                                 Map<String, SslCipher> ciphersByNickname) {
        SslCipher cipher;

        // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
                "ECDHE-ECDSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
                "ECDHE-RSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_CBC_SHA256",
                "AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
                "ECDH-ECDSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
                "ECDH-RSA-AES256-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA384,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
                "DHE-RSA-AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
                "DHE-DSS-AES256-SHA256", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES256,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
                "ECDHE-ECDSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
                "ECDHE-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_CBC_SHA",
                "AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
                "ECDH-ECDSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
                "ECDH-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
                "DHE-RSA-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_CBC_SHA
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
                "DHE-DSS-AES256-SHA", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES256,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
                "ECDHE-ECDSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
                "ECDHE-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_CBC_SHA256",
                "AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
                "ECDH-ECDSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
                "ECDH-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
                "DHE-RSA-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
                "DHE-DSS-AES128-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
                "ECDHE-ECDSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
                "ECDHE-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);


        // TLS_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_CBC_SHA",
                "AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);


        // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
                "ECDH-ECDSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
                "ECDH-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_RSA_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
                "DHE-RSA-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_CBC_SHA
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
                "DHE-DSS-AES128-SHA", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AES128,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
                "ECDHE-ECDSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_RC4_128_SHA",
                "ECDHE-RSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("SSL_RSA_WITH_RC4_128_SHA",
                "RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
                "ECDH-ECDSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_RC4_128_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_RC4_128_SHA",
                "ECDH-RSA-RC4-SHA", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.RC4,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
                "ECDHE-ECDSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
                "ECDHE-ECDSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.AESGCM128,
                CipherMAC.SHA256,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
                "ECDHE-RSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_RSA_WITH_AES_256_GCM_SHA384",
                "AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
        // openssl doesn't have it

        // TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
        // openssl doesn't have it

        // TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
                "DHE-RSA-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
                "DHE-DSS-AES256-GCM-SHA384", 256,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AESGCM256,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
                "ECDHE-RSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_RSA_WITH_AES_128_GCM_SHA256",
                "AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
        // openssl doesn't have it

        // TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
        // openssl doesn't have it

        // TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
                "DHE-RSA-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_DHE_DSS_WITH_AES_128_GCM_SHA256
        cipher = new SslCipher("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
                "DHE-DSS-AES128-GCM-SHA256", 128,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.AESGCM128,
                CipherMAC.AEAD,
                CipherProtocolVersion.TLSV1_2,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
                "ECDHE-ECDSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.ECDSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
                "ECDHE-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDHE,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_RSA_WITH_3DES_EDE_CBC_SHA",
                "DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
                "ECDH-ECDSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_ECDSA,
                CipherAuthentication.ECDH,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
                "ECDH-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.ECDH_RSA,
                CipherAuthentication.ECDH,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.TLSV1,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
                "EDH-RSA-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.RSA,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
        cipher = new SslCipher("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
                "EDH-DSS-DES-CBC3-SHA", 168,
                CipherStrength.HIGH,
                CipherKeyExchange.DHE,
                CipherAuthentication.DSS,
                CipherEncryption.TripleDES,
                CipherMAC.SHA1,
                CipherProtocolVersion.SSLV3,
                true);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // SSL_RSA_WITH_RC4_128_MD5
        cipher = new SslCipher("SSL_RSA_WITH_RC4_128_MD5",
                "RC4-MD5", 128,
                CipherStrength.MEDIUM,
                CipherKeyExchange.RSA,
                CipherAuthentication.RSA,
                CipherEncryption.RC4,
                CipherMAC.MD5,
                CipherProtocolVersion.SSLV3,
                false);
        ciphers.putIfAbsent(cipher.name, cipher);
        ciphersByNickname.putIfAbsent(cipher.nickname, cipher);

        // TLS_EMPTY_RENEGOTIATION_INFO_SCSV
        // openssl doesn't have it
    }
931786
def _authenticate_scram_sha1(credentials, sock_info):
    """"""
    username = credentials.username
    password = credentials.password
    source = credentials.source

    # Make local
    _hmac = hmac.HMAC
    _sha1 = sha1

    user = username.encode("utf-8").replace(b"=", b"=3D").replace(b",", b"=2C")
    nonce = standard_b64encode(
        (("%s" % (SystemRandom().random(),))[2:]).encode("utf-8"))
    first_bare = b"n=" + user + b",r=" + nonce

    cmd = SON([('saslStart', 1),
               ('mechanism', 'SCRAM-SHA-1'),
               ('payload', Binary(b"n,," + first_bare)),
               ('autoAuthorize', 1)])
    res = sock_info.command(source, cmd)

    server_first = res['payload']
    parsed = _parse_scram_response(server_first)
    iterations = int(parsed[b'i'])
    salt = parsed[b's']
    rnonce = parsed[b'r']
    if not rnonce.startswith(nonce):
        raise OperationFailure("Server returned an invalid nonce.")

    without_proof = b"c=biws,r=" + rnonce
    salted_pass = _hi(_password_digest(username, password).encode("utf-8"),
                      standard_b64decode(salt),
                      iterations)
    client_key = _hmac(salted_pass, b"Client Key", _sha1).digest()
    stored_key = _sha1(client_key).digest()
    auth_msg = b",".join((first_bare, server_first, without_proof))
    client_sig = _hmac(stored_key, auth_msg, _sha1).digest()
    client_proof = b"p=" + standard_b64encode(_xor(client_key, client_sig))
    client_final = b",".join((without_proof, client_proof))

    server_key = _hmac(salted_pass, b"Server Key", _sha1).digest()
    server_sig = standard_b64encode(
        _hmac(server_key, auth_msg, _sha1).digest())

    cmd = SON([('saslContinue', 1),
               ('conversationId', res['conversationId']),
               ('payload', Binary(client_final))])
    res = sock_info.command(source, cmd)

    parsed = _parse_scram_response(res['payload'])
    if not compare_digest(parsed[b'v'], server_sig):
        raise OperationFailure("Server returned an invalid signature.")

    # Depending on how it's configured, Cyrus SASL (which the server uses)
    # requires a third empty challenge.
    if not res['done']:
        cmd = SON([('saslContinue', 1),
                   ('conversationId', res['conversationId']),
                   ('payload', Binary(b''))])
        res = sock_info.command(source, cmd)
        if not res['done']:
            raise OperationFailure('SASL conversation failed to complete.')
64980
def authenticationAndCipheringReject():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x14)  # 00010100
    packet = a / b
    return packet
454005
def _tls_auth_encrypt(self, s):
        
        wcs = self.tls_session.wcs
        write_seq_num = struct.pack("!Q", wcs.seq_num)
        wcs.seq_num += 1
        return wcs.cipher.auth_encrypt(s, b"", write_seq_num)
1166948
def _tls_compress(alg, p):
    
    c = TLSCompressed()
    c.type = p.type
    c.version = p.version
    c.data = alg.compress(p.data)
    c.len = len(c.data)
    return c
254258
def setup_cipher
      raise RLPxSessionError, 'missing responder nonce' unless @responder_nonce
      raise RLPxSessionError, 'missing initiator_nonce' unless @initiator_nonce
      raise RLPxSessionError, 'missing auth_init' unless @auth_init
      raise RLPxSessionError, 'missing auth_ack' unless @auth_ack
      raise RLPxSessionError, 'missing remote ephemeral pubkey' unless @remote_ephemeral_pubkey
      raise InvalidKeyError, 'invalid remote ephemeral pubkey' unless Crypto::ECCx.valid_key?(@remote_ephemeral_pubkey)

      # derive base secrets from ephemeral key agreement
      # ecdhe-shared-secret = ecdh.agree(ephemeral-privkey, remote-ephemeral-pubk)
      @ecdhe_shared_secret = @ephemeral_ecc.get_ecdh_key(@remote_ephemeral_pubkey)
      @shared_secret = Crypto.keccak256("#{@ecdhe_shared_secret}#{Crypto.keccak256(@responder_nonce + @initiator_nonce)}")
      @token = Crypto.keccak256 @shared_secret
      @aes_secret = Crypto.keccak256 "#{@ecdhe_shared_secret}#{@shared_secret}"
      @mac_secret = Crypto.keccak256 "#{@ecdhe_shared_secret}#{@aes_secret}"

      mac1 = keccak256 "#{Utils.sxor(@mac_secret, @responder_nonce)}#{@auth_init}"
      mac2 = keccak256 "#{Utils.sxor(@mac_secret, @initiator_nonce)}#{@auth_ack}"

      if initiator?
        @egress_mac, @ingress_mac = mac1, mac2
      else
        @egress_mac, @ingress_mac = mac2, mac1
      end

      iv = "\x00" * 16
      @aes_enc = OpenSSL::Cipher.new(ENC_CIPHER).tap do |c|
        c.encrypt
        c.iv = iv
        c.key = @aes_secret
      end
      @aes_dec = OpenSSL::Cipher.new(ENC_CIPHER).tap do |c|
        c.decrypt
        c.iv = iv
        c.key = @aes_secret
      end
      @mac_enc = OpenSSL::Cipher.new(MAC_CIPHER).tap do |c|
        c.encrypt
        c.key = @mac_secret
      end

      @ready = true
    end
47314
function blockEncrypt(input, inOffset, sessionKey) {

        if (input &&
          sessionKey &&
          utils.isAnArray(sessionKey) &&
          utils.isAnArray(input)) {

          input = new Uint8Array(input);
          var sBox = sessionKey[0]
            , sKey = sessionKey[1]

            /*eslint-disable no-plusplus*/
            , x0 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x1 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x2 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x3 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24
            /*eslint-enable no-plusplus*/

            , t0
            , t1
            , k = ROUND_SUBKEYS
            , R = 0;

          x0 ^= sKey[INPUT_WHITEN];
          x1 ^= sKey[INPUT_WHITEN + 1];
          x2 ^= sKey[INPUT_WHITEN + 2];
          x3 ^= sKey[INPUT_WHITEN + 3];
          for (R = 0; R < ROUNDS; R += 2) {

            t0 = fe32(sBox, x0, 0);
            t1 = fe32(sBox, x1, 3);
            /*eslint-disable no-plusplus*/
            x2 ^= t0 + t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
            x2 = x2 >>> 1 | x2 << 31;
            x3 = x3 << 1 | x3 >>> 31;
            /*eslint-disable no-plusplus*/
            x3 ^= t0 + 2 * t1 + sKey[k++];
            /*eslint-enable no-plusplus*/

            t0 = fe32(sBox, x2, 0);
            t1 = fe32(sBox, x3, 3);
            /*eslint-disable no-plusplus*/
            x0 ^= t0 + t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
            x0 = x0 >>> 1 | x0 << 31;
            x1 = x1 << 1 | x1 >>> 31;
            /*eslint-disable no-plusplus*/
            x1 ^= t0 + 2 * t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
          }

          x2 ^= sKey[OUTPUT_WHITEN];
          x3 ^= sKey[OUTPUT_WHITEN + 1];
          x0 ^= sKey[OUTPUT_WHITEN + 2];
          x1 ^= sKey[OUTPUT_WHITEN + 3];

          return new Uint8Array([x2, x2 >>> 8, x2 >>> 16, x2 >>> 24,
             x3, x3 >>> 8, x3 >>> 16, x3 >>> 24,
             x0, x0 >>> 8, x0 >>> 16, x0 >>> 24,
             x1, x1 >>> 8, x1 >>> 16, x1 >>> 24]);
        }

        throw 'input block is not an array or sessionKey is incorrect';
      }
1326318
def _init_server_authentication(self, ssl_verify: OpenSslVerifyEnum, ssl_verify_locations: Optional[str]) -> None:
        
        self._ssl_ctx.set_verify(ssl_verify.value)
        if ssl_verify_locations:
            # Ensure the file exists
            with open(ssl_verify_locations):
                pass
            self._ssl_ctx.load_verify_locations(ssl_verify_locations)
1323816
def tls_session_update(self, msg_str):
        
        super(TLSClientHello, self).tls_session_update(msg_str)

        self.tls_session.advertised_tls_version = self.version
        self.random_bytes = msg_str[10:38]
        self.tls_session.client_random = (struct.pack('!I',
                                                      self.gmt_unix_time) +
                                          self.random_bytes)
        if self.ext:
            for e in self.ext:
                if isinstance(e, TLS_Ext_SupportedVersions):
                    if self.tls_session.tls13_early_secret is None:
                        # this is not recomputed if there was a TLS 1.3 HRR
                        self.tls_session.compute_tls13_early_secrets()
                    break
113952
def sanitize_ssl(self):
        """"""
        if self["sslverify"] is True:
            try:
                self["sslverify"] = get_system_cert_file()
            except ValueError:
                try:
                    self["sslverify"] = get_certifi_file()
                except (ValueError, ImportError):
                    try:
                        self["sslverify"] = get_share_file('cacert.pem')
                    except ValueError:
                        pass