Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keyvault] az keyvault key: sign and verify #29476

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/azure-cli/azure/cli/command_modules/keyvault/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,11 @@ def decrypt_key(cmd, client, algorithm, value, iv=None, tag=None, aad=None,


def sign_key(cmd, client, algorithm, digest, name=None, version=None):
import base64
SignatureAlgorithm = cmd.loader.get_sdk('SignatureAlgorithm', mod='crypto._enums',
resource_type=ResourceType.DATA_KEYVAULT_KEYS)
crypto_client = client.get_cryptography_client(name, key_version=version)
return crypto_client.sign(SignatureAlgorithm(algorithm), digest.encode('utf-8'))
return crypto_client.sign(SignatureAlgorithm(algorithm), base64.b64decode(digest))


def verify_key(cmd, client, algorithm, digest, signature, name=None, version=None):
Expand All @@ -1199,7 +1200,7 @@ def verify_key(cmd, client, algorithm, digest, signature, name=None, version=Non
resource_type=ResourceType.DATA_KEYVAULT_KEYS)
crypto_client = client.get_cryptography_client(name, key_version=version)
return crypto_client.verify(SignatureAlgorithm(algorithm),
digest.encode('utf-8'),
base64.b64decode(digest),
base64.b64decode(signature.encode('utf-8')))


Expand Down
Loading