Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Rename create_aead to new_aead in Python HashiCorp Vault KMS inte…
Browse files Browse the repository at this point in the history
…gration

This makes it more consistent with the tink-go-hcvault implementation [1].

[1] https://github.com/tink-crypto/tink-go-hcvault/blob/f6867b9cff6fd8f6f91a88110628e8d6b7ba7e7b/integration/hcvault/hcvault_aead.go#L80

PiperOrigin-RevId: 602971968
  • Loading branch information
morambro authored and copybara-github committed Jan 31, 2024
1 parent e94e769 commit 92d1a36
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/tink/integration/hcvault/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
' install the `tink[hcvault]` extras?'
) from import_error

create_aead = _hcvault_kms_aead.create_aead
new_aead = _hcvault_kms_aead.new_aead
2 changes: 1 addition & 1 deletion python/tink/integration/hcvault/_hcvault_kms_aead.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_endpoint_paths(key_path: str) -> Tuple[str, str]:
return mount_and_key_name.groups()


def create_aead(key_path: str, client: hvac.Client) -> aead.Aead:
def new_aead(key_path: str, client: hvac.Client) -> aead.Aead:
return _HcVaultKmsAead(client, key_path)


Expand Down
6 changes: 3 additions & 3 deletions python/tink/integration/hcvault/_hcvault_kms_aead_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def tearDown(self):

def test_encrypt_decrypt(self):
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
vaultaead = hcvault.create_aead(_KEY_PATH, client)
vaultaead = hcvault.new_aead(_KEY_PATH, client)
plaintext = b'hello'
associated_data = b'world'
ciphertext = vaultaead.encrypt(plaintext, associated_data)
Expand All @@ -133,7 +133,7 @@ def test_encrypt_decrypt(self):

def test_invalid_context(self):
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
vaultaead = hcvault.create_aead(_KEY_PATH, client)
vaultaead = hcvault.new_aead(_KEY_PATH, client)

plaintext = b'helloworld'
ciphertext = vaultaead.encrypt(plaintext, b'')
Expand All @@ -144,7 +144,7 @@ def test_invalid_context(self):
def test_encrypt_with_bad_uri(self):
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
with self.assertRaises(tink.TinkError):
hcvault.create_aead(_GCP_KEY_URI, client)
hcvault.new_aead(_GCP_KEY_URI, client)

@parameterized.named_parameters([
('simple', '/transit/keys/key-1', 'transit', 'key-1'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setUp(self):
self.client = hvac.Client(url=_VAULT_ADDR, token=_VAULT_TOKEN, verify=False)

def test_encrypt_decrypt(self):
vaultaead = hcvault.create_aead(_KEY_PATH, self.client)
vaultaead = hcvault.new_aead(_KEY_PATH, self.client)

plaintext = b'hello'
associated_data = b'world'
Expand All @@ -64,7 +64,7 @@ def test_encrypt_decrypt(self):
self.assertEqual(plaintext, vaultaead.decrypt(ciphertext, b''))

def test_corrupted_ciphertext(self):
vaultaead = hcvault.create_aead(_KEY_PATH, self.client)
vaultaead = hcvault.new_aead(_KEY_PATH, self.client)

plaintext = b'helloworld'
ciphertext = vaultaead.encrypt(plaintext, b'')
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_corrupted_ciphertext(self):
def test_encrypt_with_bad_client(self):
with self.assertRaises(tink.TinkError):
bad_client = hvac.Client(url=_VAULT_ADDR, token=_BAD_TOKEN, verify=False)
vaultaead = hcvault.create_aead(_KEY_PATH, bad_client)
vaultaead = hcvault.new_aead(_KEY_PATH, bad_client)

plaintext = b'hello'
associated_data = b'world'
Expand Down

0 comments on commit 92d1a36

Please sign in to comment.