From fe376d907b90298fb19676adbaabcccf92b27e36 Mon Sep 17 00:00:00 2001 From: YouTube Embedded Player Date: Fri, 9 Jun 2023 00:08:51 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 538999592 --- .../com/google/rcat/cli/KeysetHandleConverter.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/cli/src/main/java/com/google/rcat/cli/KeysetHandleConverter.java b/tools/cli/src/main/java/com/google/rcat/cli/KeysetHandleConverter.java index 1404eb3..f4054fc 100644 --- a/tools/cli/src/main/java/com/google/rcat/cli/KeysetHandleConverter.java +++ b/tools/cli/src/main/java/com/google/rcat/cli/KeysetHandleConverter.java @@ -16,20 +16,18 @@ package com.google.rcat.cli; -import com.google.crypto.tink.CleartextKeysetHandle; -import com.google.crypto.tink.JsonKeysetReader; +import com.google.crypto.tink.InsecureSecretKeyAccess; import com.google.crypto.tink.KeysetHandle; -import java.io.File; -import java.io.FileInputStream; +import com.google.crypto.tink.TinkJsonProtoKeysetFormat; +import java.nio.file.Files; +import java.nio.file.Paths; import picocli.CommandLine.ITypeConverter; /** Converts the file content at {@code filePath} in a KeysetHandle. */ final class KeysetHandleConverter implements ITypeConverter { @Override public KeysetHandle convert(String filePath) throws Exception { - // Public Key can be read without `CleartextKeysetHandle` using the normal KeysetHandle API. - // This is an effort to centralize the logic. - return CleartextKeysetHandle.read( - JsonKeysetReader.withInputStream(new FileInputStream(new File(filePath)))); + return TinkJsonProtoKeysetFormat.parseKeyset( + Files.readString(Paths.get(filePath)), InsecureSecretKeyAccess.get()); } }