Check if the cryptography library is present, and if it supports X25519,
    ChaCha20Poly1305 and such (v2.0 or later).
965385
def isCryptographyAdvanced():
    
    try:
        from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey  # noqa: E501
        X25519PrivateKey.generate()
    except Exception:
        return False
    else:
        return True
543870
def _fulfills_version_spec(versions, oper, desired_version,
                           ignore_epoch=False):
    '''
    
    '''
    cmp_func = __salt__.get('pkg.version_cmp')
    # stripping "with_origin" dict wrapper
    if salt.utils.platform.is_freebsd():
        if isinstance(versions, dict) and 'version' in versions:
            versions = versions['version']
    for ver in versions:
        if (oper == '==' and fnmatch.fnmatch(ver, desired_version)) \
                or salt.utils.versions.compare(ver1=ver,
                                               oper=oper,
                                               ver2=desired_version,
                                               cmp_func=cmp_func,
                                               ignore_epoch=ignore_epoch):
            return True
    return False
82741
private void check(CryptoMode cryptoMode) {
        // For modes that use AES/GCM, we prefer using the BouncyCastle provider unless the
        // user has explicitly overridden us (i.e., with the FIPS-compliant BouncyCastle
        // implementation).
        boolean preferBC = (cryptoMode == CryptoMode.AuthenticatedEncryption)
                           || (cryptoMode == CryptoMode.StrictAuthenticatedEncryption);

        boolean haveOverride = (cryptoProvider != null && alwaysUseCryptoProvider);

        if (preferBC && !haveOverride) {
            if (!CryptoRuntime.isBouncyCastleAvailable()) {
                CryptoRuntime.enableBouncyCastle();
                if (!CryptoRuntime.isBouncyCastleAvailable()) {
                    throw new UnsupportedOperationException(
                        "The Bouncy castle library jar is required on the classpath to enable authenticated encryption");
                }
            }
            if (!CryptoRuntime.isAesGcmAvailable())
                throw new UnsupportedOperationException(
                    "More recent version of the Bouncy castle library is required to enable authenticated encryption");
        }
    }
1189689
def scrypt_mcf_check(mcf, password):
    """"""
    if isinstance(password, unicode):
        password = password.encode('utf8')
    elif not isinstance(password, bytes):
        raise TypeError('password must be a unicode or byte string')
    if not isinstance(mcf, bytes):
        raise TypeError('MCF must be a byte string')
    if mcf_mod._scrypt_mcf_7_is_standard(mcf) and not _scrypt_ll:
        return _scrypt_str_chk(mcf, password, len(password)) == 0
    return mcf_mod.scrypt_mcf_check(scrypt, mcf, password)
14050
def is_pkcs12(data):
    
    if isinstance(data, bytes):
        tlv = Tlv(data)
        if tlv.tag == 0x30:
            header = Tlv(tlv.value)
            return header.tag == 0x02 and header.value == b'\x03'
        return False
    else:
        return False
378722
def btc_is_p2pkh_address( address ):
    
    vb = keylib.b58check.b58check_version_byte( address )
    if vb == version_byte:
        return True
    else:
        return False
504947
private function checkKey()
    {
        $keyResource = openssl_get_publickey($this->secretKey);
        $details = openssl_pkey_get_details($keyResource);

        if (!isset($details["key"]) || $details["type"] !== OPENSSL_KEYTYPE_RSA) {
             throw new AppException("Provided Secret Key is invalid");
        }
    }
614357
def _verify_sig(self, m, cert):
        
        if self.sig_val:
            if self.sig_alg:
                h, sig = _tls_hash_sig[self.sig_alg].split('+')
                if sig.endswith('pss'):
                    t = "pss"
                else:
                    t = "pkcs"
                return cert.verify(m, self.sig_val, t=t, h=h)
            else:
                if self.tls_session.tls_version >= 0x0300:
                    return cert.verify(m, self.sig_val, t='pkcs', h='md5-sha1')
                else:
                    return cert.verify(m, self.sig_val, t='pkcs', h='md5')
        return False
220363
public void checkKeyStore() {
        if (sslContext != null)
            return; //nothing to check if using preconfigured context
        
        if (keyStoreInputStream == null &&
	    sslConfig.getKeyStorePath() == null) {
            throw new IllegalStateException("SSL doesn't have a valid keystore");
        }
        // if the keystore has been configured but there is no
        // truststore configured, use the keystore as the truststore
        if (trustStoreInputStream == null && sslConfig.getTrustStorePath() == null) {
            trustStoreInputStream = keyStoreInputStream;
            sslConfig.setTrustStorePath(sslConfig.getKeyStorePath());
            sslConfig.setTrustStoreType(sslConfig.getKeyStoreType());
            sslConfig.setTrustStoreProvider(sslConfig.getKeyStoreProvider());
            sslConfig.setTrustStorePassword(sslConfig.getKeyStorePassword());
            sslConfig.setTrustManagerFactoryAlgorithm(sslConfig.getKeyManagerFactoryAlgorithm());
        }

        // It's the same stream we cannot read it twice, so read it once in memory
        if (keyStoreInputStream != null && keyStoreInputStream == trustStoreInputStream) {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
		streamCopy(keyStoreInputStream, baos, null, false);
                keyStoreInputStream.close();
                keyStoreInputStream = new ByteArrayInputStream(baos.toByteArray());
                trustStoreInputStream = new ByteArrayInputStream(baos.toByteArray());
            } catch (Exception ex) {
                throw new IllegalStateException(ex);
            }
        }
    }
