Search in sources :

Example 6 with EdDSAParameterSpec

use of net.i2p.crypto.eddsa.spec.EdDSAParameterSpec in project i2p.i2p by i2p.

the class EdDSAEngineTest method testSignOneShotMode.

@Test
public void testSignOneShotMode() throws Exception {
    Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
    EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
    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)));
}
Also used : EdDSAParameterSpec(net.i2p.crypto.eddsa.spec.EdDSAParameterSpec) PrivateKey(java.security.PrivateKey) Signature(java.security.Signature) EdDSAPrivateKeySpec(net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec) Test(org.junit.Test)

Aggregations

EdDSAParameterSpec (net.i2p.crypto.eddsa.spec.EdDSAParameterSpec)6 Test (org.junit.Test)6 PrivateKey (java.security.PrivateKey)5 Signature (java.security.Signature)5 EdDSAPrivateKeySpec (net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec)5 PublicKey (java.security.PublicKey)1 EdDSAPublicKeySpec (net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec)1