Verify a message

@param Message $message
@param string $fingerprint
@return bool

@throws \Crypt_GPG_FileException
@throws GPGMailerException
@throws \PEAR_Exception
10427
public function verify(Message $message, string $fingerprint): bool
    {
        $gnupg = new \Crypt_GPG($this->options);
        $gnupg->addSignKey($fingerprint);

        /**
         * @var \Crypt_GPG_Signature[] $verified
         */
        try {
            $verified = $gnupg->verify($message->getBodyText());
            /**
             * @var \Crypt_GPG_Signature $sig
             */
            foreach ($verified as $sig) {
                if ($sig->isValid()) {
                    return true;
                }
            }
            return false;
        } catch (\PEAR_Exception $ex) {
            throw new GPGMailerException(
                'An error occurred trying to verify this message: ' .
                    $ex->getMessage(),
                $ex->getCode(),
                $ex
            );
        }
    }
412441
public function getByFingerprint($fingerprint)
    {
        $key = $this->adapter->get(sprintf('%s/account/keys/%s', $this->endpoint, $fingerprint));

        $key = json_decode($key);

        return new KeyEntity($key->ssh_key);
    }
942529
def assert_fingerprint(cert, fingerprint):
    

    # Maps the length of a digest to a possible hash function producing
    # this digest.
    hashfunc_map = {
        16: md5,
        20: sha1,
        32: sha256,
    }

    fingerprint = fingerprint.replace(':', '').lower()
    digest_length, odd = divmod(len(fingerprint), 2)

    if odd or digest_length not in hashfunc_map:
        raise SSLError('Fingerprint is of invalid length.')

    # We need encode() here for py32; works on py2 and p33.
    fingerprint_bytes = unhexlify(fingerprint.encode())

    hashfunc = hashfunc_map[digest_length]

    cert_digest = hashfunc(cert).digest()

    if not cert_digest == fingerprint_bytes:
        raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".'
                       .format(hexlify(fingerprint_bytes),
                               hexlify(cert_digest)))
191298
private static function normalizePeerFingerprint($fingerprint): array
    {
        if (\is_string($fingerprint)) {
            switch (\strlen($fingerprint = str_replace(':', '', $fingerprint))) {
                case 32: $fingerprint = ['md5' => $fingerprint]; break;
                case 40: $fingerprint = ['sha1' => $fingerprint]; break;
                case 44: $fingerprint = ['pin-sha256' => [$fingerprint]]; break;
                case 64: $fingerprint = ['sha256' => $fingerprint]; break;
                default: throw new InvalidArgumentException(sprintf('Cannot auto-detect fingerprint algorithm for "%s".', $fingerprint));
            }
        } elseif (\is_array($fingerprint)) {
            foreach ($fingerprint as $algo => $hash) {
                $fingerprint[$algo] = 'pin-sha256' === $algo ? (array) $hash : str_replace(':', '', $hash);
            }
        } else {
            throw new InvalidArgumentException(sprintf('Option "peer_fingerprint" must be string or array, %s given.', \gettype($fingerprint)));
        }

        return $fingerprint;
    }
635888
protected function generateFingerprint()
    {
        // Assume empty fingerprint
        $fingerprint = '';

        // Who is requesting (fingerprint client)
        $headers = getallheaders();

        // Get arguments
        $arguments   = func_get_args();
        $arguments[] = $_SERVER['REMOTE_ADDR'];
        $arguments[] = (isset($headers['USER_AGENT'])) ? $headers['USER_AGENT'] : null;
        $arguments[] = (isset($headers['ACCEPT'])) ? $headers['ACCEPT'] : null;
        $arguments[] = (isset($headers['ACCEPT_LANGUAGE'])) ? $headers['ACCEPT_LANGUAGE'] : null;
        $arguments[] = (isset($headers['ACCEPT_ENCODING'])) ? $headers['ACCEPT_ENCODING'] : null;
        $arguments[] = $this->translateToTemplateFilename();

        foreach ($arguments as $argument) {
            $fingerprint .= serialize($argument);
        }

        return md5($fingerprint);
    }
1335855
@Override
  public boolean verifyMessage(InputStream publicKeyOfSender, InputStream message, InputStream signatureStream) {
    LOGGER.trace("verifyMessage(InputStream, InputStream, InputStream)");
    LOGGER.trace("Public Key: {}, Data: {}, Signature: {}",
        publicKeyOfSender == null ? "not set" : "set", message == null ? "not set" : "set", signatureStream == null ? "not set" : "set");
    boolean result = false;
    LOGGER.debug("Wrapping signature stream in ArmoredInputStream");
    try( InputStream armordPublicKeyStream = new ArmoredInputStream(signatureStream) ) {
      Object pgpObject;
      PGPObjectFactory pgpObjectFactory = new PGPObjectFactory(armordPublicKeyStream, new BcKeyFingerprintCalculator());
      LOGGER.debug("Iterating over PGP objects in stream");
      while( (pgpObject = pgpObjectFactory.nextObject()) != null ) {
        if( pgpObject instanceof PGPSignatureList ) {
          LOGGER.debug("Signature List found");
          PGPSignatureList signatureList = (PGPSignatureList)pgpObject;
          LOGGER.debug("Iterating over signature list");
          Iterator<PGPSignature> signatureIterator = signatureList.iterator();
          while( signatureIterator.hasNext() ) {
            LOGGER.debug("Checking next signature");
            final PGPSignature signature = signatureIterator.next();
            PGPPublicKey pgpPublicKey = findPublicKey(publicKeyOfSender, new KeyFilter<PGPPublicKey>() {
              @Override
              public boolean accept(PGPPublicKey pgpKey) {
                return pgpKey.getKeyID() == signature.getKeyID();
              }
            });
            if( pgpPublicKey != null ) {
              signature.init(new BcPGPContentVerifierBuilderProvider(), pgpPublicKey);
              LOGGER.debug("Processing signature data");
              IOUtils.process(message, new IOUtils.StreamHandler() {
                @Override
                public void handleStreamBuffer(byte[] buffer, int offset, int length) throws IOException {
                  signature.update(buffer, offset, length);
                }
              });
              result = signature.verify();
              LOGGER.info("Verify Signature: {}", result);
            } else {
              LOGGER.warn("No public key found for signature. Key ID: {}", signature.getKeyID());
            }
          }
        }
      }
    } catch (IOException | PGPException e) {
      LOGGER.error("{}", e.getMessage());
      result &= false;
    }
    return result;
  }
