`data` <string> the data to verify.
        `signature` <string> The signature, if detached from the data.
        `keyrings` <list of string> Additional keyrings to search in.
        `homedir` <string> Override the configured homedir.
969649
def verify(self, data, signature=None, keyrings=None, homedir=None):
        '''
        
        '''

        if isinstance(data, six.text_type):
            data = data.encode('utf-8')

        tmpdir = tempfile.mkdtemp()
        data_file, data_path = tempfile.mkstemp(dir=tmpdir)
        data_file = os.fdopen(data_file, 'wb')
        data_file.write(data)
        data_file.close()
        if signature:
            sig_file, sig_path = tempfile.mkstemp(dir=tmpdir)
            sig_file = os.fdopen(sig_file, 'wb')
            sig_file.write(signature)
            sig_file.close()
        else:
            sig_path = None
        try:
            return self.verify_from_file(
                data_path,
                sig_path=sig_path,
                keyrings=keyrings,
                homedir=homedir
            )
        finally:
            shutil.rmtree(tmpdir)
823094
def verify(data, sig)
      regenerate_pubkey unless @key.public_key
      sig = Bitcoin::OpenSSL_EC.repack_der_signature(sig)
      if sig
        @key.dsa_verify_asn1(data, sig)
      else
        false
      end
    end
218239
def sign(data)
      sig = @key.dsa_sign_asn1(data)
      if Script::is_low_der_signature?(sig)
        sig
      else
        Bitcoin::OpenSSL_EC.signature_to_low_s(sig)
      end
    end
318925
def sign(self, data: bytes, v: int = 27) -> Signature:
        
        assert v in (0, 27), 'Raiden is only signing messages with v in (0, 27)'
        _hash = eth_sign_sha3(data)
        signature = self.private_key.sign_msg_hash(message_hash=_hash)
        sig_bytes = signature.to_bytes()
        # adjust last byte to v
        return sig_bytes[:-1] + bytes([sig_bytes[-1] + v])
1142698
def gen_keys_signature(self, priv, pub, signature_path, auto_create=False, keysize=None):
        '''
        
        '''
        # check given pub-key
        if pub:
            if not os.path.isfile(pub):
                return 'Public-key {0} does not exist'.format(pub)
        # default to master.pub
        else:
            mpub = self.opts['pki_dir'] + '/' + 'master.pub'
            if os.path.isfile(mpub):
                pub = mpub

        # check given priv-key
        if priv:
            if not os.path.isfile(priv):
                return 'Private-key {0} does not exist'.format(priv)
        # default to master_sign.pem
        else:
            mpriv = self.opts['pki_dir'] + '/' + 'master_sign.pem'
            if os.path.isfile(mpriv):
                priv = mpriv

        if not priv:
            if auto_create:
                log.debug(
                    'Generating new signing key-pair .%s.* in %s',
                    self.opts['master_sign_key_name'], self.opts['pki_dir']
                )
                salt.crypt.gen_keys(self.opts['pki_dir'],
                                    self.opts['master_sign_key_name'],
                                    keysize or self.opts['keysize'],
                                    self.opts.get('user'),
                                    self.passphrase)

                priv = self.opts['pki_dir'] + '/' + self.opts['master_sign_key_name'] + '.pem'
            else:
                return 'No usable private-key found'

        if not pub:
            return 'No usable public-key found'

        log.debug('Using public-key %s', pub)
        log.debug('Using private-key %s', priv)

        if signature_path:
            if not os.path.isdir(signature_path):
                log.debug('target directory %s does not exist', signature_path)
        else:
            signature_path = self.opts['pki_dir']

        sign_path = signature_path + '/' + self.opts['master_pubkey_signature']

        skey = get_key(self.opts)
        return skey.gen_signature(priv, pub, sign_path)
1303403
def data(self):
        
        # Check if signatire is detached
        if self.detached:
            return None
        bio = Membio()
        if not libcrypto.CMS_verify(self.ptr, None, None, None, bio.bio,
                                    Flags.NO_VERIFY):
            raise CMSError("extract data")
        return str(bio)
578287
def _default_data(self, *args, **kwargs):
        
        data = super(Trading, self)._default_data(*args, **kwargs)
        data['key'] = self.key
        nonce = self.get_nonce()
        msg = str(nonce) + self.username + self.key

        signature = hmac.new(
            self.secret.encode('utf-8'), msg=msg.encode('utf-8'),
            digestmod=hashlib.sha256).hexdigest().upper()
        data['signature'] = signature
        data['nonce'] = nonce
        return data
325872
def signatures(transaction, names: [:primary])
      transaction.inputs.map do |input|
        path = input.output.metadata[:wallet_path]
        node = self.path(path)
        sig_hash = transaction.sig_hash(input, node.script)
        node.signatures(sig_hash, names: names)
      end
    end
489058
def sign_raw_data(raw_data, privatekey_hex):
    
    if not isinstance(raw_data, (str, unicode)):
        raise ValueError("Data is not a string")

    raw_data = str(raw_data)

    si = ECSigner(privatekey_hex)
    si.update(raw_data)
    return si.finalize()
247779
function signature(m) {
    return m.get(f.signature)
            .orElse(_ => m.get(f.name))
            .getOrElse('(Anonymous)');
  }
1008186
def gen_signature(data)
      raise ArgumentError unless data

      sig = @priv_key.sign(@digest, data)
      base64sig = Base64.strict_encode64(sig)

      return HTTP_SIGNATURE % [user_path, @fingerprint, @digest_name, base64sig]
    end
1107986
def signature_base_string(request, token = nil, request_options = {})
      request.signature_base_string(http, self, token, options.merge(request_options))
    end
122001
def hmac_signature(string, shared_secret, challenge_hmac):
    '''
    
    '''
    msg = salt.utils.stringutils.to_bytes(string)
    key = salt.utils.stringutils.to_bytes(shared_secret)
    challenge = salt.utils.stringutils.to_bytes(challenge_hmac)
    hmac_hash = hmac.new(key, msg, hashlib.sha256)
    valid_hmac = base64.b64encode(hmac_hash.digest())
    return valid_hmac == challenge
929092
def _data_to_sign(self) -> bytes:
        
        packed = self.packed()

        field = type(packed).fields_spec[-1]
        assert field.name == 'signature', 'signature is not the last field'

        # this slice must be from the end of the buffer
        return packed.data[:-field.size_bytes]
1241570
def sign(self, data):
        
        if self.signing_key is None:
            raise MissingSigningKeyError("KeyPair does not contain secret key. "
                                         "Use Keypair.from_seed method to create a new keypair with a secret key.")
        return self.signing_key.sign(data)
694354
def signature_info
      @signature_info ||= begin
        match = x_mws_authentication && x_mws_authentication.match(/\A([^ ]+) *([^:]+):([^:]+)\z/)
        match ? { token: match[1], app_uuid: match[2], signature: match[3] } : {}
      end
    end
706835
def derive_signature(key, qs):
    """"""
    key, qs = (key or "", qs or "")
    return hmac.new(key.encode(), qs.encode(), hashlib.sha1).hexdigest()