Determine whether a KDFSuite can be used with this EncryptionSuite.

        :param kdf: KDFSuite to evaluate
        :type kdf: aws_encryption_sdk.identifiers.KDFSuite
        :rtype: bool
438044
def valid_kdf(self, kdf):
        
        if kdf.input_length is None:
            return True

        if self.data_key_length > kdf.input_length(self):
            raise InvalidAlgorithmError(
                "Invalid Algorithm definition: data_key_len must not be greater than kdf_input_len"
            )

        return True
1337873
def is_valid(identifier):
    

    return (
        isinstance(identifier, six.string_types)
        and bool(NAME_RE.search(identifier))
        and not keyword.iskeyword(identifier)
    )
273334
def is_secure_option(self, section, option):
        
        if not self.has_section(section):
            return False
        if not self.has_option(section, option):
            return False
        if ConfigParser.get(self, section, option) == self._secure_placeholder:
            return True
        return False
335793
def are_credentials_still_valid(awsclient):
    
    client = awsclient.get_client('lambda')
    try:
        client.list_functions()
    except GracefulExit:
        raise
    except Exception as e:
        log.debug(e)
        log.error(e)
        return 1
    return 0
703538
def parse_identitie(self, global_params, region, identity_name):
        
        identity = {'name': identity_name, 'policies': {}}
        policy_names = api_clients[region].list_identity_policies(Identity = identity_name)['PolicyNames']
        if len(policy_names):
            policies = api_clients[region].get_identity_policies(Identity = identity_name, PolicyNames = policy_names)['Policies']
            for policy_name in policies:
                identity['policies'][policy_name] = json.loads(policies[policy_name])
        dkim = api_clients[region].get_identity_dkim_attributes(Identities = [ identity_name ])['DkimAttributes'][identity_name]
        identity['DkimEnabled'] = dkim['DkimEnabled']
        identity['DkimVerificationStatus'] = dkim['DkimVerificationStatus']
        self.identities[self.get_non_aws_id(identity_name)] = identity
835499
def should_add_ServerHello(self):
        
        if isinstance(self.mykey, PrivKeyRSA):
            kx = "RSA"
        elif isinstance(self.mykey, PrivKeyECDSA):
            kx = "ECDSA"
        usable_suites = get_usable_ciphersuites(self.cur_pkt.ciphers, kx)
        c = usable_suites[0]
        if self.preferred_ciphersuite in usable_suites:
            c = self.preferred_ciphersuite
        self.add_msg(TLSServerHello(cipher=c))
        raise self.ADDED_SERVERHELLO()
523870
def signature_type(self):
        
        if not self.mardata.signatures:
            return None

        for sig in self.mardata.signatures.sigs:
            if sig.algorithm_id == 1:
                return 'sha1'
            elif sig.algorithm_id == 2:
                return 'sha384'
        else:
            return 'unknown'
153661
def identifier(self):
        
        if len(self.polygons_full) != 1:
            raise TypeError('Identifier only valid for single body')
        return polygons.polygon_hash(self.polygons_full[0])
751568
def _identifier_as_cid(self, identifier):
        
        def __cname_matches(container, identifier):
            return any([n for n in (container['Names'] or [])
                        if matches(n, '/' + identifier)])

        # Determine if identifier is a container
        containers = [c['Id'] for c in self.client.containers(all=True)
                      if (__cname_matches(c, identifier) or
                          matches(c['Id'], identifier + '*'))]

        if len(containers) > 1:
            raise SelectionMatchError(identifier, containers)
        elif len(containers) == 1:
            c = containers[0]
            return self._clone(c)

        # Determine if identifier is an image UUID
        images = [i for i in set(self.client.images(all=True, quiet=True))
                  if i.startswith(identifier)]

        if len(images) > 1:
            raise SelectionMatchError(identifier, images)
        elif len(images) == 1:
            return self._create_temp_container(images[0])

        # Match image tag.
        images = util.image_by_name(identifier)
        if len(images) > 1:
            tags = [t for i in images for t in i['RepoTags']]
            raise SelectionMatchError(identifier, tags)
        elif len(images) == 1:
            return self._create_temp_container(images[0]['Id'].replace("sha256:", ""))

        raise MountError('{} did not match any image or container.'
                         ''.format(identifier))
