protected void doSetParameter(Signature sig, PSSParameterSpec spec) throws InvalidAlgorithmParameterException { sig.setParameter(spec); }
signature.initSign(signerConfig.privateKey); if (jcaSignatureAlgorithmParams != null) { signature.setParameter(jcaSignatureAlgorithmParams); signature.initVerify(publicKey); if (jcaSignatureAlgorithmParams != null) { signature.setParameter(jcaSignatureAlgorithmParams);
sig.initVerify(publicKey); if (jcaSignatureAlgorithmParams != null) { sig.setParameter(jcaSignatureAlgorithmParams);
@Test public void testSignOneShotMode() throws Exception { EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519); Signature sgr = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); EdDSAPrivateKeySpec privKey = new EdDSAPrivateKeySpec(TEST_SEED, spec); PrivateKey sKey = new EdDSAPrivateKey(privKey); sgr.initSign(sKey); sgr.setParameter(EdDSAEngine.ONE_SHOT_MODE); sgr.update(TEST_MSG); assertThat("One-shot mode sign failed", sgr.sign(), is(equalTo(TEST_MSG_SIG))); }
@Test public void testVerifyOneShotMode() throws Exception { EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519); Signature sgr = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(TEST_PK, spec); PublicKey vKey = new EdDSAPublicKey(pubKey); sgr.initVerify(vKey); sgr.setParameter(EdDSAEngine.ONE_SHOT_MODE); sgr.update(TEST_MSG); assertThat("One-shot mode verify failed", sgr.verify(TEST_MSG_SIG), is(true)); }
@Test public void testVerifyOneShotModeMultipleUpdates() throws Exception { EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519); EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(TEST_PK, spec); Signature sgr = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); PublicKey vKey = new EdDSAPublicKey(pubKey); sgr.initVerify(vKey); sgr.setParameter(EdDSAEngine.ONE_SHOT_MODE); sgr.update(TEST_MSG); exception.expect(SignatureException.class); exception.expectMessage("update() already called"); sgr.update(TEST_MSG); }
@Test public void testSignOneShotModeMultipleUpdates() throws Exception { EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519); Signature sgr = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm())); EdDSAPrivateKeySpec privKey = new EdDSAPrivateKeySpec(TEST_SEED, spec); PrivateKey sKey = new EdDSAPrivateKey(privKey); sgr.initSign(sKey); sgr.setParameter(EdDSAEngine.ONE_SHOT_MODE); sgr.update(TEST_MSG); exception.expect(SignatureException.class); exception.expectMessage("update() already called"); sgr.update(TEST_MSG); }
@Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { this.wrapped.setParameter(param, value); }
@Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { this.wrapped.setParameter(param, value); }
@Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { this.wrapped.setParameter(param, value); }
@Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { this.wrapped.setParameter(param, value); }
protected void doSetParameter(Signature sig, PSSParameterSpec spec) throws InvalidAlgorithmParameterException { sig.setParameter(spec); }
/** * {@inheritDoc} */ protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException { try { this.signatureAlgorithm.setParameter(params); } catch (InvalidAlgorithmParameterException ex) { throw new XMLSignatureException(ex); } }
/** {@inheritDoc} */ protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException { try { this.signatureAlgorithm.setParameter(params); } catch (InvalidAlgorithmParameterException ex) { throw new XMLSignatureException(ex); } }
@Override public void engineSetParameter(AlgorithmParameterSpec params) throws XMLSecurityException { try { signature.setParameter(params); } catch (InvalidAlgorithmParameterException e) { throw new XMLSecurityException(e); } } }
/** {@inheritDoc} */ protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException { try { this.signatureAlgorithm.setParameter(params); } catch (InvalidAlgorithmParameterException ex) { throw new XMLSignatureException(ex); } }
public static boolean verifyPSS(PublicKey publicKey, byte[] signedData, byte[] sig) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeySpecException { Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC); signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1)); signature.initVerify(publicKey); signature.update(signedData); return signature.verify(sig); }
public static byte[] signPSS(PrivateKey privateKey, byte[] signedData) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC); signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1)); signature.initSign(privateKey); signature.update(signedData); return signature.sign(); }
public static byte[] signPSS(PrivateKey privateKey, byte[] signedData) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC); signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1)); signature.initSign(privateKey); signature.update(signedData); return signature.sign(); }
public static boolean verifyPSS(PublicKey publicKey, byte[] signedData, byte[] sig) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeySpecException { Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC); signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1)); signature.initVerify(publicKey); signature.update(signedData); return signature.verify(sig); }