use of com.google.crypto.tink.KeysetWriter in project tink by google.
the class CreatePublicKeysetCommand method create.
/**
* Extracts public keys from {@code inputStream} (using {@code credentialPath} and
* {@code masterKeyUri} to decrypt if it is encrypted) and writes public keys to
* {@code outputStream}.
*/
public static void create(OutputStream outputStream, String outFormat, InputStream inputStream, String inFormat, String masterKeyUri, String credentialPath) throws Exception {
KeysetHandle handle = TinkeyUtil.getKeysetHandle(inputStream, inFormat, masterKeyUri, credentialPath);
KeysetWriter writer = TinkeyUtil.createKeysetWriter(outputStream, outFormat);
CleartextKeysetHandle.write(handle.getPublicKeysetHandle(), writer);
}
use of com.google.crypto.tink.KeysetWriter in project tink by google.
the class TinkeyUtil method writeKeyset.
/**
* Writes the keyset managed by {@code handle} to {@code outputStream} with format {@code
* outFormat}. Maybe encrypt it with {@code masterKeyUri} and {@code credentialPath}.
*/
public static void writeKeyset(KeysetHandle handle, OutputStream outputStream, String outFormat, String masterKeyUri, String credentialPath) throws GeneralSecurityException, IOException {
KeysetWriter writer = createKeysetWriter(outputStream, outFormat);
if (masterKeyUri != null) {
Aead masterKey = KmsClients.getAutoLoaded(masterKeyUri).withCredentials(credentialPath).getAead(masterKeyUri);
handle.write(writer, masterKey);
} else {
CleartextKeysetHandle.write(handle, writer);
}
}
Aggregations