use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.
the class Ed25519PublicKeyManagerTest method validateKey_wrongLength64_throws.
@Test
public void validateKey_wrongLength64_throws() throws Exception {
Ed25519PublicKey publicKey = signManager.getPublicKey(createPrivateKey());
Ed25519PublicKey invalidKey = Ed25519PublicKey.newBuilder(publicKey).setKeyValue(ByteString.copyFrom(Random.randBytes(64))).build();
assertThrows(GeneralSecurityException.class, () -> verifyManager.validateKey(invalidKey));
}
use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.
the class Ed25519PublicKeyManagerTest method validateKey.
@Test
public void validateKey() throws Exception {
Ed25519PublicKey publicKey = signManager.getPublicKey(createPrivateKey());
verifyManager.validateKey(publicKey);
}
use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.
the class Ed25519PublicKeyManagerTest method validateKey_wrongVersion.
@Test
public void validateKey_wrongVersion() throws Exception {
Ed25519PublicKey publicKey = signManager.getPublicKey(createPrivateKey());
Ed25519PublicKey invalidKey = Ed25519PublicKey.newBuilder(publicKey).setVersion(1).build();
assertThrows(GeneralSecurityException.class, () -> verifyManager.validateKey(invalidKey));
}
use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.
the class Ed25519PublicKeyManagerTest method createPrimitive.
@Test
public void createPrimitive() throws Exception {
Ed25519PrivateKey privateKey = createPrivateKey();
Ed25519PublicKey publicKey = signManager.getPublicKey(privateKey);
PublicKeySign signer = signManager.getPrimitive(privateKey, PublicKeySign.class);
PublicKeyVerify verifier = verifyManager.getPrimitive(publicKey, PublicKeyVerify.class);
byte[] message = Random.randBytes(135);
verifier.verify(signer.sign(message), message);
}
use of com.google.crypto.tink.proto.Ed25519PublicKey in project tink by google.
the class Ed25519PublicKeyManagerTest method createPrimitive_anotherKey_throws.
@Test
public void createPrimitive_anotherKey_throws() throws Exception {
Ed25519PrivateKey privateKey = createPrivateKey();
// Create a different key.
Ed25519PublicKey publicKey = signManager.getPublicKey(createPrivateKey());
PublicKeySign signer = signManager.getPrimitive(privateKey, PublicKeySign.class);
PublicKeyVerify verifier = verifyManager.getPrimitive(publicKey, PublicKeyVerify.class);
byte[] message = Random.randBytes(135);
byte[] signature = signer.sign(message);
assertThrows(GeneralSecurityException.class, () -> verifier.verify(signature, message));
}
Aggregations