Return message given signature+message and the verifying key.
961745
def crypto_sign_open(signed, vk):
    """"""
    if len(vk) != PUBLICKEYBYTES:
        raise ValueError("Bad verifying key length %d" % len(vk))
    rc = djbec.checkvalid(signed[:SIGNATUREBYTES], signed[SIGNATUREBYTES:], vk)
    if not rc:
        raise ValueError("rc != True", rc)
    return signed[SIGNATUREBYTES:]
1364766
def signature_validate(signature, error = None) :
    ""
    error, my_error = _get_error(error)
    result = dbus.dbus_signature_validate(signature.encode(), error._dbobj) != 0
    my_error.raise_if_set()
    return \
        result
129208
def sign(self, msg, key):
        
        h = hmac.HMAC(key, self.algorithm(), default_backend())
        h.update(msg)
        return h.finalize()
635470
def check_signature(signature, key, data):
    """"""
    if isinstance(key, type(u'')):
        key = key.encode()

    digest = 'sha1=' + hmac.new(key, data, hashlib.sha1).hexdigest()

    # Covert everything to byte sequences
    if isinstance(digest, type(u'')):
        digest = digest.encode()
    if isinstance(signature, type(u'')):
        signature = signature.encode()

    return werkzeug.security.safe_str_cmp(digest, signature)
521987
function checksig(msg, sig, key) {
  return secp256k1.verify(msg, sig.slice(0, -1), key);
}
108217
def sign(self):
        """"""
        self.verify_integrity()
        
        if session.get('u2f_sign_required', False):
            if request.method == 'GET':
                response = self.get_signature_challenge()

                if response['status'] == 'ok':
                    return jsonify(response), 200
                else:
                    return jsonify(response), 404

            elif request.method == 'POST':
                response = self.verify_signature(request.json)

                if response['status'] == 'ok':
                    return jsonify(response), 201
                else:
                    return jsonify(response), 400

        return jsonify({'status': 'failed', 'error': 'Unauthorized!'}), 401
494260
function (message, signature) {
      var md = forge.md.sha1.create();
      md.update(message, 'utf8');
      try {
        return this._cert.publicKey.verify(md.digest().bytes(), forge.util.decode64(signature));
      } catch (e) {
        return false;
      }
    }
922261
def checkMessageSignature(self, message):
        
        message_sig = message.getArg(OPENID_NS, 'sig')
        if not message_sig:
            raise ValueError("%s has no sig." % (message,))
        calculated_sig = self.getMessageSignature(message)
        return cryptutil.const_eq(calculated_sig, message_sig)
111194
def sign_message(privkey_path, message, passphrase=None):
    '''
    
    '''
    key = get_rsa_key(privkey_path, passphrase)
    log.debug('salt.crypt.sign_message: Signing message.')
    if HAS_M2:
        md = EVP.MessageDigest('sha1')
        md.update(salt.utils.stringutils.to_bytes(message))
        digest = md.final()
        return key.sign(digest)
    else:
        signer = PKCS1_v1_5.new(key)
        return signer.sign(SHA.new(salt.utils.stringutils.to_bytes(message)))
222490
def _build_signature(self):
        """"""
        sig_contents = \
            self.payload + "." + \
            b64encode(b"application/xml").decode("ascii") + "." + \
            b64encode(b"base64url").decode("ascii") + "." + \
            b64encode(b"RSA-SHA256").decode("ascii")
        sig_hash = SHA256.new(sig_contents.encode("ascii"))
        cipher = PKCS1_v1_5.new(self.private_key)
        sig = urlsafe_b64encode(cipher.sign(sig_hash))
        key_id = urlsafe_b64encode(bytes(self.author_handle, encoding="utf-8"))
        return sig, key_id
679589
def sign(self, msg, key):
        

        if not isinstance(key, rsa.RSAPrivateKey):
            raise TypeError(
                "The key must be an instance of rsa.RSAPrivateKey")
        sig = key.sign(msg, self.padding, self.hash)
        return sig
1118819
def sign(self, message, encoder=encoding.RawEncoder):
        
        raw_signed = libnacl.crypto_sign(message, self._signing_key)

        signature = encoder.encode(raw_signed[:libnacl.crypto_sign_BYTES])
        message = encoder.encode(raw_signed[libnacl.crypto_sign_BYTES:])
        signed = encoder.encode(raw_signed)

        return SignedMessage._from_parts(signature, message, signed)
357654
def check(self, request, consumer, token, signature):
        """"""
        built = self.sign(request, consumer, token)
        return built == signature
757163
def verify_signature(message, signature, address):
    
    if (len(signature) != SIGNATURE_LENGTH):
        return False

    try:
        binsig = base64.b64decode(signature)
    except:
        return False

    r = intbytes.from_bytes(binsig[1:33])

    s = intbytes.from_bytes(binsig[33:65])

    val = intbytes.from_bytes(bitcoin_sig_hash(message.encode()))

    pubpairs = possible_public_pairs_for_signature(
        generator_secp256k1,
        val,
        (r, s))

    addr_hash160 = bitcoin_address_to_hash160_sec(address)

    for pair in pubpairs:
        if (public_pair_to_hash160_sec(pair, True) == addr_hash160):
            return True
        if (public_pair_to_hash160_sec(pair, False) == addr_hash160):
            return True

    return False
866351
def wrap(self, message):
        
        cipher_text = _Ntlm2Session.encrypt(self, message)
        signature = _Ntlm2Session.sign(self, message)
        return cipher_text, signature
1367488
def verify_message(self, message):
        """"""
        if verify_checksum(
                message,
                self.in_checksum.get(message.id, 0),
        ):
            self.in_checksum[message.id] = message.checksum[1]

            if message.flags == FlagsType.none:
                self.in_checksum.pop(message.id)
        else:
            self.in_checksum.pop(message.id, None)
            raise InvalidChecksumError(
                description="Checksum does not match!",
                id=message.id,
            )
521845
def verify(self, digest, signature, **kwargs):
        
        ctx = libcrypto.EVP_PKEY_CTX_new(self.key, None)
        if ctx is None:
            raise PKeyError("Initailizing verify context")
        if libcrypto.EVP_PKEY_verify_init(ctx) < 1:
            raise PKeyError("verify_init")
        self._configure_context(ctx, kwargs)
        ret = libcrypto.EVP_PKEY_verify(ctx, signature, len(signature), digest,
                                        len(digest))
        if ret < 0:
            raise PKeyError("Signature verification")
        libcrypto.EVP_PKEY_CTX_free(ctx)
        return ret > 0