@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(); try { verifyManager.validateKey(invalidKey); fail(); } catch (GeneralSecurityException e) { } }
@Override public void validateKey(Ed25519PublicKey keyProto) throws GeneralSecurityException { Validators.validateVersion(keyProto.getVersion(), getVersion()); if (keyProto.getKeyValue().size() != Ed25519Verify.PUBLIC_KEY_LEN) { throw new GeneralSecurityException("invalid Ed25519 public key: incorrect key length"); } }
Ed25519PublicKeyManager extends KeyTypeManager<Ed25519PublicKey> { @Override public void validateKey(Ed25519PublicKey keyProto) throws GeneralSecurityException { Validators.validateVersion(keyProto.getVersion(), getVersion()); if (keyProto.getKeyValue().size() != Ed25519Verify.PUBLIC_KEY_LEN) { throw new GeneralSecurityException("invalid Ed25519 public key: incorrect key length"); } } }
Ed25519PublicKeyManager extends KeyTypeManager<Ed25519PublicKey> { @Override public void validateKey(Ed25519PublicKey keyProto) throws GeneralSecurityException { Validators.validateVersion(keyProto.getVersion(), getVersion()); if (keyProto.getKeyValue().size() != Ed25519Verify.PUBLIC_KEY_LEN) { throw new GeneralSecurityException("invalid Ed25519 public key: incorrect key length"); } } Ed25519PublicKeyManager(); }
Ed25519PublicKeyManager extends KeyTypeManager<Ed25519PublicKey> { @Override public void validateKey(Ed25519PublicKey keyProto) throws GeneralSecurityException { Validators.validateVersion(keyProto.getVersion(), getVersion()); if (keyProto.getKeyValue().size() != Ed25519Verify.PUBLIC_KEY_LEN) { throw new GeneralSecurityException("invalid Ed25519 public key: incorrect key length"); } } Ed25519PublicKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override Ed25519PublicKey parseKey(ByteString byteString); @Override void validateKey(Ed25519PublicKey keyProto); }
Ed25519PublicKeyManager extends KeyTypeManager<Ed25519PublicKey> { @Override public void validateKey(Ed25519PublicKey keyProto) throws GeneralSecurityException { Validators.validateVersion(keyProto.getVersion(), getVersion()); if (keyProto.getKeyValue().size() != Ed25519Verify.PUBLIC_KEY_LEN) { throw new GeneralSecurityException("invalid Ed25519 public key: incorrect key length"); } } Ed25519PublicKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override Ed25519PublicKey parseKey(ByteString byteString); @Override void validateKey(Ed25519PublicKey keyProto);  }