Check whether a given HMAC value matches the HMAC for this HawkContext.

@param hmac
The HMAC value to test.
@return true if the HMAC matches the HMAC computed for this context,
false otherwise.
@throws HawkException
976150
public boolean isValidMac(String hmac) throws HawkException {
		String this_hmac = this.generateHmac();
		return Util.fixedTimeEqual(this_hmac, hmac);
	}
204014
public boolean isHashEqualsWithHex(String expectedSignatureHex, BuilderMode builderMode) {
        try {
            final byte[] signature = build(builderMode);
            return MessageDigest.isEqual(signature, DatatypeConverter.parseHexBinary(expectedSignatureHex));
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            return false;
        }
    }
1356401
@Override
    public boolean matches(IAtom atom) {

        if (!((IQueryAtom) query.getAtom(0)).matches(atom)) return false;

        if (query.getAtomCount() == 1) return true;

        IAtomContainer target = invariants(atom).target();

        return cache.getUnchecked(target).get(target.indexOf(atom));
    }
49148
@Override
    public boolean containsKey(Object key) {
        return key == null ? (indexOfNull() >= 0) : (indexOf(key, key.hashCode()) >= 0);
    }
537307
public boolean isMatch(InetAddress inetAddress)
  {
    byte []bytes = inetAddress.getAddress();

    if (bytes.length != _address.length)
      return false;

    for (int i = 0; i < bytes.length; i++) {
      if (bytes[i] == _address[i]) {
      }
      else if (_subnetByte < i) {
        return true;
      }
      else if (i == _subnetByte) {
        return (bytes[i] & _subnetMask) == (_address[i] & _subnetMask);
      }
      else {
        return false;
      }
    }

    return true;
  }
1096450
public boolean matchesBeacon(Beacon beacon) {
        // All identifiers must match, or the corresponding region identifier must be null.
        for (int i = mIdentifiers.size(); --i >= 0; ) {
            final Identifier identifier = mIdentifiers.get(i);
            Identifier beaconIdentifier = null;
            if (i < beacon.mIdentifiers.size()) {
                beaconIdentifier = beacon.getIdentifier(i);
            }
            if ((beaconIdentifier == null && identifier != null) ||
                    (beaconIdentifier != null  && identifier != null && !identifier.equals(beaconIdentifier))) {
                return false;
            }
        }
        if (mBluetoothAddress != null && !mBluetoothAddress.equalsIgnoreCase(beacon.mBluetoothAddress)) {
            return false;
        }
        return true;
    }
709701
public static boolean isMacValid(byte[] expected, byte[] input, byte[] key) {
		byte[] actual = hmacSha1(input, key);
		return Arrays.equals(expected, actual);
	}
375391
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
        try {
            return scramHmac.hmac(key, str);
        }
        catch (InvalidKeyException e) {
            throw new SmackSaslException(getName() + " Exception", e);
        }
    }
79659
@Override
    public boolean matches(String fileName) {
        // Special case: if no classes or packages have been defined,
        // then the screener matches all class files.
        if (patternList.isEmpty()) {
            return true;
        }

        LOG.debug("Matching: {}", fileName);

        // Scan through list of regexes
        for (Matcher matcher : patternList) {
            matcher.reset(fileName);
            if (matcher.find()) {
                LOG.debug("\\tTrying [{}]: yes!", matcher.pattern());
                return true;
            }
            LOG.debug("\\tTrying [{}]: no", matcher.pattern());
        }
        return false;
    }
1175358
private int hmacSignature(byte[] workBytes) {
    try {
      Mac integrityHmac = createMac();
      integrityHmac.init(keys.getIntegrityKey());
      integrityHmac.update(workBytes, PAYLOAD_BASE, workBytes.length - OVERHEAD_SIZE);
      integrityHmac.update(workBytes, INITV_BASE, INITV_SIZE);
      return Ints.fromByteArray(integrityHmac.doFinal());
    } catch (InvalidKeyException e) {
      throw new IllegalStateException(e);
    }
  }
