Verify a WBB signature for a certain message

@param pk  Public key
@param sig Signature
@param m   Message
@return True iff valid
519823
public static boolean weakBBVerify(ECP2 pk, ECP sig, BIG m) {
        ECP2 p = new ECP2();
        p.copy(pk);
        p.add(IdemixUtils.genG2.mul(m));
        p.affine();

        return PAIR.fexp(PAIR.ate(p, sig)).equals(IdemixUtils.genGT);
    }
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)
1087687
private boolean verifyHelloMessage(byte[] helloMsg) {
		if (sdpHelloHashReceived != null) {
			String hash = calculateSHA256Hash(helloMsg, 0, helloMsg.length);
			boolean hashesMatched = hash.toUpperCase().equals(
					sdpHelloHashReceived.toUpperCase());
			if (platform.getLogger().isEnabled()) {
				if (hashesMatched) {
					logString("verifyHelloMessage() Hello hash verified OK.");
				} else {
					logString("verifyHelloMessage() Hello hash does NOT match  hash= '"
							+ hash
							+ "' expected (SDP) = '"
							+ sdpHelloHashReceived + "'");
				}
			}
			return hashesMatched;
		} else {
			return true;
		}
	}
351114
public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
        throws SignatureException {
        Signature signature;
        try {
            signature = Signature.getInstance(algorithm);
            signature.initVerify(key);
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
        }
        signature.update(text);
        return signature.verify(signatureValue);
    }
78423
public boolean verify(BIG sk, IdemixIssuerPublicKey ipk) {
        if (ipk == null || Attrs.length != ipk.getAttributeNames().length) {
            return false;
        }
        for (byte[] attr : Attrs) {
            if (attr == null) {
                return false;
            }
        }

        ECP bPrime = new ECP();
        bPrime.copy(IdemixUtils.genG1);
        bPrime.add(ipk.getHsk().mul2(sk, ipk.getHRand(), S));
        for (int i = 0; i < Attrs.length / 2; i++) {
            bPrime.add(ipk.getHAttrs()[2 * i].mul2(BIG.fromBytes(Attrs[2 * i]), ipk.getHAttrs()[2 * i + 1], BIG.fromBytes(Attrs[2 * i + 1])));
        }
        if (Attrs.length % 2 != 0) {
            bPrime.add(ipk.getHAttrs()[Attrs.length - 1].mul(BIG.fromBytes(Attrs[Attrs.length - 1])));
        }
        if (!B.equals(bPrime)) {
            return false;
        }

        ECP2 a = IdemixUtils.genG2.mul(E);
        a.add(ipk.getW());
        a.affine();
        return PAIR.fexp(PAIR.ate(a, A)).equals(PAIR.fexp(PAIR.ate(IdemixUtils.genG2, B)));
    }
1058190
public void verifyMIC(byte[] inTok, int tokOff, int tokLen, // mic
                          byte[] inMsg, int msgOff, int msgLen, // real msg
                          MessageProp prop)
        throws GSSException {
        throw new GSSException(GSSException.UNAVAILABLE);
/*TODO

        checkContext();

        logger.debug("enter verifyMic");

        SSLCipherState st = this.conn.getReadCipherState();
        SSLCipherSuite cs = st.getCipherSuite();

        logger.debug("digest algorithm: " + cs.getDigestAlg());

        if (tokLen != (GSI_MESSAGE_DIGEST_PADDING + cs.getDigestOutputLength())) {
            throw new GlobusGSSException(GSSException.DEFECTIVE_TOKEN,
                                         GlobusGSSException.TOKEN_FAIL,
                                         "tokenFail00",
                                         new Object[] {new Integer(tokLen),
                                                       new Integer(GSI_MESSAGE_DIGEST_PADDING +
                                                                   cs.getDigestOutputLength())});
        }

        int bufLen = SSLUtil.toInt(inTok, tokOff+GSI_SEQUENCE_SIZE);
        if (bufLen != msgLen) {
            throw new GlobusGSSException(GSSException.DEFECTIVE_TOKEN,
                                         GlobusGSSException.TOKEN_FAIL,
                                         "tokenFail01",
                                         new Object[] {new Integer(msgLen), new Integer(bufLen)});
        }

        int pad_ct = (cs.getDigestOutputLength()==16) ? 48 : 40;

        byte [] digest = null;

        try {
            MessageDigest md =
                MessageDigest.getInstance(cs.getDigestAlg());

            md.update(st.getMacKey());
            for(int i=0;i<pad_ct;i++) {
                md.update(SSLHandshake.pad_1);
            }
            md.update(inTok, tokOff, GSI_MESSAGE_DIGEST_PADDING);
            md.update(inMsg, msgOff, msgLen);

            digest = md.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new GlobusGSSException(GSSException.FAILURE, e);
        }

        byte [] token = new byte[tokLen-GSI_MESSAGE_DIGEST_PADDING];
        System.arraycopy(inTok, tokOff+GSI_MESSAGE_DIGEST_PADDING, token, 0, token.length);

        if (!Arrays.equals(digest, token)) {
            throw new GlobusGSSException(GSSException.BAD_MIC,
                                         GlobusGSSException.BAD_MIC,
                                         "tokenFail02");
        }

        long tokSeq = SSLUtil.toLong(inTok, tokOff);
        long readSeq = this.conn.getReadSequence();
        long seqTest = tokSeq - readSeq;

        logger.debug("Token seq#   : " + tokSeq);
        logger.debug("Current seq# : " + readSeq);

        if (seqTest > 0) {
            // gap token
            throw new GSSException(GSSException.GAP_TOKEN);
        } else if (seqTest < 0) {
            // old token
            throw new GSSException(GSSException.OLD_TOKEN);
        } else {
            this.conn.incrementReadSequence();
        }

        if (prop != null) {
            prop.setPrivacy(false);
            prop.setQOP(0);
        }

        logger.debug("exit verifyMic");
*/
    }
