/** * 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 sign 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) * sig = sign() *</pre> * * @param data byte array containing the message to be signed * @param off the start of the message inside data * @param len the length of the message * @return the signature * @throws SignatureException if update() already called * @see #ONE_SHOT_MODE * @since 0.9.25 */ public byte[] signOneShot(byte[] data, int off, int len) throws SignatureException { oneShotMode = true; update(data, off, len); return sign(); }
/** * To efficiently sign 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) * sig = sign() *</pre> * * @param data byte array containing the message to be signed * @param off the start of the message inside data * @param len the length of the message * @return the signature * @throws SignatureException if update() already called * @see #ONE_SHOT_MODE */ public byte[] signOneShot(byte[] data, int off, int len) throws SignatureException { oneShotMode = true; update(data, off, len); return sign(); }
/** * 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); }
@Override public byte[] signMessage(byte[] message) { try { EdDSAEngine sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512")); PrivateKey sKey = new EdDSAPrivateKey(keySpec); sgr.initSign(sKey); sgr.update(message); return sgr.sign(); } catch (Exception e) { throw new RuntimeException(e); } }
protected byte[] signWithoutClamp(byte[] message, byte[] privateKey, byte[] publicKey) { try { EdDSAPrivateKeySpec edDSAPrivateKeySpec = new EdDSAPrivateKeySpec(privateKey, EdDSANamedCurveTable.getByName("ed25519-sha-512")); mEdDSAEngine.initSign(new EdDSAPrivateKey(edDSAPrivateKeySpec)); mEdDSAEngine.update(message); return mEdDSAEngine.sign(); } catch (InvalidKeyException e) { throw new IllegalArgumentException(e); } catch (SignatureException 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); } }
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); } }