998379
function compareHmac(hmac1, hmac2) {
    var left = hmac1;
    if (Buffer.isBuffer(hmac1)) {
        left = hmac1.toString('base64');
    }
    var right = hmac2;
    if (Buffer.isBuffer(hmac2)) {
        right = hmac2.toString('base64');
    }
    return (left == right);
}
112586
public static boolean checkKeyAgreement(Platform platform, byte[] aMsg, int keyPos,
			int keyCount) {
		if (keyCount != 4)
			return false;
		
		boolean result = (platform.getUtils().equals(KeyAgreementType.ECDH384.getType(), 0, aMsg, keyPos , 4)  &&
			    platform.getUtils().equals(KeyAgreementType.ECDH256.getType(), 0, aMsg, keyPos + 1 * 4, 4) &&
			    platform.getUtils().equals(KeyAgreementType.DH3K.getType(), 0, aMsg, keyPos + 2 * 4, 4) &&
			    platform.getUtils().equals(new byte[] { 'D', 'H', '2', 'k' }, 0, aMsg, keyPos + 3 * 4, 4));
		
		return result;
	}
970324
public static boolean verify(String appId, String appSecretKey, byte[] body, HttpServletRequest request)
            throws IOException {
        HmacSignatureBuilder builder = new HmacSignatureBuilder();

        String signitSignature = request.getHeader("X-Signit-Signature");
        builder.scheme(request.getHeader("X-Signit-Scheme"))
                .apiKey(appId)
                .apiSecret(appSecretKey.getBytes())
                .method(request.getMethod()
                        .toUpperCase())
                .payload(body)
                .contentType(request.getContentType())
                .host(Validator.isEmpty(request.getHeader("X-Signit-Host")) ? "" : request.getHeader("X-Signit-Host"))
                .resource(Validator.isEmpty(request.getHeader("X-Signit-Resource")) ? ""
                        : request.getHeader("X-Signit-Resource"))
                .nonce(Validator.isEmpty(request.getHeader("X-Signit-Nonce")) ? ""
                        : request.getHeader("X-Signit-Nonce"))
                .date(Validator.isEmpty(request.getHeader("X-Signit-Date")) ? "" : request.getHeader("X-Signit-Date"));
        String selfBuiltHmac = builder.getDefaultAlgorithm() + " " + appId + ":" + builder.buildAsBase64();
        return selfBuiltHmac.equals(signitSignature);
    }
428210
public synchronized boolean containsKey(CacheKey key) {
    Preconditions.checkNotNull(key);
    if (!mMap.containsKey(key)) {
      return false;
    }
    EncodedImage storedEncodedImage = mMap.get(key);
    synchronized (storedEncodedImage) {
      if (!EncodedImage.isValid(storedEncodedImage)) {
        // Reference is not valid, this means that someone cleared reference while it was still in
        // use. Log error
        // TODO: 3697790
        mMap.remove(key);
        FLog.w(
            TAG,
            "Found closed reference %d for key %s (%d)",
            System.identityHashCode(storedEncodedImage),
            key.getUriString(),
            System.identityHashCode(key));
        return false;
      }
      return true;
    }
  }
1234556
private static boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) {
        if (authenticateHeader != null && !authenticateHeader.isEmpty()
                && authenticateHeader.toLowerCase().startsWith(authChallengePrefix.toLowerCase())) {
            return true;
        }
        return false;
    }
1066149
protected boolean hasI18nKey(final String aMessageKey) {
        return myBundle != null && aMessageKey != null && myBundle.containsKey(aMessageKey);
    }
626003
private String generateHmac() throws HawkException {

		String baseString = getBaseString();

		Mac mac;
		try {
			mac = Mac.getInstance(getAlgorithm().getMacName());
		} catch (NoSuchAlgorithmException e) {
			throw new HawkException("Unknown algorithm "
					+ getAlgorithm().getMacName(), e);
		}

		SecretKeySpec secret_key = new SecretKeySpec(getKey().getBytes(
				Charsets.UTF_8), getAlgorithm().getMacName());
		try {
			mac.init(secret_key);
		} catch (InvalidKeyException e) {
			throw new HawkException("Key is invalid ", e);
		}

		return new String(Base64.encodeBase64(mac.doFinal(baseString
				.getBytes(Charsets.UTF_8))), Charsets.UTF_8);
	}