Search in sources :

Example 11 with Ed25519PublicKey

use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.

the class Ed25519PublicKeyManagerTest method validateKey_wrongLength31_throws.

@Test
public void validateKey_wrongLength31_throws() throws Exception {
    Ed25519PublicKey publicKey = signManager.getPublicKey(createPrivateKey());
    Ed25519PublicKey invalidKey = Ed25519PublicKey.newBuilder(publicKey).setKeyValue(ByteString.copyFrom(Random.randBytes(31))).build();
    assertThrows(GeneralSecurityException.class, () -> verifyManager.validateKey(invalidKey));
}
Also used : Ed25519PublicKey(com.google.crypto.tink.proto.Ed25519PublicKey) Test(org.junit.Test)

Example 12 with Ed25519PublicKey

use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.

the class Ed25519PrivateKeyManagerTest method getPublicKey_checkValues.

/**
 * Tests that a public key is extracted properly from a private key.
 */
@Test
public void getPublicKey_checkValues() throws Exception {
    Ed25519PrivateKey privateKey = factory.createKey(Ed25519KeyFormat.getDefaultInstance());
    Ed25519PublicKey publicKey = manager.getPublicKey(privateKey);
    assertThat(publicKey).isEqualTo(privateKey.getPublicKey());
}
Also used : Ed25519PrivateKey(com.google.crypto.tink.proto.Ed25519PrivateKey) Ed25519PublicKey(com.google.crypto.tink.proto.Ed25519PublicKey) Test(org.junit.Test)

Aggregations

Ed25519PublicKey (com.google.crypto.tink.proto.Ed25519PublicKey)12 Test (org.junit.Test)9 Ed25519PrivateKey (com.google.crypto.tink.proto.Ed25519PrivateKey)5 PublicKeySign (com.google.crypto.tink.PublicKeySign)2 PublicKeyVerify (com.google.crypto.tink.PublicKeyVerify)2 KeyData (com.google.crypto.tink.proto.KeyData)2 Ed25519Sign (com.google.crypto.tink.subtle.Ed25519Sign)2 GeneralSecurityException (java.security.GeneralSecurityException)2 Ed25519KeyFormat (com.google.crypto.tink.proto.Ed25519KeyFormat)1 Ed25519Verify (com.google.crypto.tink.subtle.Ed25519Verify)1 ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1