/** * 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(); }
@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); } }