637808
def verify(sigfilename, filefilename=None):
    """"""

    if gnupg is None:
        return False

    gpg = gnupg.GPG()

    with open(sigfilename, "rb") as sigfile:
        verified = gpg.verify_file(sigfile, filefilename)

        pyspread_keyid = fingerprint2keyid(config["gpg_key_fingerprint"])

        if verified.valid and verified.key_id == pyspread_keyid:
            return True

    return False
562140
public void verify(PublicKey key, Provider sigProvider)
            throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
        unwrap().verify(key, sigProvider);
    }
1349020
static function format_fingerprint($fingerprint)
    {
        if (!$fingerprint) {
            return '';
        }

        $result = '';
        for ($i=0; $i<40; $i++) {
            if ($i % 4 == 0) {
                $result .= ' ';
            }
            $result .= $fingerprint[$i];
        }

        return $result;
    }
509384
public boolean detached_verify(byte [] message, byte [] signature) {
            if (signature.length != signatureLength)
                return false;
            if (theirPublicKey.length != publicKeyLength)
                return false;
            byte [] sm = new byte[signatureLength + message.length];
            byte [] m = new byte[signatureLength + message.length];
            for (int i = 0; i < signatureLength; i++)
                sm[i] = signature[i];
            for (int i = 0; i < message.length; i++)
                sm[i + signatureLength] = message[i];
            return (crypto_sign_open(m, -1, sm, 0, sm.length, theirPublicKey) >= 0);
        }
1076357
function verify($text, $signature)
    {
        try {
            $verified = $this->gpg->verify($text, $signature);
            return $this->parse_signature($verified[0]);
        }
        catch (Exception $e) {
            return $this->get_error_from_exception($e);
        }
    }
609721
def verify_message(self, key_or_address, signature, message=None, msg_hash=None):
        
        if isinstance(key_or_address, str):
            # they gave us a private key or a public key already loaded.
            key = self._network.parse.address(key_or_address)
        else:
            key = key_or_address

        try:
            msg_hash = self.hash_for_signing(message) if message is not None else msg_hash
            pair, is_compressed = self.pair_for_message_hash(signature, msg_hash)
        except EncodingError:
            return False
        return self.pair_matches_key(pair, key, is_compressed)
730959
public static function isProtocolMessage(Message $message)
    {
        // Temporary check to maintain BC with legacy Messages.
        if (is_numeric($message->peek()) && $message->peek() < 100) {
            return true;
        }

        return false;
    }
554135
def get_key(fingerprint, secret = false)
      rkey = []
      err = GPGME::gpgme_get_key(self, fingerprint, rkey, secret ? 1 : 0)
      exc = GPGME::error_to_exception(err)
      raise exc if exc
      rkey[0]
    end
70064
protected function _checkSure($message = null, $default = null) {
		if (empty($message)) {
			$message = __d('cake_installer', 'Are you sure?');
		}
		if (empty($default) || !in_array($default, ['y', 'n'])) {
			$default = 'n';
		}
		$options = ['y', 'n'];

		if (!empty($this->param('yes')) || ($this->in($message, $options, $default) === 'y')) {
			return true;
		} else {
			return false;
		}
	}
201979
private boolean matchesFingerprint(byte[] buffer, Pattern fingerprint)
   {
      return fingerprint.matcher(m_charset == null ? new String(buffer) : new String(buffer, m_charset)).matches();
   }
1232243
def Verify(self, message, signature, hash_algorithm=None):
    """"""
    # This method accepts both PSS and PKCS1v15 padding. PSS is preferred but
    # old clients only support PKCS1v15.

    if hash_algorithm is None:
      hash_algorithm = hashes.SHA256()

    last_e = None
    for padding_algorithm in [
        padding.PSS(
            mgf=padding.MGF1(hash_algorithm),
            salt_length=padding.PSS.MAX_LENGTH),
        padding.PKCS1v15()
    ]:
      try:
        self._value.verify(signature, message, padding_algorithm,
                           hash_algorithm)
        return True

      except exceptions.InvalidSignature as e:
        last_e = e

    raise VerificationError(last_e)