@Test public void validateKeyFormat() throws Exception { new ChaCha20Poly1305KeyManager() .keyFactory() .validateKeyFormat(ChaCha20Poly1305KeyFormat.getDefaultInstance()); }
@Override public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() { return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>( ChaCha20Poly1305KeyFormat.class) { @Override public void validateKeyFormat(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException {} @Override public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString) throws InvalidProtocolBufferException { return ChaCha20Poly1305KeyFormat.parseFrom( byteString, ExtensionRegistryLite.getEmptyRegistry()); } @Override public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException { return ChaCha20Poly1305Key.newBuilder() .setVersion(getVersion()) .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES))) .build(); } }; }
ChaCha20Poly1305KeyManager extends KeyTypeManager<ChaCha20Poly1305Key> { @Override public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() { return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>( ChaCha20Poly1305KeyFormat.class) { @Override public void validateKeyFormat(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException {} @Override public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString) throws InvalidProtocolBufferException { return ChaCha20Poly1305KeyFormat.parseFrom( byteString, ExtensionRegistryLite.getEmptyRegistry()); } @Override public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException { return ChaCha20Poly1305Key.newBuilder() .setVersion(getVersion()) .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES))) .build(); } }; } }
ChaCha20Poly1305KeyManager extends KeyTypeManager<ChaCha20Poly1305Key> { @Override public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() { return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>( ChaCha20Poly1305KeyFormat.class) { @Override public void validateKeyFormat(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException {} @Override public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString) throws InvalidProtocolBufferException { return ChaCha20Poly1305KeyFormat.parseFrom( byteString, ExtensionRegistryLite.getEmptyRegistry()); } @Override public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException { return ChaCha20Poly1305Key.newBuilder() .setVersion(getVersion()) .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES))) .build(); } }; } ChaCha20Poly1305KeyManager(); }
ChaCha20Poly1305KeyManager extends KeyTypeManager<ChaCha20Poly1305Key> { @Override public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() { return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>( ChaCha20Poly1305KeyFormat.class) { @Override public void validateKeyFormat(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException {} @Override public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString) throws InvalidProtocolBufferException { return ChaCha20Poly1305KeyFormat.parseFrom( byteString, ExtensionRegistryLite.getEmptyRegistry()); } @Override public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException { return ChaCha20Poly1305Key.newBuilder() .setVersion(getVersion()) .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES))) .build(); } }; } ChaCha20Poly1305KeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(ChaCha20Poly1305Key key); @Override ChaCha20Poly1305Key parseKey(ByteString byteString); @Override KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate chaCha20Poly1305Template(); static final KeyTemplate rawChaCha20Poly1305Template(); }
ChaCha20Poly1305KeyManager extends KeyTypeManager<ChaCha20Poly1305Key> { @Override public KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory() { return new KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key>( ChaCha20Poly1305KeyFormat.class) { @Override public void validateKeyFormat(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException {} @Override public ChaCha20Poly1305KeyFormat parseKeyFormat(ByteString byteString) throws InvalidProtocolBufferException { return ChaCha20Poly1305KeyFormat.parseFrom( byteString, ExtensionRegistryLite.getEmptyRegistry()); } @Override public ChaCha20Poly1305Key createKey(ChaCha20Poly1305KeyFormat format) throws GeneralSecurityException { return ChaCha20Poly1305Key.newBuilder() .setVersion(getVersion()) .setKeyValue(ByteString.copyFrom(Random.randBytes(KEY_SIZE_IN_BYTES))) .build(); } }; } ChaCha20Poly1305KeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(ChaCha20Poly1305Key key); @Override ChaCha20Poly1305Key parseKey(ByteString byteString); @Override KeyFactory<ChaCha20Poly1305KeyFormat, ChaCha20Poly1305Key> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate chaCha20Poly1305Template(); static final KeyTemplate rawChaCha20Poly1305Template();  }