/** * To efficiently verify all the data in one shot, if it is available, * use this method, which will avoid copying the data. * * Same as: *<pre> * setParameter(ONE_SHOT_MODE) * update(data, off, len) * ok = verify(signature, sigoff, siglen) *</pre> * * @param data byte array containing the message that was signed * @param off the start of the message inside data * @param len the length of the message * @param signature byte array containing the signature * @param sigoff the start of the signature * @param siglen the length of the signature * @return true if the signature is valid, false otherwise * @throws SignatureException if update() already called * @see #ONE_SHOT_MODE * @since 0.9.25 */ public boolean verifyOneShot(byte[] data, int off, int len, byte[] signature, int sigoff, int siglen) throws SignatureException { oneShotMode = true; update(data, off, len); return verify(signature, sigoff, siglen); }
/** * To efficiently verify all the data in one shot, if it is available, * use this method, which will avoid copying the data. * * Same as: *<pre> * setParameter(ONE_SHOT_MODE) * update(data, off, len) * ok = verify(signature, sigoff, siglen) *</pre> * * @param data byte array containing the message that was signed * @param off the start of the message inside data * @param len the length of the message * @param signature byte array containing the signature * @param sigoff the start of the signature * @param siglen the length of the signature * @return true if the signature is valid, false otherwise * @throws SignatureException if update() already called * @see #ONE_SHOT_MODE */ public boolean verifyOneShot(byte[] data, int off, int len, byte[] signature, int sigoff, int siglen) throws SignatureException { oneShotMode = true; update(data, off, len); return verify(signature, sigoff, siglen); }
public boolean isValidSignature(byte[] message, byte[] signature, byte[] publicKey) { try { EdDSANamedCurveSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512"); EdDSAPublicKeySpec edDSAPublicKeySpec = new EdDSAPublicKeySpec(publicKey, spec); EdDSAPublicKey edDSAPublicKey = new EdDSAPublicKey(edDSAPublicKeySpec); mEdDSAEngine.initVerify(edDSAPublicKey); mEdDSAEngine.update(message); return mEdDSAEngine.verify(signature); } catch (Exception e) { throw new IllegalArgumentException(e); } }
@Override public boolean verifySignature(byte[] message, byte[] sigBytes) { try { EdDSAEngine sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512")); sgr.initVerify(new EdDSAPublicKey(new EdDSAPublicKeySpec(keySpec.getA(), ed25519))); sgr.update(message); return sgr.verify(sigBytes); } catch (Exception e) { throw new RuntimeException(e); } }