479786
def Verify(self, public_key):
    
    if self.digest_type != self.HashType.SHA256:
      raise rdfvalue.DecodeError("Unsupported digest.")
    if self.signature_type not in [
        self.SignatureType.RSA_PKCS1v15, self.SignatureType.RSA_PSS
    ]:
      raise rdfvalue.DecodeError("Unsupported signature type.")

    try:
      public_key.Verify(self.data, self.signature)
    except InvalidSignature as e:
      raise rdfvalue.DecodeError("Could not verify blob. Error: %s" % e)

    return True
1100619
@Override
    protected boolean shouldEncryptTokenFor(final OidcRegisteredService svc) {
        if (AlgorithmIdentifiers.NONE.equalsIgnoreCase(svc.getIdTokenEncryptionAlg())) {
            LOGGER.warn("ID token encryption algorithm is set to none for [{}] and ID token will not be encrypted", svc.getServiceId());
            return false;
        }
        return svc.isEncryptIdToken() && StringUtils.isNotBlank(svc.getIdTokenEncryptionAlg()) && StringUtils.isNotBlank(svc.getIdTokenEncryptionEncoding());
    }
403885
def verify_relayable_signature(public_key, doc, signature):
    
    sig_hash = _create_signature_hash(doc)
    cipher = PKCS1_v1_5.new(RSA.importKey(public_key))
    return cipher.verify(sig_hash, b64decode(signature))
1225580
def is_indexed(self, identifier):
        
        with self.index.searcher() as searcher:
            result = searcher.search(Term('identifier', identifier['identifier']))
            return bool(result)
1288751
def is_identifier(self, is_identifier):
        

        if is_identifier:
            self.is_editable = False

        self._is_identifier = is_identifier
991308
def valid_fits_key(key):
    

    ret = re.sub("[^A-Z0-9\-_]", "", key.upper())[:8]
    if len(ret) == 0:
        raise RuntimeError("key '{0!s}' has no valid characters to be a key in a FITS header".format(key))
    return ret
593334
def register_model(self, storagemodel:object, modeldefinition = None):
        
        if modeldefinition is None:
            
            """ test if queuename already exists """
            if [model for model in self._modeldefinitions if model['queuename'] == storagemodel._queuename]:
                raise NameConventionError(storagemodel._queuename)

            """ test if queuename fits to azure naming rules """
            if not test_azurestorage_nameconventions(storagemodel._queuename, 'StorageQueueModel'):
                raise NameConventionError(storagemodel._queuename)
             
            """ now register model """
            modeldefinition = {
                'modelname': storagemodel.__class__.__name__,
                'queuename': storagemodel._queuename,
                'encrypt': storagemodel._encrypt,
                'queueservice': self._account.create_queue_service()
                }    

            """ encrypt queue service """
            if modeldefinition['encrypt']:

                # Create the KEK used for encryption.
                # KeyWrapper is the provided sample implementation, but the user may use their own object as long as it implements the interface above.
                kek = KeyWrapper(self._key_identifier, self._secret_key) #  Key identifier

                # Create the key resolver used for decryption.
                # KeyResolver is the provided sample implementation, but the user may use whatever implementation they choose so long as the function set on the service object behaves appropriately.
                key_resolver = KeyResolver()
                key_resolver.put_key(kek)                           

                # Set the require Encryption, KEK and key resolver on the service object.
                modeldefinition['queueservice'].require_encryption = True
                modeldefinition['queueservice'].key_encryption_key = kek
                modeldefinition['queueservice'].key_resolver_funcion = key_resolver.resolve_key
            
            self.__create__(modeldefinition)
                
            self._modeldefinitions.append(modeldefinition)

            log.info('model {} registered successfully. Models are {!s}.'.format(modeldefinition['modelname'], [model['modelname'] for model in self._modeldefinitions]))
        else:
            log.info('model {} already registered. Models are {!s}.'.format(modeldefinition['modelname'], [model['modelname'] for model in self._modeldefinitions]))

        pass
219723
def set_identifier(self, uid):
        

        self.uid = uid

        self.set_unique_metadata('DC', 'identifier', self.uid, {'id': self.IDENTIFIER_ID})