@Override
    public void verify(byte[] data, byte[] signature, MessageDigest digest) {
        final byte[] decrypted = engine.processBlock(signature, 0, signature.length);
        final int delta = checkSignature(decrypted, digest);
        final int offset = decrypted.length - digest.getDigestLength() - delta;
        digest.update(decrypted, 1, offset - 1);
        digest.update(data);

        if (!CryptoUtils.compare(digest.digest(), decrypted, offset)) {
            throw new VerificationException("Invalid signature");
        }
    }
@Test
    public void shouldValidateSignatureSHA1() {
        final byte[] challenge = CryptoUtils.random(40);
        final byte[] signature = sign(0x54, challenge, ISOTrailers.TRAILER_SHA1, "SHA1");
        new DssRsaSignatureVerifier(PUBLIC).verify(challenge, signature, "SHA1");
    }