Generate a DKIM signature.
@access public
@param string $signHeader
@throws phpmailerException
@return string
189841
public function DKIM_Sign($signHeader)
    {
        if (!defined('PKCS7_TEXT')) {
            if ($this->exceptions) {
                throw new Mail\MailerException($this->lang('signing') . ' OpenSSL extension missing.');
            }
            return '';
        }
        $privKeyStr = file_get_contents($this->DKIM_private);
        if ($this->DKIM_passphrase != '') {
            $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
        } else {
            $privKey = $privKeyStr;
        }
        if (openssl_sign($signHeader, $signature, $privKey)) {
            return base64_encode($signature);
        }
        return '';
    }
579276
private function generateRequestHeaders($signedMessage)
    {
        // Prepare request Http Headers
        $requestHeaders = [
            CurlRequestHandler::YOTI_AUTH_HEADER_KEY . ": {$this->authKey}",
            CurlRequestHandler::YOTI_DIGEST_HEADER_KEY . ": {$signedMessage}",
            CurlRequestHandler::YOTI_SDK_IDENTIFIER_KEY . ": {$this->sdkIdentifier}",
            'Content-Type: application/json',
            'Accept: application/json',
        ];

        if ($version = Config::getInstance()->get('version')) {
            $requestHeaders[] = self::YOTI_SDK_VERSION . ": {$this->sdkIdentifier}-{$version}";
        }
        return $requestHeaders;
    }
949368
private function generateSignature(DOMElement $signedInfoNode)
    {
        $signature = null;

        if (!openssl_sign(
            $signedInfoNode->C14N(true),
            $signature,
            $this->getPrivateKeyResource(),
            OPENSSL_ALGO_SHA1
        )
        ) {
            throw new \Exception('Unable to sign the request');
        }

        return $signature;
    }
387435
private static function getSignatures($header, $scheme)
    {
        $signatures = [];
        $items = explode(",", $header);

        foreach ($items as $item) {
            $itemParts = explode("=", $item, 2);
            if ($itemParts[0] == $scheme) {
                array_push($signatures, $itemParts[1]);
            }
        }

        return $signatures;
    }
1088906
public function sign($key, $password = null)
    {
        $this->signature = $this->getSigner()->sign($this->generateSigninInput(), $key, $password);
        $this->isSigned = true;

        return $this->signature;
    }
1030643
public function packStructureHeader($length, $signature)
    {
        $stream = '';
        $packedSig = chr($signature);
        if ($length < Constants::SIZE_TINY) {
            $stream .= chr(Constants::STRUCTURE_TINY + $length);
            $stream .= $packedSig;

            return $stream;
        }

        if ($length < Constants::SIZE_MEDIUM) {
            $stream .= chr(Constants::STRUCTURE_MEDIUM);
            $stream .= $this->packUnsignedShortShort($length);
            $stream .= $packedSig;

            return $stream;
        }

        if ($length < Constants::SIZE_LARGE) {
            $stream .= chr(Constants::STRUCTURE_LARGE);
            $stream .= $this->packSignedShort($length);
            $stream .= $packedSig;

            return $stream;
        }

        throw new SerializationException(sprintf('Unable pack the size "%d" of the structure, Out of bound !', $length));
    }
1343895
private function prepareHeaders(&$signature, array $headers = []) 
    {
        $headers["X-Origin"] = self::prepareOrigin();
        $headers["X-Ukey1-App"] = $this->appId;
        $headers["X-Ukey1-Signature"] = $signature;
        
        if ($this->accessToken) {
            $headers["Authorization"] = "Bearer " . $this->accessToken;
        }
        
        return $headers;
    }
202307
private function generateEmptyDkimHeader(Message $message)
    {
        // fetch configurable params
        $configurableParams = $this->getParams();

        // check if the required params are set for singing.
        if (empty($configurableParams['d']) || empty($configurableParams['h']) || empty($configurableParams['s'])) {
            throw new \Exception('Unable to sign message: missing params');
        }

        // final params
        $params = array(
            'v'    => $configurableParams['v'],
            'a'    => $configurableParams['a'],
            'bh'   => $this->getBodyHash($message),
            'c'    => 'relaxed',
            'd'    => $configurableParams['d'],
            'h'    => $configurableParams['h'],
            's'    => $configurableParams['s'],
            'b'    => ''
        );

        $string = '';
        foreach ($params as $key => $value) {
            $string .= $key . '=' . $value . '; ';
        }

        // set empty dkim header
        $this->setEmptyDkimHeader(new Dkim(substr(trim($string),0, -1)));
    }
755051
public static function signWithPKCS15(RSAKey $key, string $message, string $hash): string
    {
        $em = self::encodeEMSA15($message, $key->getModulusLength(), Hash::$hash());
        $message = BigInteger::createFromBinaryString($em);
        $signature = RSAKey::exponentiate($key, $message);

        return self::convertIntegerToOctetString($signature, $key->getModulusLength());
    }
