From cd6717475bda17c568cb307a030abf39f2ac4950 Mon Sep 17 00:00:00 2001 From: Benson Kuang Date: Thu, 7 May 2020 18:44:20 +0000 Subject: [PATCH 1/3] Add main function to attestation verification script. fixes #3704 --- kms/attestations/verify_attestation.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/kms/attestations/verify_attestation.py b/kms/attestations/verify_attestation.py index 69c16425f78c..c6e5e224c2eb 100644 --- a/kms/attestations/verify_attestation.py +++ b/kms/attestations/verify_attestation.py @@ -14,13 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""This sample demonstrates how to verify HSM attestations using certificate -bundles obtained from Cloud HSM. +"""This application verifies HSM attestations using certificate bundles +obtained from Cloud HSM. For more information, visit https://cloud.google.com/kms/docs/attest-key. """ # [START verify_attestations] +import argparse import gzip from cryptography import exceptions @@ -69,3 +70,17 @@ def verify(attestation_file, bundle_file): continue return False # [END verify_attestations] + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description=__doc__) + parser.add_argument('attestation_file', help="Name of attestation file.") + parser.add_argument('bundle_file', help="Name of certificate bundle file.") + + args = parser.parse_args() + + if verify(args.attestation_file, args.bundle_file): + print('Signature verified.') + else: + print('Signature verification failed.') \ No newline at end of file From 464d267375c251237d185a8540894b383b3c7eab Mon Sep 17 00:00:00 2001 From: Benson Kuang Date: Wed, 13 May 2020 14:26:17 +0000 Subject: [PATCH 2/3] Add newline to end of file --- kms/attestations/verify_attestation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kms/attestations/verify_attestation.py b/kms/attestations/verify_attestation.py index c6e5e224c2eb..a26a6bf34254 100644 --- a/kms/attestations/verify_attestation.py +++ b/kms/attestations/verify_attestation.py @@ -83,4 +83,5 @@ def verify(attestation_file, bundle_file): if verify(args.attestation_file, args.bundle_file): print('Signature verified.') else: - print('Signature verification failed.') \ No newline at end of file + print('Signature verification failed.') + From f4e4c3a03fd18efe3a7a4fd53afb17bee97445f7 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Fri, 15 May 2020 19:02:50 +0000 Subject: [PATCH 3/3] remove a blank line at the end --- kms/attestations/verify_attestation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kms/attestations/verify_attestation.py b/kms/attestations/verify_attestation.py index a26a6bf34254..e534ad9eecb4 100644 --- a/kms/attestations/verify_attestation.py +++ b/kms/attestations/verify_attestation.py @@ -84,4 +84,3 @@ def verify(attestation_file, bundle_file): print('Signature verified.') else: print('Signature verification failed.') -