Creates signature for message using specified signer

        :param msg: message to sign
        :param identifier: signer identifier
        :param otherIdentifier:
        :return: signature that then can be assigned to request
181470
def signMsg(self,
                msg: Dict,
                identifier: Identifier=None,
                otherIdentifier: Identifier=None):
        
        idr = self.requiredIdr(idr=identifier or otherIdentifier)
        signer = self._signerById(idr)
        signature = signer.sign(msg)
        return signature
1052323
def wrap(self, message):
        
        cipher_text = _Ntlm1Session.encrypt(self, message)
        signature = _Ntlm1Session.sign(self, message)
        return cipher_text, signature
997670
def RegisterMessage(self, message):
    

    desc = message.DESCRIPTOR
    self._classes[desc.full_name] = message
    self.pool.AddDescriptor(desc)
    return message
1014144
protected JwtSigner createSigner(SignatureAlgorithm alg, Key key) {
        return new DefaultJwtSigner(alg, key, base64UrlEncoder);
    }
820193
def verifySignature(self, msg):
        
        if isinstance(msg, self.authnWhitelist):
            return
        if isinstance(msg, Propagate):
            typ = 'propagate'
            req = TxnUtilConfig.client_request_class(**msg.request)
        else:
            typ = ''
            req = msg

        key = None

        if isinstance(req, Request):
            key = req.key

        if not isinstance(req, Mapping):
            req = req.as_dict

        with self.metrics.measure_time(MetricsName.VERIFY_SIGNATURE_TIME):
            identifiers = self.authNr(req).authenticate(req, key=key)

        logger.debug("{} authenticated {} signature on {} request {}".
                     format(self, identifiers, typ, req['reqId']),
                     extra={"cli": True,
                            "tags": ["node-msg-processing"]})
680607
def sign(self, entry, signer=None):
        """"""
        if (self.get(entry) is not None):
            return
        if (entry.rrsig is None) and (self.private is not None):
            entry.rrsig = DNSSignatureS(entry.name,
                    _TYPE_RRSIG, _CLASS_IN, entry, self.private, signer)
        self.add(entry)
        if (self.private is not None):
            self.add(entry.rrsig)
878914
def onAuthenticate(self, signature, extra):
        
        log.msg("onAuthenticate: {} {}".format(signature, extra))

        ## if there is a pending auth, and the signature provided by client matches ..
        if self._pending_auth:

            if signature == self._pending_auth.signature:

                ## accept the client
                return types.Accept(authid = self._pending_auth.uid,
                    authrole = self._pending_auth.authrole,
                    authmethod = self._pending_auth.authmethod,
                    authprovider = self._pending_auth.authprovider)
            else:

                ## deny client
                return types.Deny(message = u"signature is invalid")
        else:

            ## deny client
            return types.Deny(message = u"no pending authentication")
184342
public RequestSignerRegistry register(RequestSigner requestSigner, Class<? extends RequestSigner> signerType) {
        Map<Class<? extends RequestSigner>, RequestSigner> registeredSigners = new HashMap<>();
        registeredSigners.putAll(signerForType);
        registeredSigners.put(signerType, requestSigner);
        return new RequestSignerRegistry(registeredSigners);
    }
714929
def sign(message, gpg_home=None, gpg_signing_key=None, **config):
    

    if gpg_home is None or gpg_signing_key is None:
        raise ValueError("You must set the gpg_home \
                         and gpg_signing_key keyword arguments.")

    message['crypto'] = 'gpg'

    signature = _ctx.sign(
        fedmsg.encoding.dumps(message['msg']),
        gpg_signing_key,
        homedir=gpg_home
    )
    return dict(list(message.items()) + [('signature', b64encode(signature))])
1176028
def sign_message(self, key, message, verbose=False):
        
        secret_exponent = key.secret_exponent()
        if not secret_exponent:
            raise ValueError("Private key is required to sign a message")

        addr = key.address()

        msg_hash = self.hash_for_signing(message)
        is_compressed = key.is_compressed()

        sig = self.signature_for_message_hash(secret_exponent, msg_hash, is_compressed)

        if not verbose or message is None:
            return sig

        return self.signature_template.format(
            msg=message, sig=sig, addr=addr,
            net_name=self._network_name.upper())
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)
1165667
def create_agent_signer(user_id):
    """"""
    sock = connect_to_agent(env=os.environ)
    keygrip = get_keygrip(user_id)

    def sign(digest):
        """Sign the digest and return an ECDSA/RSA/DSA signature."""
        return sign_digest(sock=sock, keygrip=keygrip, digest=digest)

    return sign
1301572
def _messageFromSender(self, sender, messageID):
        
        return self.store.findUnique(
            _QueuedMessage,
            AND(_QueuedMessage.senderUsername == sender.localpart,
                _QueuedMessage.senderDomain == sender.domain,
                _QueuedMessage.messageID == messageID),
            default=None)
777785
def _bot_identifier(self, message):
        

        text = message['text']

        formatters = [
            lambda identifier: "%s " % identifier,
            lambda identifier: "%s:" % identifier,
        ]
        my_identifiers = [formatter(identifier) for identifier in [self.name, self.my_mention] for formatter in formatters]

        for identifier in my_identifiers:
            if text.startswith(identifier):
                self.log.debug("sent to me:\n%s", pprint.pformat(message))
                return identifier

        return None
1167825
def crypto_sign(msg, sk):
    """"""
    if len(sk) != SECRETKEYBYTES:
        raise ValueError("Bad signing key length %d" % len(sk))
    vkbytes = sk[PUBLICKEYBYTES:]
    skbytes = sk[:PUBLICKEYBYTES]
    sig = djbec.signature(msg, skbytes, vkbytes)
    return sig + msg
886881
def build_signature(self, user_api_key, user_secret, request):
        """"""
        path = request.get_full_path()
        sent_signature = request.META.get(
            self.header_canonical('Authorization'))
        signature_headers = self.get_headers_from_signature(sent_signature)
        unsigned = self.build_dict_to_sign(request, signature_headers)

        # Sign string and compare.
        signer = HeaderSigner(
            key_id=user_api_key, secret=user_secret,
            headers=signature_headers, algorithm=self.ALGORITHM)
        signed = signer.sign(unsigned, method=request.method, path=path)
        return signed['authorization']
1190094
def sign_message(body: ByteString, secret: Text) -> Text:
    

    return 'sha1={}'.format(
        hmac.new(secret.encode(), body, sha1).hexdigest()
    )