Skip to content

Commit

Permalink
Rollback a change in the Aws/Gcp Kms Client tests.
Browse files Browse the repository at this point in the history
Also, lift visibility restrictions of methods which should be just deprecated.

PiperOrigin-RevId: 565624093
Change-Id: Ic81ae2f0b1973b8313fecd68efb5092269f00d6b
  • Loading branch information
tholenst authored and copybara-github committed Sep 15, 2023
1 parent fc41148 commit 668bff6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Aead getAead(String uri) throws GeneralSecurityException {
* an envelope {@code Aead} using {@code KmsEnvelopeAead.create}.
*/
@Deprecated
/* OSS: public */ static void register(Optional<String> keyUri, Optional<String> credentialPath)
public static void register(Optional<String> keyUri, Optional<String> credentialPath)
throws GeneralSecurityException {
GcpKmsClient client;
if (keyUri.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ java_test(
"@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
"@tink_java//src/main/java/com/google/crypto/tink/aead:aead_config",
"@tink_java//src/main/java/com/google/crypto/tink/aead:kms_aead_key_manager",
"@tink_java//src/main/java/com/google/crypto/tink/aead:kms_envelope_aead",
"@tink_java//src/main/java/com/google/crypto/tink/aead:kms_envelope_aead_key_manager",
"@tink_java//src/main/java/com/google/crypto/tink/aead:predefined_aead_parameters",
"//src/main/java/com/google/crypto/tink/integration/gcpkms:fake_cloud_kms",
"//src/main/java/com/google/crypto/tink/integration/gcpkms:gcp_kms_client",
"@maven//:com_google_truth_truth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
import com.google.crypto.tink.KmsClientsTestUtil;
import com.google.crypto.tink.aead.AeadConfig;
import com.google.crypto.tink.aead.KmsAeadKeyManager;
import com.google.crypto.tink.aead.KmsEnvelopeAead;
import com.google.crypto.tink.aead.KmsEnvelopeAeadKeyManager;
import com.google.crypto.tink.aead.PredefinedAeadParameters;
import java.security.GeneralSecurityException;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -110,11 +108,14 @@ public void clientBoundToKeyUri_createKmsEnvelopeAead_works() throws Exception {
String keyUri =
"gcp-kms://projects/tink-test/locations/global/keyRings/unit-test/cryptoKeys/aead-key";

KmsClient client = new GcpKmsClient(keyUri).withCloudKms(new FakeCloudKms(asList(keyId)));
// Register a client bound to a single key.
registerGcpKmsClient(keyUri, new FakeCloudKms(asList(keyId)));

Aead kmsEnvelopeAead =
KmsEnvelopeAead.create(
PredefinedAeadParameters.AES128_CTR_HMAC_SHA256, client.getAead(keyUri));
// Create an envelope encryption AEAD primitive
KeyTemplate dekTemplate = KeyTemplates.get("AES128_CTR_HMAC_SHA256_RAW");
KeyTemplate envelopeTemplate = KmsEnvelopeAeadKeyManager.createKeyTemplate(keyUri, dekTemplate);
KeysetHandle handle = KeysetHandle.generateNew(envelopeTemplate);
Aead kmsEnvelopeAead = handle.getPrimitive(Aead.class);

byte[] plaintext = "plaintext".getBytes(UTF_8);
byte[] associatedData = "associatedData".getBytes(UTF_8);
Expand Down

0 comments on commit 668bff6

Please sign in to comment.