71788
private function makeSignedJwt($payload) {
    $header = array('typ' => 'JWT', 'alg' => 'RS256');

    $segments = array(
      Utils::urlSafeB64Encode(json_encode($header)),
      Utils::urlSafeB64Encode(json_encode($payload))
    );
    $signingInput = implode('.', $segments);

    $signer = new P12Signer($this->privateKey, $this->privateKeyPassword);
    $signature = $signer->sign($signingInput);
    $segments[] = Utils::urlSafeB64Encode($signature);

    return implode(".", $segments);
  }
150784
public function generateSignature(array $data, $hashed = true)
    {
        ksort($data);

        $content = "";
        foreach ($data as $key => $value) {
            if (substr($key, 0, 5) == 'vads_') {
                $content .= $value . '+';
            }
        }
        $content .= $this->config['certificate'];

        return $hashed ? sha1($content) : $content;
    }
636768
private function generateSignature($data)
    {
        return base64_encode(
            hash_hmac('sha512',
                $this->getMerchantId() . $data . $this->getMerchantId(),
                $this->getPrivateKey())
        );
    }
1100840
private function createSignatureDataFromHeaders(ResponseInterface $response)
    {
        $signatureData = $response->getStatusCode();
        $signatureData .= $this->convertHeadersToSignatureData($response);
        $signatureData .= "\n\n";
        $signatureData .= (string)$response->getBody();

        return $signatureData;
    }
291753
public function preSend()
    {
        try {
            $this->mailHeader = '';
            if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
                throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
            }

            // Set whether the message is multipart/alternative
            if (!empty($this->AltBody)) {
                $this->ContentType = 'multipart/alternative';
            }

            $this->error_count = 0; // reset errors
            $this->setMessageType();
            // Refuse to send an empty message unless we are specifically allowing it
            if (!$this->AllowEmpty and empty($this->Body)) {
                throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
            }

            $this->MIMEHeader = $this->createHeader();
            $this->MIMEBody = $this->createBody();

            // To capture the complete message when using mail(), create
            // an extra header list which createHeader() doesn't fold in
            if ($this->Mailer == 'mail') {
                if (count($this->to) > 0) {
                    $this->mailHeader .= $this->addrAppend('To', $this->to);
                } else {
                    $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
                }
                $this->mailHeader .= $this->headerLine(
                    'Subject',
                    $this->encodeHeader($this->secureHeader(trim($this->Subject)))
                );
            }

            // Sign with DKIM if enabled
            if (!empty($this->DKIM_domain)
                && !empty($this->DKIM_private)
                && !empty($this->DKIM_selector)
                && !empty($this->DKIM_domain)
                && file_exists($this->DKIM_private)) {
                $header_dkim = $this->DKIM_Add(
                    $this->MIMEHeader . $this->mailHeader,
                    $this->encodeHeader($this->secureHeader($this->Subject)),
                    $this->MIMEBody
                );
                $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
                    str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
            }
            return true;

        } catch (phpmailerException $exc) {
            $this->setError($exc->getMessage());
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }
161307
function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption')
    {
        if (!is_object($this->privateKey) || empty($this->dn)) {
            return false;
        }

        $origPublicKey = $this->publicKey;
        $class = get_class($this->privateKey);
        $this->publicKey = new $class();
        $this->publicKey->loadKey($this->privateKey->getPublicKey());
        $this->publicKey->setPublicKey();
        if (!($publicKey = $this->_formatSubjectPublicKey())) {
            return false;
        }
        $this->publicKey = $origPublicKey;

        $currentCert = isset($this->currentCert) ? $this->currentCert : NULL;
        $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL;

        if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) {
            $this->currentCert['signatureAlgorithm']['algorithm'] =
                $signatureAlgorithm;
            if (!empty($this->dn)) {
                $this->currentCert['certificationRequestInfo']['subject'] = $this->dn;
            }
            $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey;
        } else {
            $this->currentCert = array(
                'certificationRequestInfo' =>
                    array(
                        'version' => 'v1',
                        'subject' => $this->dn,
                        'subjectPKInfo' => $publicKey
                    ),
                'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
                'signature'          => false // this is going to be overwritten later
            );
        }

        // resync $this->signatureSubject
        // save $certificationRequestInfo in case there are any File_ASN1_Element objects in it
        $certificationRequestInfo = $this->currentCert['certificationRequestInfo'];
        $this->loadCSR($this->saveCSR($this->currentCert));

        $result = $this->_sign($this->privateKey, $signatureAlgorithm);
        $result['certificationRequestInfo'] = $certificationRequestInfo;

        $this->currentCert = $currentCert;
        $this->signatureSubject = $signatureSubject;

        return $result;
    }
1166036
protected function generateSignature()
    {
        return md5(
            $this->getAmountInteger().
            $this->getCurrency().
            $this->getAccountId().
            $this->getSiteId().
            $this->getTransactionId()
        );
    }
327714
protected function _sign($sid)
    {
        $stamp = $this->_stamp() . $this->_secret;
        $signature = hash('sha256', $sid . $stamp);
            return $signature;
    }