716177
def verifySignature(self, signatureKey):
        
        try:
            parts = ByteUtil.split(self.serialized,
                                   len(self.serialized) - self.__class__.SIGNATURE_LENGTH,
                                   self.__class__.SIGNATURE_LENGTH)

            if not Curve.verifySignature(signatureKey, parts[0], parts[1]):
                raise InvalidMessageException("Invalid signature!")
        except InvalidKeyException as e:
            raise InvalidMessageException(e)
677803
public static boolean verify(byte[] data, String publicKey, String sign) throws Exception {
        String keyBytes = Base64Utils.encode(publicKey);
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes.getBytes());
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        PublicKey publicK = keyFactory.generatePublic(keySpec);
        Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
        signature.initVerify(publicK);
        signature.update(data);
        return signature.verify(Base64Utils.decode(sign).getBytes());
    }
1107408
def checkvalid(s, m, pk):
    
    if len(s) != b // 4:
        raise ValueError("signature length is wrong")

    if len(pk) != b // 8:
        raise ValueError("public-key length is wrong")

    s = bytearray(s)
    m = bytearray(m)
    pk = bytearray(pk)

    R = decodepoint(s[: b // 8])
    A = decodepoint(pk)
    S = decodeint(s[b // 8 : b // 4])
    h = Hint(encodepoint(R) + pk + m)

    (x1, y1, z1, t1) = P = scalarmult_B(S)
    (x2, y2, z2, t2) = Q = edwards_add(R, scalarmult(A, h))

    if (
        not isoncurve(P)
        or not isoncurve(Q)
        or (x1 * z2 - x2 * z1) % q != 0
        or (y1 * z2 - y2 * z1) % q != 0
    ):
        raise SignatureMismatch("signature does not pass verification")
403885
def verify_relayable_signature(public_key, doc, signature):
    
    sig_hash = _create_signature_hash(doc)
    cipher = PKCS1_v1_5.new(RSA.importKey(public_key))
    return cipher.verify(sig_hash, b64decode(signature))
996313
public static boolean checkByPublicKey(String data, String sign, String publicKey) throws Exception {
		KeyFactory keyFactory = KeyFactory.getInstance("RSA");
		byte[] encodedKey = base64.decode(publicKey);
		PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
		java.security.Signature signature = java.security.Signature.getInstance("SHA256WithRSA");
		signature.initVerify(pubKey);
		signature.update(data.getBytes("utf-8"));
		return signature.verify(base64.decode(sign.getBytes("UTf-8")));
	}
801505
public void proveIdentity(byte[] sharedSecret, KeyPair key) throws IOException, GeneralSecurityException {
        String algorithm = detectKeyAlgorithm(key);
        writeUTF(algorithm);
        writeKey(key.getPublic());

        Signature sig = Signature.getInstance("SHA1with"+algorithm);
        sig.initSign(key.getPrivate());
        sig.update(key.getPublic().getEncoded());
        sig.update(sharedSecret);
        writeObject(sig.sign());
    }
102163
def verifySignature(ecPublicSigningKey, message, signature):
        

        if ecPublicSigningKey.getType() == Curve.DJB_TYPE:
            result = _curve.verifySignature(ecPublicSigningKey.getPublicKey(), message, signature)
            return result == 0
        else:
            raise InvalidKeyException("Unknown type: %s" % ecPublicSigningKey.getType())
984340
def verify_signature(pubkey_path, message, signature):
    '''
    
    '''
    log.debug('salt.crypt.verify_signature: Loading public key')
    pubkey = get_rsa_pub_key(pubkey_path)
    log.debug('salt.crypt.verify_signature: Verifying signature')
    if HAS_M2:
        md = EVP.MessageDigest('sha1')
        md.update(salt.utils.stringutils.to_bytes(message))
        digest = md.final()
        return pubkey.verify(digest, signature)
    else:
        verifier = PKCS1_v1_5.new(pubkey)
        return verifier.verify(SHA.new(salt.utils.stringutils.to_bytes(message)), signature)
1326435
@SneakyThrows
    public static byte[] verifyJwsSignature(final Key signingKey, final byte[] value) {
        val asString = new String(value, StandardCharsets.UTF_8);
        return verifyJwsSignature(signingKey, asString);
    }
262122
public static boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
        return curve_sigs.curve25519_verify(SHA512Provider, signature, publicKey, message, message.length) == 0;
    }
397927
public boolean isHashEqualsWithBase64(String expectedSignatureBase64, BuilderMode builderMode) {
        try {
            final byte[] signature = build(builderMode);
            return MessageDigest.isEqual(signature, DatatypeConverter.parseBase64Binary(expectedSignatureBase64));
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            return false;
        }
    }