Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671003827
Change-Id: I31d0b83841fc29a5635c170c85d219b85b6b8fac
  • Loading branch information
kluever authored and copybara-github committed Sep 4, 2024
1 parent 8fd2e9b commit b046b13
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.TinkProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
Expand Down Expand Up @@ -131,7 +132,7 @@ public void testAddKey_binaryEncrypted_works() throws Exception {

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle inputKeyset =
Expand Down Expand Up @@ -181,7 +182,7 @@ public void testAddKey_jsonEncrypted_works() throws Exception {

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle inputKeyset =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.TinkProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void setUpEncryption() throws Exception {
TinkeyTestKmsClient.createCredentialFile(credentialFile);

masterKeyAeadKeyset = KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.TinkProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testCreateCleartext_withMasterKey_shouldCreateNewKeyset() throws Exc

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

String commandLine =
Expand Down Expand Up @@ -148,7 +149,7 @@ public void testCreateCleartext_withMasterKey_jsonFormat_shouldCreateNewKeyset()

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

String commandLine =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.crypto.tink.Key;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.PrivateKey;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.TinkProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void testCreatePublicKeyset_ed25519_encrypted_json_works() throws Excepti

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle privateKeyset =
Expand Down Expand Up @@ -170,7 +171,7 @@ public void testCreatePublicKeyset_ed25519_encrypted_jsonBinaryMixed_works() thr

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle privateKeyset =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.InsecureSecretKeyAccess;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
import com.google.crypto.tink.TinkProtoKeysetFormat;
import com.google.crypto.tink.aead.AeadConfig;
Expand Down Expand Up @@ -133,7 +134,7 @@ public void testRotateKey_binaryEncrypted_works() throws Exception {

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle inputKeyset =
Expand Down Expand Up @@ -183,7 +184,7 @@ public void testRotateKey_jsonEncrypted_works() throws Exception {

KeysetHandle masterKeyAeadKeyset =
KeysetHandle.generateNew(PredefinedAeadParameters.AES128_GCM);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(Aead.class);
Aead masterKeyAead = masterKeyAeadKeyset.getPrimitive(RegistryConfiguration.get(), Aead.class);
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(masterKeyAeadKeyset);

KeysetHandle inputKeyset =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.crypto.tink.Aead;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.KmsClient;
import com.google.crypto.tink.RegistryConfiguration;
import com.google.crypto.tink.aead.AeadConfig;
import com.google.crypto.tink.aead.PredefinedAeadParameters;
import java.nio.file.Files;
Expand Down Expand Up @@ -54,7 +55,7 @@ public void test_clientCanBeLoadedWithCredential_works() throws Exception {
String masterKeyUri = TinkeyTestKmsClient.createKeyUri(handle);
Aead masterKey =
new TinkeyTestKmsClient().withCredentials(credentialPath.toString()).getAead(masterKeyUri);
Aead manualMasterKey = handle.getPrimitive(Aead.class);
Aead manualMasterKey = handle.getPrimitive(RegistryConfiguration.get(), Aead.class);

byte[] ciphertext = manualMasterKey.encrypt(new byte[] {}, new byte[] {});
assertThat(masterKey.decrypt(ciphertext, new byte[] {})).isEqualTo(new byte[] {});
Expand Down Expand Up @@ -103,7 +104,7 @@ public void test_differentPrefix_works() throws Exception {
.newClientFor(masterKeyUri)
.withCredentials(credentialPath.toString())
.getAead(masterKeyUri);
Aead manualMasterKey = handle.getPrimitive(Aead.class);
Aead manualMasterKey = handle.getPrimitive(RegistryConfiguration.get(), Aead.class);

byte[] ciphertext = manualMasterKey.encrypt(new byte[] {}, new byte[] {});
assertThat(masterKey.decrypt(ciphertext, new byte[] {})).isEqualTo(new byte[] {});
Expand Down

0 comments on commit b046b13

Please sign in to comment.