public static void convert(OutputStream outputStream, String outFormat,
      InputStream inputStream, String inFormat,
      String masterKeyUri, String credentialPath,
      String newMasterKeyUri, String newCredentialPath)
      throws GeneralSecurityException, IOException {
    KeysetHandle handle = TinkeyUtil.getKeysetHandle(inputStream, inFormat, masterKeyUri,
        credentialPath);
    TinkeyUtil.writeKeyset(handle, outputStream, outFormat, newMasterKeyUri, newCredentialPath);
  }
Changes format, encrypts or decrypts a keyset.

<p>The keyset is read from {@code inputStream}. Its format can be either <code>json</code>
or <code>binary</code>, and is specified by {@code inFormat}. The new key is generated
from template {@code keyTemplate}. If the input keyset is encrypted, use
{@code masterKeyUri} and {@code credentialPath} to decrypt. The output keyset
is written to {@code outputStream} in {@code outFormat}, and encrypted if the
input keyset is encrypted.

@throws GeneralSecurityException if cannot encrypt/decrypt the keyset
@throws IOException if cannot read/write the keyset
tools/tinkey/src/main/java/com/google/crypto/tink/tinkey/ConvertKeysetCommand.java