757132
def verify_gpg_version():
    """"""
    existing_gpg = keyring.gpg_version().decode('ascii')
    required_gpg = '>=2.1.11'
    msg = 'Existing GnuPG has version "{}" ({} required)'.format(existing_gpg,
                                                                 required_gpg)
    if not semver.match(existing_gpg, required_gpg):
        log.error(msg)
224410
def crypto_validator(func):
    
    def func_in(*args, **kwargs):
        if not conf.crypto_valid:
            raise ImportError("Cannot execute crypto-related method! "
                              "Please install python-cryptography v1.7 or later.")  # noqa: E501
        return func(*args, **kwargs)
    return func_in
680358
def _check_version():
    """"""
    from ._config import APP_NAME

    if VersionCache.load(APP_NAME).is_fresh:
        return

    from pkg_resources import parse_version
    from renku.version import __version__

    version = parse_version(__version__)
    allow_prereleases = version.is_prerelease

    latest_version = find_latest_version(
        'renku', allow_prereleases=allow_prereleases
    )

    if version < latest_version:
        click.secho(
            'You are using renku version {version}, however version '
            '{latest_version} is available.\n'
            'You should consider upgrading ...'.format(
                version=__version__,
                latest_version=latest_version,
            ),
            fg='yellow',
            bold=True,
        )

    VersionCache(pypi_version=str(latest_version)).dump(APP_NAME)
45932
def should_check_ciphersuites(self):
        
        if isinstance(self.mykey, PrivKeyRSA):
            kx = "RSA"
        elif isinstance(self.mykey, PrivKeyECDSA):
            kx = "ECDSA"
        if get_usable_ciphersuites(self.cur_pkt.ciphers, kx):
            return
        raise self.NO_USABLE_CIPHERSUITE()
217417
def has_library_value(self, key: str) -> bool:
        
        desc = Metadata.session_key_map.get(key)
        if desc is not None:
            field_id = desc['path'][-1]
            return bool(getattr(ApplicationData.get_session_metadata_model(), field_id, None))
        return False
864235
function (xpcKey) {
    if ($bc_$5.pN) {
      try {
        return $bc_$5.pN.app.hasXPCService(xpcKey || 'default')
      } catch (e) {
        console.error(e);
      }
    }

    return false
  }
833583
def is_supported():
    '''
    
    '''
    # Check for supported platforms
    # NOTE: ZFS on Windows is in development
    # NOTE: ZFS on NetBSD is in development
    on_supported_platform = False
    if salt.utils.platform.is_sunos():
        on_supported_platform = True
    elif salt.utils.platform.is_freebsd() and _check_retcode('kldstat -q -m zfs'):
        on_supported_platform = True
    elif salt.utils.platform.is_linux() and os.path.exists('/sys/module/zfs'):
        on_supported_platform = True
    elif salt.utils.platform.is_linux() and salt.utils.path.which('zfs-fuse'):
        on_supported_platform = True
    elif salt.utils.platform.is_darwin() and \
         os.path.exists('/Library/Extensions/zfs.kext') and \
         os.path.exists('/dev/zfs'):
        on_supported_platform = True

    # Additional check for the zpool command
    return (salt.utils.path.which('zpool') and on_supported_platform) is True
951719
def warn_if_insecure_platform():
    
    m = (
        "\n"
        "######################################################################################\n"  # noqa
        "#                                                                                    #\n"  # noqa
        "#  Your version of Python appears to be out of date and lack important security      #\n"  # noqa
        "#  features. Please update to Python >= 2.7.9 or `pip install requests[security]`.   #\n"  # noqa
        "#                                                                                    #\n"  # noqa
        "#  InsecurePlatformWarning: A true SSLContext object is not available. This          #\n"  # noqa
        "#  prevents urllib3 from configuring SSL appropriately and may cause certain         #\n"  # noqa
        "#  SSL connections to fail. For more information, see                                #\n"  # noqa
        "#  https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.  #\n"  # noqa
        "#                                                                                    #\n"  # noqa
        "######################################################################################\n"
    )  # noqa
    if is_insecure_platform():
        click.echo(m, err=True)
        return True
    else:
        cli_log.debug("Python SSLContext passed")
        return False