pax_global_header00006660000000000000000000000064146174351750014527gustar00rootroot0000000000000052 comment=0d66c785167cc5e99b28ad5a622a84eb8ce70a39 tink-go-gcpkms-2.2.0/000077500000000000000000000000001461743517500143625ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/.bazelrc000066400000000000000000000007301461743517500160050ustar00rootroot00000000000000# Enables automatic per-platform configs. common --enable_platform_specific_config # Minumum C++ version. Override it building this project with # `bazel build --cxxopt='-std=c++' --host_cxxopt='c++' ...` # (Both -std and --host_cxxopt must be set to force the desired version.) build:linux --cxxopt='-std=c++14' --host_cxxopt='-std=c++14' build:macos --cxxopt='-std=c++14' --host_cxxopt='-std=c++14' build:windows --cxxopt='/std:c++14' --host_cxxopt='/std:c++14' tink-go-gcpkms-2.2.0/.bazelversion000066400000000000000000000000061461743517500170620ustar00rootroot000000000000006.4.0 tink-go-gcpkms-2.2.0/BUILD.bazel000066400000000000000000000012121461743517500162340ustar00rootroot00000000000000load("@io_bazel_rules_go//go:def.bzl", "nogo") load("@bazel_gazelle//:def.bzl", "gazelle") package(default_visibility = ["//:__subpackages__"]) licenses(["notice"]) nogo( name = "tink_nogo", vet = True, visibility = ["//visibility:public"], ) # gazelle:prefix github.com/tink-crypto/tink-go-gcpkms/v2 # gazelle:exclude proto/*.proto gazelle( name = "gazelle", args = [ "-go_naming_convention=import_alias", ], ) gazelle( name = "gazelle-update-repos", args = [ "-from_file=go.mod", "-to_macro=deps.bzl%tink_go_gcpkms_dependencies", "-prune", ], command = "update-repos", ) tink-go-gcpkms-2.2.0/LICENSE000066400000000000000000000261361461743517500153770ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. tink-go-gcpkms-2.2.0/MODULE.bazel000066400000000000000000000013071461743517500163670ustar00rootroot00000000000000module( name = "tink-go-gcpkms", version = "2.2.0", ) bazel_dep( name = "platforms", version = "0.0.8", ) bazel_dep( name = "rules_go", version = "0.44.2", repo_name = "io_bazel_rules_go" ) bazel_dep( name = "gazelle", version = "0.35.0", repo_name = "bazel_gazelle" ) go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") go_sdk.download(version = "1.20.13") go_sdk.nogo(nogo = "@//:tink_nogo") go_sdk.host() go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") go_deps.from_file(go_mod = "//:go.mod") # Direct Go dependencies. use_repo( go_deps, "com_github_tink_crypto_tink_go_v2", "org_golang_google_api", ) tink-go-gcpkms-2.2.0/README.md000066400000000000000000000041531461743517500156440ustar00rootroot00000000000000# Tink Go Google Cloud KMS extension [tink_go_gcpkms_bazel_badge_gcp_ubuntu]: https://storage.googleapis.com/tink-kokoro-build-badges/tink-go-gcpkms-bazel-gcp-ubuntu.svg [tink_go_gcpkms_gomod_badge_gcp_ubuntu]: https://storage.googleapis.com/tink-kokoro-build-badges/tink-go-gcpkms-gomod-gcp-ubuntu.svg [tink_go_gcpkms_bazel_badge_macos]: https://storage.googleapis.com/tink-kokoro-build-badges/tink-go-gcpkms-bazel-macos-external.svg [tink_go_gcpkms_gomod_badge_macos]: https://storage.googleapis.com/tink-kokoro-build-badges/tink-go-gcpkms-gomod-macos-external.svg **Test** | **GCP Ubuntu** | **MacOS** ------------ | -------------------------------------------------------------- | --------- Tink (Bazel) | [![Bazel_GcpUbuntu][tink_go_gcpkms_bazel_badge_gcp_ubuntu]](#) | [![Bazel_MacOs][tink_go_gcpkms_bazel_badge_macos]](#) Tink (Gomod) | [![Gomod_GcpUbuntu][tink_go_gcpkms_gomod_badge_gcp_ubuntu]](#) | [![Gomod_MacOs][tink_go_gcpkms_gomod_badge_macos]](#) This is an extension to the [Tink Go](https://github.com/tink-crypto/tink-go) library that provides support for Google Cloud KMS. The official documentation is available at https://developers.google.com/tink. ## Contact and mailing list If you want to contribute, please read [CONTRIBUTING](docs/CONTRIBUTING.md) and send us pull requests. You can also report bugs or file feature requests. If you'd like to talk to the developers or get notified about major product updates, you may want to subscribe to our [mailing list](https://groups.google.com/forum/#!forum/tink-users). ## Maintainers Tink is maintained by (A-Z): - Moreno Ambrosin - Taymon Beal - William Conner - Thomas Holenstein - Stefan Kölbl - Charles Lee - Cindy Lin - Fernando Lobato Meeser - Ioana Nedelcu - Sophie Schmieg - Elizaveta Tretiakova - Jürg Wullschleger Alumni: - Haris Andrianakis - Daniel Bleichenbacher - Tanuj Dhir - Thai Duong - Atul Luykx - Rafael Misoczki - Quan Nguyen - Bartosz Przydatek - Enzo Puig - Laurent Simon - Veronika Slívová - Paula Vidas tink-go-gcpkms-2.2.0/WORKSPACE000066400000000000000000000033311461743517500156430ustar00rootroot00000000000000workspace(name = "tink_go_gcpkms") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Release X.25.2 from 2024-01-09. http_archive( name = "com_google_protobuf", sha256 = "5e8e2b369a6fcaa24fada21135782eef147aec467cd286c108936a3277e88d2b", strip_prefix = "protobuf-25.2", urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protobuf-25.2.zip"], ) # Release from 2023-04-20 http_archive( name = "io_bazel_rules_go", sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", ], ) # Release from 2023-01-14 http_archive( name = "bazel_gazelle", sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", ], ) load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") # Tink Go Google Cloud KMS Deps. load("//:deps.bzl", "tink_go_gcpkms_dependencies") load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") protobuf_deps() # gazelle:repository_macro deps.bzl%tink_go_gcpkms_dependencies tink_go_gcpkms_dependencies() go_rules_dependencies() go_register_toolchains( nogo = "@//:tink_nogo", version = "1.20.10", ) gazelle_dependencies() tink-go-gcpkms-2.2.0/deps.bzl000066400000000000000000000266271461743517500160430ustar00rootroot00000000000000"""Tink Go Google Cloud KMS dependencies.""" load("@bazel_gazelle//:deps.bzl", "go_repository") # Placeholder for internal instructions to autogenerate dependencies. def tink_go_gcpkms_dependencies(): """Loads Tink Go Google Cloud KMS dependencies. These are autogenerated running `go mod tidy && bazel run //:gazelle-update-repos`. """ go_repository( name = "co_honnef_go_tools", importpath = "honnef.co/go/tools", sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=", version = "v0.0.0-20190523083050-ea95bdfd59fc", ) go_repository( name = "com_github_burntsushi_toml", importpath = "github.com/BurntSushi/toml", sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", version = "v0.3.1", ) go_repository( name = "com_github_census_instrumentation_opencensus_proto", importpath = "github.com/census-instrumentation/opencensus-proto", sum = "h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=", version = "v0.4.1", ) go_repository( name = "com_github_cespare_xxhash_v2", importpath = "github.com/cespare/xxhash/v2", sum = "h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=", version = "v2.2.0", ) go_repository( name = "com_github_client9_misspell", importpath = "github.com/client9/misspell", sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", version = "v0.3.4", ) go_repository( name = "com_github_cncf_udpa_go", importpath = "github.com/cncf/udpa/go", sum = "h1:QQ3GSy+MqSHxm/d8nCtnAiZdYFd45cYZPs8vOOIYKfk=", version = "v0.0.0-20220112060539-c52dc94e7fbe", ) go_repository( name = "com_github_cncf_xds_go", importpath = "github.com/cncf/xds/go", sum = "h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k=", version = "v0.0.0-20230607035331-e9ce68804cb4", ) go_repository( name = "com_github_davecgh_go_spew", importpath = "github.com/davecgh/go-spew", sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", version = "v1.1.1", ) go_repository( name = "com_github_envoyproxy_go_control_plane", importpath = "github.com/envoyproxy/go-control-plane", sum = "h1:wSUXTlLfiAQRWs2F+p+EKOY9rUyis1MyGqJ2DIk5HpM=", version = "v0.11.1", ) go_repository( name = "com_github_envoyproxy_protoc_gen_validate", importpath = "github.com/envoyproxy/protoc-gen-validate", sum = "h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=", version = "v1.0.2", ) go_repository( name = "com_github_golang_glog", importpath = "github.com/golang/glog", sum = "h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=", version = "v1.1.0", ) go_repository( name = "com_github_golang_groupcache", importpath = "github.com/golang/groupcache", sum = "h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=", version = "v0.0.0-20210331224755-41bb18bfe9da", ) go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=", version = "v1.1.1", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", sum = "h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=", version = "v1.5.3", ) go_repository( name = "com_github_google_go_cmp", importpath = "github.com/google/go-cmp", sum = "h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=", version = "v0.6.0", ) go_repository( name = "com_github_google_go_pkcs11", importpath = "github.com/google/go-pkcs11", sum = "h1:OF1IPgv+F4NmqmJ98KTjdN97Vs1JxDPB3vbmYzV2dpk=", version = "v0.2.1-0.20230907215043-c6f79328ddf9", ) go_repository( name = "com_github_google_s2a_go", importpath = "github.com/google/s2a-go", sum = "h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=", version = "v0.1.7", ) go_repository( name = "com_github_google_uuid", importpath = "github.com/google/uuid", sum = "h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=", version = "v1.3.1", ) go_repository( name = "com_github_googleapis_enterprise_certificate_proxy", importpath = "github.com/googleapis/enterprise-certificate-proxy", sum = "h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ=", version = "v0.3.1", ) go_repository( name = "com_github_googleapis_gax_go_v2", importpath = "github.com/googleapis/gax-go/v2", sum = "h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=", version = "v2.12.0", ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) go_repository( name = "com_github_prometheus_client_model", importpath = "github.com/prometheus/client_model", sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=", version = "v0.0.0-20190812154241-14fe0d1b01d4", ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", sum = "h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=", version = "v0.5.0", ) go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", sum = "h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=", version = "v1.8.1", ) go_repository( name = "com_github_tink_crypto_tink_go_v2", importpath = "github.com/tink-crypto/tink-go/v2", sum = "h1:QXFBguwMwTIaU17EgZpEJWsUSc60b1BAGTzBIoMdmok=", version = "v2.1.0", ) go_repository( name = "com_google_cloud_go", importpath = "cloud.google.com/go", sum = "h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA=", version = "v0.110.2", ) go_repository( name = "com_google_cloud_go_compute", importpath = "cloud.google.com/go/compute", sum = "h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY=", version = "v1.23.0", ) go_repository( name = "com_google_cloud_go_compute_metadata", importpath = "cloud.google.com/go/compute/metadata", sum = "h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=", version = "v0.2.3", ) go_repository( name = "in_gopkg_check_v1", importpath = "gopkg.in/check.v1", sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=", version = "v0.0.0-20161208181325-20d25e280405", ) go_repository( name = "in_gopkg_yaml_v3", importpath = "gopkg.in/yaml.v3", sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", version = "v3.0.1", ) go_repository( name = "io_opencensus_go", importpath = "go.opencensus.io", sum = "h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=", version = "v0.24.0", ) go_repository( name = "org_golang_google_api", importpath = "google.golang.org/api", sum = "h1:Can3FaQo9LlVqxJCodNmeZW/ib3/qKAY3rFeXiHo5gc=", version = "v0.147.0", ) go_repository( name = "org_golang_google_appengine", importpath = "google.golang.org/appengine", sum = "h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=", version = "v1.6.7", ) go_repository( name = "org_golang_google_genproto", importpath = "google.golang.org/genproto", sum = "h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0=", version = "v0.0.0-20231002182017-d307bd883b97", ) go_repository( name = "org_golang_google_genproto_googleapis_api", importpath = "google.golang.org/genproto/googleapis/api", sum = "h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU=", version = "v0.0.0-20231002182017-d307bd883b97", ) go_repository( name = "org_golang_google_genproto_googleapis_bytestream", importpath = "google.golang.org/genproto/googleapis/bytestream", sum = "h1:9tZedXBlwql0v/dLZx1E4Rcz9ESc8j1KZk71903wKEg=", version = "v0.0.0-20231009173412-8bfb1ae86b6c", ) go_repository( name = "org_golang_google_genproto_googleapis_rpc", importpath = "google.golang.org/genproto/googleapis/rpc", sum = "h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY=", version = "v0.0.0-20231009173412-8bfb1ae86b6c", ) go_repository( name = "org_golang_google_grpc", importpath = "google.golang.org/grpc", sum = "h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=", version = "v1.58.3", ) go_repository( name = "org_golang_google_protobuf", importpath = "google.golang.org/protobuf", sum = "h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=", version = "v1.31.0", ) go_repository( name = "org_golang_x_crypto", importpath = "golang.org/x/crypto", sum = "h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=", version = "v0.17.0", ) go_repository( name = "org_golang_x_exp", importpath = "golang.org/x/exp", sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=", version = "v0.0.0-20190121172915-509febef88a4", ) go_repository( name = "org_golang_x_lint", importpath = "golang.org/x/lint", sum = "h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=", version = "v0.0.0-20190313153728-d0100b6bd8b3", ) go_repository( name = "org_golang_x_mod", importpath = "golang.org/x/mod", sum = "h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=", version = "v0.8.0", ) go_repository( name = "org_golang_x_net", importpath = "golang.org/x/net", sum = "h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=", version = "v0.17.0", ) go_repository( name = "org_golang_x_oauth2", importpath = "golang.org/x/oauth2", sum = "h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=", version = "v0.13.0", ) go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", sum = "h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=", version = "v0.4.0", ) go_repository( name = "org_golang_x_sys", importpath = "golang.org/x/sys", sum = "h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=", version = "v0.15.0", ) go_repository( name = "org_golang_x_term", importpath = "golang.org/x/term", sum = "h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=", version = "v0.15.0", ) go_repository( name = "org_golang_x_text", importpath = "golang.org/x/text", sum = "h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=", version = "v0.14.0", ) go_repository( name = "org_golang_x_tools", importpath = "golang.org/x/tools", sum = "h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=", version = "v0.6.0", ) go_repository( name = "org_golang_x_xerrors", importpath = "golang.org/x/xerrors", sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", version = "v0.0.0-20191204190536-9bdfabe68543", ) tink-go-gcpkms-2.2.0/docs/000077500000000000000000000000001461743517500153125ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/docs/CONTRIBUTING.md000066400000000000000000000002151461743517500175410ustar00rootroot00000000000000# How to contribute Please see the [developer documentation](https://developers.google.com/tink/contributing) on how to contribute to Tink. tink-go-gcpkms-2.2.0/docs/SECURITY.md000066400000000000000000000004131461743517500171010ustar00rootroot00000000000000To report a security issue, please use http://g.co/vulnz. We use http://g.co/vulnz for our intake and coordination, and disclose vulnerabilities using GitHub Security Advisory. The Google Security Team will respond within 5 working days of your report on g.co/vulnz. tink-go-gcpkms-2.2.0/go.mod000066400000000000000000000020501461743517500154650ustar00rootroot00000000000000module github.com/tink-crypto/tink-go-gcpkms/v2 go 1.21 require ( github.com/tink-crypto/tink-go/v2 v2.1.0 google.golang.org/api v0.147.0 ) require ( cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/uuid v1.3.1 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.13.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect ) tink-go-gcpkms-2.2.0/go.sum000066400000000000000000000333331461743517500155220ustar00rootroot00000000000000cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.1 h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ= github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tink-crypto/tink-go/v2 v2.1.0 h1:QXFBguwMwTIaU17EgZpEJWsUSc60b1BAGTzBIoMdmok= github.com/tink-crypto/tink-go/v2 v2.1.0/go.mod h1:y1TnYFt1i2eZVfx4OGc+C+EMp4CoKWAw2VSEuoicHHI= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.147.0 h1:Can3FaQo9LlVqxJCodNmeZW/ib3/qKAY3rFeXiHo5gc= google.golang.org/api v0.147.0/go.mod h1:pQ/9j83DcmPd/5C9e2nFOdjjNkDZ1G+zkbK2uvdkJMs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= tink-go-gcpkms-2.2.0/integration/000077500000000000000000000000001461743517500167055ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/integration/gcpkms/000077500000000000000000000000001461743517500201715ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/integration/gcpkms/BUILD.bazel000066400000000000000000000022741461743517500220540ustar00rootroot00000000000000load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//:__subpackages__"]) licenses(["notice"]) # keep go_library( name = "gcpkms", srcs = [ "gcp_kms_aead.go", "gcp_kms_client.go", ], importpath = "github.com/tink-crypto/tink-go-gcpkms/v2/integration/gcpkms", visibility = ["//visibility:public"], deps = [ "@com_github_tink_crypto_tink_go_v2//core/registry", "@com_github_tink_crypto_tink_go_v2//tink", "@org_golang_google_api//cloudkms/v1:cloudkms", "@org_golang_google_api//option", ], ) go_test( name = "gcpkms_test", srcs = [ "gcp_kms_aead_test.go", "gcp_kms_client_test.go", "gcp_kms_integration_test.go", ], data = [ # Google Cloud KMS credentials to be used. "//testdata/gcp:credentials", ], embed = [":gcpkms"], tags = ["manual"], deps = [ "@com_github_tink_crypto_tink_go_v2//aead", "@org_golang_google_api//cloudkms/v1:cloudkms", "@org_golang_google_api//option", ], ) alias( name = "go_default_library", actual = ":gcpkms", visibility = ["//visibility:public"], ) tink-go-gcpkms-2.2.0/integration/gcpkms/gcp_kms_aead.go000066400000000000000000000114671461743517500231260ustar00rootroot00000000000000// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package gcpkms import ( "encoding/base64" "fmt" "hash/crc32" "google.golang.org/api/cloudkms/v1" "github.com/tink-crypto/tink-go/v2/tink" ) // gcpAEAD represents a GCP KMS service to a particular URI. type gcpAEAD struct { keyName string kms cloudkms.Service } var _ tink.AEAD = (*gcpAEAD)(nil) // newGCPAEAD returns a new GCP KMS service. func newGCPAEAD(keyName string, kms *cloudkms.Service) tink.AEAD { return &gcpAEAD{ keyName: keyName, kms: *kms, } } // Encrypt calls GCP KMS to encrypt the plaintext with associatedData and returns the resulting ciphertext. // It returns an error if the call to KMS fails or if the response returned by KMS does not pass integrity verification // (http://cloud.google.com/kms/docs/data-integrity-guidelines#calculating_and_verifying_checksums). func (a *gcpAEAD) Encrypt(plaintext, associatedData []byte) ([]byte, error) { req := &cloudkms.EncryptRequest{ Plaintext: base64.URLEncoding.EncodeToString(plaintext), PlaintextCrc32c: computeChecksum(plaintext), AdditionalAuthenticatedData: base64.URLEncoding.EncodeToString(associatedData), AdditionalAuthenticatedDataCrc32c: computeChecksum(associatedData), // Send the integrity verification fields even if their value is 0. ForceSendFields: []string{"PlaintextCrc32c", "AdditionalAuthenticatedDataCrc32c"}, } resp, err := a.kms.Projects.Locations.KeyRings.CryptoKeys.Encrypt(a.keyName, req).Do() if err != nil { return nil, err } if !resp.VerifiedPlaintextCrc32c { return nil, fmt.Errorf("KMS request for %q is missing the checksum field plaintext_crc32c, and other information may be missing from the response. Please retry a limited number of times in case the error is transient", a.keyName) } if !resp.VerifiedAdditionalAuthenticatedDataCrc32c { return nil, fmt.Errorf("KMS request for %q is missing the checksum field additional_authenticated_data_crc32c, and other information may be missing from the response. Please retry a limited number of times in case the error is transient", a.keyName) } ciphertext, err := base64.StdEncoding.DecodeString(resp.Ciphertext) if err != nil { return nil, err } if resp.CiphertextCrc32c != computeChecksum(ciphertext) { return nil, fmt.Errorf("KMS response corrupted in transit for %q: the checksum in field ciphertext_crc32c did not match the data in field ciphertext. Please retry in case this is a transient error", a.keyName) } return ciphertext, nil } // Decrypt calls GCP KMS to decrypt the ciphertext with with associatedData and returns the resulting plaintext. // It returns an error if the call to KMS fails or if the response returned by KMS does not pass integrity verification // (http://cloud.google.com/kms/docs/data-integrity-guidelines#calculating_and_verifying_checksums). func (a *gcpAEAD) Decrypt(ciphertext, associatedData []byte) ([]byte, error) { req := &cloudkms.DecryptRequest{ Ciphertext: base64.URLEncoding.EncodeToString(ciphertext), CiphertextCrc32c: computeChecksum(ciphertext), AdditionalAuthenticatedData: base64.URLEncoding.EncodeToString(associatedData), AdditionalAuthenticatedDataCrc32c: computeChecksum(associatedData), // Send the integrity verification fields even if their value is 0. ForceSendFields: []string{"CiphertextCrc32c", "AdditionalAuthenticatedDataCrc32c"}, } resp, err := a.kms.Projects.Locations.KeyRings.CryptoKeys.Decrypt(a.keyName, req).Do() if err != nil { return nil, err } plaintext, err := base64.StdEncoding.DecodeString(resp.Plaintext) if err != nil { return nil, err } if resp.PlaintextCrc32c != computeChecksum(plaintext) { return nil, fmt.Errorf("KMS response corrupted in transit for %q: the checksum in field plaintext_crc32c did not match the data in field plaintext. Please retry in case this is a transient error", a.keyName) } return plaintext, nil } // crc32cTable is used to compute checksums. It is defined as a package level variable to avoid // re-computation on every CRC calculation. var crc32cTable = crc32.MakeTable(crc32.Castagnoli) // computeChecksum returns the checksum that corresponds to the input value as an int64. func computeChecksum(value []byte) int64 { return int64(crc32.Checksum(value, crc32cTable)) } tink-go-gcpkms-2.2.0/integration/gcpkms/gcp_kms_aead_test.go000066400000000000000000000200271461743517500241550ustar00rootroot00000000000000// Copyright 2024 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package gcpkms import ( "bytes" "context" "encoding/base64" "encoding/json" "hash/crc32" "net/http" "net/http/httptest" "testing" "google.golang.org/api/cloudkms/v1" "google.golang.org/api/option" ) func initializeServerWithResponse(ctx context.Context, t *testing.T, response any) (*httptest.Server, *cloudkms.Service) { t.Helper() var b []byte switch r := response.(type) { case *cloudkms.EncryptResponse, *cloudkms.DecryptResponse: var err error b, err = json.Marshal(r) if err != nil { t.Fatalf("unable to marshal response: %v", err) } default: t.Fatalf("unsupported response type: %T", r) } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write(b) })) svc, err := cloudkms.NewService(ctx, option.WithoutAuthentication(), option.WithEndpoint(ts.URL)) if err != nil { t.Fatalf("unable to create client: %v", err) } return ts, svc } func TestEncrypt_FailsWhenPlaintextUnverifed(t *testing.T) { additionalData := []byte("additional data") ciphertext := []byte("ciphertext") ciphertextCrc32c := int64(crc32.Checksum(ciphertext, crc32.MakeTable(crc32.Castagnoli))) testcases := []struct { name string encryptResponse *cloudkms.EncryptResponse }{ { name: "verified_plaintext_crc32c is false", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString(ciphertext), CiphertextCrc32c: ciphertextCrc32c, VerifiedPlaintextCrc32c: false, VerifiedAdditionalAuthenticatedDataCrc32c: true, }, }, { name: "verified_plaintext_crc32c missing", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString(ciphertext), CiphertextCrc32c: ciphertextCrc32c, VerifiedAdditionalAuthenticatedDataCrc32c: true, }, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, tc.encryptResponse) defer ts.Close() aead := newGCPAEAD("key name", svc) // Encryption should fail for all plaintexts (empty or non-empty) _, err := aead.Encrypt([]byte("plaintext"), additionalData) if err == nil { t.Errorf("a.Encrypt err = nil, want error") } _, err = aead.Encrypt([]byte(""), additionalData) if err == nil { t.Errorf("a.Encrypt err = nil, want error") } }) } } func TestEncrypt_FailsWhenAdditionalAuthenticatedDataUnverifed(t *testing.T) { plaintext := []byte("plaintext") ciphertext := []byte("ciphertext") ciphertextCrc32c := int64(crc32.Checksum(ciphertext, crc32.MakeTable(crc32.Castagnoli))) testcases := []struct { name string encryptResponse *cloudkms.EncryptResponse }{ { name: "verified_additional_authenticated_data_crc32c is false", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString(ciphertext), CiphertextCrc32c: ciphertextCrc32c, VerifiedPlaintextCrc32c: true, VerifiedAdditionalAuthenticatedDataCrc32c: false, }, }, { name: "verified_additional_authenticated_data_crc32c missing", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString(ciphertext), CiphertextCrc32c: ciphertextCrc32c, VerifiedPlaintextCrc32c: true, }, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, tc.encryptResponse) defer ts.Close() aead := newGCPAEAD("key name", svc) // Encryption should fail for all additional authenticated data (empty or non-empty) _, err := aead.Encrypt(plaintext, []byte("additional data")) if err == nil { t.Errorf("a.Encrypt err = nil, want error") } _, err = aead.Encrypt(plaintext, []byte("")) if err == nil { t.Errorf("a.Encrypt err = nil, want error") } }) } } func TestEncrypt_FailsWithInvalidCiphertextCrc32c(t *testing.T) { testcases := []struct { name string encryptResponse *cloudkms.EncryptResponse }{ { name: "ciphertext_crc32c does not match ciphertext", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString([]byte("ciphertext")), CiphertextCrc32c: int64(1), VerifiedPlaintextCrc32c: true, VerifiedAdditionalAuthenticatedDataCrc32c: true, }, }, { name: "ciphertext_crc32c missing", encryptResponse: &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString([]byte("ciphertext")), VerifiedPlaintextCrc32c: true, VerifiedAdditionalAuthenticatedDataCrc32c: true, }, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, tc.encryptResponse) defer ts.Close() aead := newGCPAEAD("key name", svc) _, err := aead.Encrypt([]byte("plaintext"), []byte("additional data")) if err == nil { t.Errorf("a.Encrypt err = nil, want error") } }) } } func TestEncrypt_Success(t *testing.T) { ciphertext := []byte("ciphertext") ciphertextCrc32c := int64(crc32.Checksum(ciphertext, crc32.MakeTable(crc32.Castagnoli))) ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, &cloudkms.EncryptResponse{ Ciphertext: base64.StdEncoding.EncodeToString(ciphertext), CiphertextCrc32c: ciphertextCrc32c, VerifiedPlaintextCrc32c: true, VerifiedAdditionalAuthenticatedDataCrc32c: true, }) defer ts.Close() aead := newGCPAEAD("key name", svc) gotCiphertext, err := aead.Encrypt([]byte("plaintext"), []byte("additional data")) if err != nil { t.Errorf("a.Encrypt err = %q, want nil", err) } if !bytes.Equal(gotCiphertext, ciphertext) { t.Errorf("Returned ciphertext: %q, want: %q", gotCiphertext, ciphertext) } } func TestDecrypt_FailsWithInvalidPlaintextCrc32c(t *testing.T) { testcases := []struct { name string decryptResponse *cloudkms.DecryptResponse }{ { name: "plaintext_crc32c does not match plaintext", decryptResponse: &cloudkms.DecryptResponse{ Plaintext: base64.StdEncoding.EncodeToString([]byte("plaintext")), PlaintextCrc32c: int64(1), }, }, { name: "plaintext_crc32c missing", decryptResponse: &cloudkms.DecryptResponse{ Plaintext: base64.StdEncoding.EncodeToString([]byte("plaintext")), }, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, tc.decryptResponse) defer ts.Close() aead := newGCPAEAD("key name", svc) _, err := aead.Decrypt([]byte("ciphertext"), []byte("additional data")) if err == nil { t.Errorf("a.Decrypt err = nil, want error") } }) } } func TestDecrypt_Success(t *testing.T) { plaintext := []byte("plaintext") plaintextCrc32c := int64(crc32.Checksum(plaintext, crc32.MakeTable(crc32.Castagnoli))) ctx := context.Background() ts, svc := initializeServerWithResponse(ctx, t, &cloudkms.DecryptResponse{ Plaintext: base64.StdEncoding.EncodeToString(plaintext), PlaintextCrc32c: plaintextCrc32c, }) defer ts.Close() aead := newGCPAEAD("key name", svc) gotPlaintext, err := aead.Decrypt([]byte("ciphertext"), []byte("additional data")) if err != nil { t.Errorf("a.Decrypt err = %q, want nil", err) } if !bytes.Equal(gotPlaintext, plaintext) { t.Errorf("Returned plaitext: %q, want: %q", gotPlaintext, plaintext) } } tink-go-gcpkms-2.2.0/integration/gcpkms/gcp_kms_client.go000066400000000000000000000045761461743517500235150ustar00rootroot00000000000000// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package gcpkms provides integration with the GCP Cloud KMS. // Tink APIs work with GCP and AWS KMS. package gcpkms import ( "context" "errors" "fmt" "runtime" "strings" "google.golang.org/api/cloudkms/v1" "google.golang.org/api/option" "github.com/tink-crypto/tink-go/v2/core/registry" "github.com/tink-crypto/tink-go/v2/tink" ) const ( gcpPrefix = "gcp-kms://" ) var ( errCred = errors.New("invalid credential path") tinkUserAgent = "Tink/" + tink.Version + " Golang/" + runtime.Version() ) // gcpClient represents a client that connects to the GCP KMS backend. type gcpClient struct { keyURIPrefix string kms *cloudkms.Service } var _ registry.KMSClient = (*gcpClient)(nil) // NewClientWithOptions returns a new GCP KMS client with provided Google API // options to handle keys with uriPrefix prefix. // uriPrefix must have the following format: 'gcp-kms://[:path]'. func NewClientWithOptions(ctx context.Context, uriPrefix string, opts ...option.ClientOption) (registry.KMSClient, error) { if !strings.HasPrefix(strings.ToLower(uriPrefix), gcpPrefix) { return nil, fmt.Errorf("uriPrefix must start with %s", gcpPrefix) } opts = append(opts, option.WithUserAgent(tinkUserAgent)) kmsService, err := cloudkms.NewService(ctx, opts...) if err != nil { return nil, err } return &gcpClient{ keyURIPrefix: uriPrefix, kms: kmsService, }, nil } // Supported true if this client does support keyURI func (c *gcpClient) Supported(keyURI string) bool { return strings.HasPrefix(keyURI, c.keyURIPrefix) } // GetAEAD gets an AEAD backend by keyURI. func (c *gcpClient) GetAEAD(keyURI string) (tink.AEAD, error) { if !c.Supported(keyURI) { return nil, errors.New("unsupported keyURI") } keyName := strings.TrimPrefix(keyURI, gcpPrefix) return newGCPAEAD(keyName, c.kms), nil } tink-go-gcpkms-2.2.0/integration/gcpkms/gcp_kms_client_test.go000066400000000000000000000031211461743517500245350ustar00rootroot00000000000000// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package gcpkms_test import ( "context" "log" "google.golang.org/api/option" "github.com/tink-crypto/tink-go/v2/aead" "github.com/tink-crypto/tink-go-gcpkms/v2/integration/gcpkms" ) func Example() { const keyURI = "gcp-kms://......" ctx := context.Background() gcpclient, err := gcpkms.NewClientWithOptions(ctx, keyURI, option.WithCredentialsFile("/mysecurestorage/credentials.json")) if err != nil { log.Fatal(err) } kekAEAD, err := gcpclient.GetAEAD(keyURI) if err != nil { log.Fatal(err) } // Get the KMS envelope AEAD primitive. dekTemplate := aead.AES128CTRHMACSHA256KeyTemplate() primitive := aead.NewKMSEnvelopeAEAD2(dekTemplate, kekAEAD) if err != nil { log.Fatal(err) } // Use the primitive. plaintext := []byte("message") associatedData := []byte("example KMS envelope AEAD encryption") ciphertext, err := primitive.Encrypt(plaintext, associatedData) if err != nil { log.Fatal(err) } _, err = primitive.Decrypt(ciphertext, associatedData) if err != nil { log.Fatal(err) } } tink-go-gcpkms-2.2.0/integration/gcpkms/gcp_kms_integration_test.go000066400000000000000000000101201461743517500255770ustar00rootroot00000000000000// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package gcpkms_test import ( "bytes" "context" "os" "path/filepath" "testing" // Placeholder for internal flag import. // context is used to cancel outstanding requests "google.golang.org/api/option" "github.com/tink-crypto/tink-go/v2/aead" "github.com/tink-crypto/tink-go-gcpkms/v2/integration/gcpkms" ) const ( keyURI = "gcp-kms://projects/tink-test-infrastructure/locations/global/keyRings/unit-and-integration-testing/cryptoKeys/aead-key" ) var ( credFile = "testdata/gcp/credential.json" ) // Placeholder for internal initialization. func TestGetAeadWithEnvelopeAead(t *testing.T) { srcDir, ok := os.LookupEnv("TEST_SRCDIR") if !ok { t.Skip("TEST_SRCDIR not set") } workspaceDir, ok := os.LookupEnv("TEST_WORKSPACE") if !ok { t.Skip("TEST_WORKSPACE not set") } ctx := context.Background() gcpClient, err := gcpkms.NewClientWithOptions( ctx, keyURI, option.WithCredentialsFile(filepath.Join(srcDir, workspaceDir, credFile))) if err != nil { t.Fatalf("gcpkms.NewClientWithOptions() err = %q, want nil", err) } kekAEAD, err := gcpClient.GetAEAD(keyURI) if err != nil { t.Fatalf("gcpClient.GetAEAD(keyURI) err = %q, want nil", err) } dekTemplate := aead.AES128CTRHMACSHA256KeyTemplate() a := aead.NewKMSEnvelopeAEAD2(dekTemplate, kekAEAD) if err != nil { t.Fatalf("a.Encrypt(plaintext, associatedData) err = %q, want nil", err) } plaintext := []byte("message") associatedData := []byte("example KMS envelope AEAD encryption") ciphertext, err := a.Encrypt(plaintext, associatedData) if err != nil { t.Fatalf("a.Encrypt(plaintext, associatedData) err = %q, want nil", err) } gotPlaintext, err := a.Decrypt(ciphertext, associatedData) if err != nil { t.Fatalf("a.Decrypt(ciphertext, associatedData) err = %q, want nil", err) } if !bytes.Equal(gotPlaintext, plaintext) { t.Errorf("a.Decrypt() = %q, want %q", gotPlaintext, plaintext) } _, err = a.Decrypt(ciphertext, []byte("invalid associatedData")) if err == nil { t.Error("a.Decrypt(ciphertext, []byte(\"invalid associatedData\")) err = nil, want error") } } func TestAead(t *testing.T) { srcDir, ok := os.LookupEnv("TEST_SRCDIR") if !ok { t.Skip("TEST_SRCDIR not set") } workspaceDir, ok := os.LookupEnv("TEST_WORKSPACE") if !ok { t.Skip("TEST_WORKSPACE not set") } ctx := context.Background() gcpClient, err := gcpkms.NewClientWithOptions( ctx, keyURI, option.WithCredentialsFile(filepath.Join(srcDir, workspaceDir, credFile))) if err != nil { t.Fatalf("gcpkms.NewClientWithOptions() err = %q, want nil", err) } aead, err := gcpClient.GetAEAD(keyURI) if err != nil { t.Fatalf("gcpClient.GetAEAD(keyURI) err = %q, want nil", err) } testcases := []struct { name string plaintext []byte associatedData []byte }{ { name: "empty_plaintext", plaintext: []byte(""), associatedData: []byte("authenticated data"), }, { name: "empty_associated_data", plaintext: []byte("plaintext"), associatedData: []byte(""), }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ciphertext, err := aead.Encrypt(tc.plaintext, tc.associatedData) if err != nil { t.Fatalf("aead.Encrypt(plaintext, associatedData) err = %q, want nil", err) } gotPlaintext, err := aead.Decrypt(ciphertext, tc.associatedData) if err != nil { t.Fatalf("aead.Decrypt(ciphertext, associatedData) err = %q, want nil", err) } if !bytes.Equal(gotPlaintext, tc.plaintext) { t.Errorf("aead.Decrypt() = %q, want %q", gotPlaintext, tc.plaintext) } }) } } tink-go-gcpkms-2.2.0/kokoro/000077500000000000000000000000001461743517500156665ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/create_github_release_branch.sh000066400000000000000000000043701461743517500240500ustar00rootroot00000000000000#!/bin/bash # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ set -euo pipefail # Fail if RELEASE_VERSION is not set. if [[ -z "${RELEASE_VERSION:-}" ]]; then echo "RELEASE_VERSION must be set" >&2 exit 1 fi IS_KOKORO="false" if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then IS_KOKORO="true" fi readonly IS_KOKORO # If not defined, default to /tmp. : "${TMPDIR:="/tmp"}" # WARNING: Setting this environment varialble to "true" will cause this script # to actually perform a release. : "${DO_MAKE_RELEASE:="false"}" if [[ ! "${DO_MAKE_RELEASE}" =~ ^(false|true)$ ]]; then echo "DO_MAKE_RELEASE must be either \"true\" or \"false\"" >&2 exit 1 fi if [[ "${IS_KOKORO}" == "true" ]] ; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" fi GITHUB_RELEASE_UTIL_OPTS=() if [[ "${IS_KOKORO}" == "true" ]] ; then # Note: KOKORO_GIT_COMMIT is populated by Kokoro. GITHUB_RELEASE_UTIL_OPTS+=( -c "${KOKORO_GIT_COMMIT}" -t "${GITHUB_ACCESS_TOKEN}" ) fi if [[ "${DO_MAKE_RELEASE}" == "true" ]]; then GITHUB_RELEASE_UTIL_OPTS+=( -r ) fi readonly GITHUB_RELEASE_UTIL_OPTS # If running on Kokoro, TMPDIR is populated with the tmp folder. readonly TMP_DIR="$(mktemp -d "${TMPDIR}/release_XXXXXX")" readonly RELEASE_UTIL_SCRIPT="$(pwd)/kokoro/testutils/github_release_util.sh" if [[ ! -f "${RELEASE_UTIL_SCRIPT}" ]]; then echo "${RELEASE_UTIL_SCRIPT} not found." echo "Make sure you run this script from the root of tink-go-gcpkms." return 1 fi pushd "${TMP_DIR}" # Create a release branch. "${RELEASE_UTIL_SCRIPT}" "${GITHUB_RELEASE_UTIL_OPTS[@]}" create_branch \ "${RELEASE_VERSION}" tink-go-gcpkms popd tink-go-gcpkms-2.2.0/kokoro/create_github_release_tag.sh000066400000000000000000000043651461743517500233720ustar00rootroot00000000000000#!/bin/bash # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ set -euo pipefail # Fail if RELEASE_VERSION is not set. if [[ -z "${RELEASE_VERSION:-}" ]]; then echo "RELEASE_VERSION must be set" >&2 exit 1 fi IS_KOKORO="false" if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then IS_KOKORO="true" fi readonly IS_KOKORO # If not defined, default to /tmp. : "${TMPDIR:="/tmp"}" # WARNING: Setting this environment varialble to "true" will cause this script # to actually perform a release. : "${DO_MAKE_RELEASE:="false"}" if [[ ! "${DO_MAKE_RELEASE}" =~ ^(false|true)$ ]]; then echo "DO_MAKE_RELEASE must be either \"true\" or \"false\"" >&2 exit 1 fi if [[ "${IS_KOKORO}" == "true" ]] ; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" fi GITHUB_RELEASE_UTIL_OPTS=() if [[ "${IS_KOKORO}" == "true" ]] ; then # Note: KOKORO_GIT_COMMIT is populated by Kokoro. GITHUB_RELEASE_UTIL_OPTS+=( -c "${KOKORO_GIT_COMMIT}" -t "${GITHUB_ACCESS_TOKEN}" ) fi if [[ "${DO_MAKE_RELEASE}" == "true" ]]; then GITHUB_RELEASE_UTIL_OPTS+=( -r ) fi readonly GITHUB_RELEASE_UTIL_OPTS # If running on Kokoro, TMPDIR is populated with the tmp folder. readonly TMP_DIR="$(mktemp -d "${TMPDIR}/release_XXXXXX")" readonly RELEASE_UTIL_SCRIPT="$(pwd)/kokoro/testutils/github_release_util.sh" if [[ ! -f "${RELEASE_UTIL_SCRIPT}" ]]; then echo "${RELEASE_UTIL_SCRIPT} not found." echo "Make sure you run this script from the root of tink-go-gcpkms." return 1 fi pushd "${TMP_DIR}" # Create a release branch. "${RELEASE_UTIL_SCRIPT}" "${GITHUB_RELEASE_UTIL_OPTS[@]}" create_tag \ "${RELEASE_VERSION}" tink-go-gcpkms popd tink-go-gcpkms-2.2.0/kokoro/gcp_ubuntu/000077500000000000000000000000001461743517500200415ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/gcp_ubuntu/bazel/000077500000000000000000000000001461743517500211365ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/gcp_ubuntu/bazel/run_tests.sh000066400000000000000000000050361461743517500235240ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # Builds and tests tink-go-gcpkms using Bazel. # # The behavior of this script can be modified using the following optional env # variables: # # - CONTAINER_IMAGE (unset by default): By default when run locally this script # executes tests directly on the host. The CONTAINER_IMAGE variable can be set # to execute tests in a custom container image for local testing. E.g.: # # CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-go-base:latest" \ # sh ./kokoro/gcp_ubuntu/bazel/run_tests.sh set -euo pipefail RUN_COMMAND_ARGS=() if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" source "./kokoro/testutils/go_test_container_images.sh" CONTAINER_IMAGE="${TINK_GO_BASE_IMAGE}" RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" ) fi readonly CONTAINER_IMAGE if [[ -n "${CONTAINER_IMAGE:-}" ]]; then RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) fi ./kokoro/testutils/copy_credentials.sh "testdata" "gcp" cat <<'EOF' > _do_run_test.sh #!/bin/bash set -euo pipefail ./kokoro/testutils/check_go_generated_files_up_to_date.sh "$(pwd)" MANUAL_TARGETS=() # Run manual tests that rely on test data only available via Bazel. if [[ -n "${KOKORO_ROOT:-}" ]]; then MANUAL_TARGETS+=( "//integration/gcpkms:gcpkms_test" ) fi readonly MANUAL_TARGETS ./kokoro/testutils/run_bazel_tests.sh -t --test_arg=--test.v . \ "${MANUAL_TARGETS[@]}" ./kokoro/testutils/run_bazel_tests.sh -b --enable_bzlmod \ -t --enable_bzlmod,--test_arg=--test.v . "${MANUAL_TARGETS[@]}" EOF chmod +x _do_run_test.sh cat < _env_variables.txt KOKORO_ROOT EOF RUN_COMMAND_ARGS+=( -e _env_variables.txt ) # Run cleanup on EXIT. trap cleanup EXIT cleanup() { rm -rf _do_run_test.sh rm -rf _env_variables.txt } ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" ./_do_run_test.sh tink-go-gcpkms-2.2.0/kokoro/gcp_ubuntu/gomod/000077500000000000000000000000001461743517500211465ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/gcp_ubuntu/gomod/run_tests.sh000066400000000000000000000036561461743517500235420ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # Builds and tests tink-go-gcpkms using Go tooling. # # The behavior of this script can be modified using the following optional env # variables: # # - CONTAINER_IMAGE (unset by default): By default when run locally this script # executes tests directly on the host. The CONTAINER_IMAGE variable can be set # to execute tests in a custom container image for local testing. E.g.: # # CONTAINER_IMAGE="us-docker.pkg.dev/tink-test-infrastructure/tink-ci-images/linux-tink-go-base:latest" \ # sh ./kokoro/gcp_ubuntu/gomod/run_tests.sh set -eEuo pipefail RUN_COMMAND_ARGS=() if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" source "./kokoro/testutils/go_test_container_images.sh" CONTAINER_IMAGE="${TINK_GO_BASE_IMAGE}" RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" ) fi readonly CONTAINER_IMAGE if [[ -n "${CONTAINER_IMAGE:-}" ]]; then RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) fi readonly MODULE_URL="github.com/tink-crypto/tink-go-gcpkms" readonly MODULE_VERSION="$(cat version.bzl | grep ^TINK | cut -f 2 -d \")" ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ ./kokoro/testutils/run_go_mod_tests.sh "${MODULE_URL}" . \ "${MODULE_VERSION}" "main" tink-go-gcpkms-2.2.0/kokoro/macos_external/000077500000000000000000000000001461743517500206725ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/macos_external/bazel/000077500000000000000000000000001461743517500217675ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/macos_external/bazel/run_tests.sh000066400000000000000000000026751461743517500243630ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ set -euo pipefail if [[ -n "${KOKORO_ROOT:-}" ]]; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" fi # Sourcing required to update callers environment. source ./kokoro/testutils/install_go.sh echo "Using go binary from $(which go): $(go version)" # TODO(b/238389921): Run check_go_generated_files_up_to_date.sh after a # refactoring that takes into account extensions to tink-go. ./kokoro/testutils/copy_credentials.sh "testdata" "gcp" MANUAL_TARGETS=() # Run manual tests that rely on test data only available via Bazel. if [[ -n "${KOKORO_ROOT:-}" ]]; then MANUAL_TARGETS+=( "//integration/gcpkms:gcpkms_test" ) fi readonly MANUAL_TARGETS ./kokoro/testutils/run_bazel_tests.sh -t --test_arg=--test.v . \ "${MANUAL_TARGETS[@]}" tink-go-gcpkms-2.2.0/kokoro/macos_external/gomod/000077500000000000000000000000001461743517500217775ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/macos_external/gomod/run_tests.sh000066400000000000000000000022741461743517500243660ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ set -euo pipefail if [[ -n "${KOKORO_ROOT:-}" ]]; then readonly TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" cd "${TINK_BASE_DIR}/tink_go_gcpkms" fi # Sourcing required to update callers environment. source ./kokoro/testutils/install_go.sh echo "Using go binary from $(which go): $(go version)" readonly MODULE_URL="github.com/tink-crypto/tink-go-gcpkms" readonly MODULE_VERSION="$(cat version.bzl | grep ^TINK | cut -f 2 -d \")" ./kokoro/testutils/run_go_mod_tests.sh "${MODULE_URL}" "$(pwd)" \ "${MODULE_VERSION}" "main" tink-go-gcpkms-2.2.0/kokoro/testutils/000077500000000000000000000000001461743517500177265ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/kokoro/testutils/BUILD.bazel000066400000000000000000000012531461743517500216050ustar00rootroot00000000000000package(default_visibility = ["//:__subpackages__"]) licenses(["notice"]) sh_binary( name = "test_utils", srcs = ["test_utils.sh"], ) sh_binary( name = "github_release_util", srcs = ["github_release_util.sh"], ) sh_test( name = "github_release_util_test", size = "small", srcs = ["github_release_util_test.sh"], args = [ "$(rlocationpath :github_release_util.sh)", "$(rlocationpath :test_utils)", ], data = [ ":github_release_util.sh", ":test_utils", ], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), ) tink-go-gcpkms-2.2.0/kokoro/testutils/check_go_generated_files_up_to_date.sh000077500000000000000000000062111461743517500274320ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # This scripts checks that a given Go workspace has its generated Bazel files up # to date. BAZEL_CMD="bazel" # Use Bazelisk (https://github.com/bazelbuild/bazelisk) if available. if command -v "bazelisk" &> /dev/null; then BAZEL_CMD="bazelisk" "${BAZEL_CMD}" version fi usage() { echo "Usage: $0 [-h] [-c ] " echo " -c: Value to pass to `-compat`. Default to 1.19." echo " -h: Help. Print this usage information." exit 1 } COMPAT="1.19" GO_PROJECT_DIR= process_args() { # Parse options. while getopts "hc:" opt; do case "${opt}" in c) COMPAT="${OPTARG}" ;; *) usage ;; esac done shift $((OPTIND - 1)) readonly GO_PROJECT_DIR="$1" if [[ -z "${GO_PROJECT_DIR}" ]]; then usage fi } main() { process_args "$@" ( cd "${GO_PROJECT_DIR}" local -r temp_dir_current_generated_files="$(mktemp -dt \ current_tink_go_build_files.XXXXXX)" local -r go_generated_files=( ./go.mod ./go.sum ./deps.bzl ) # Copy all current generated files into temp_dir_current_generated_files. local current_go_generated_files=( "${go_generated_files[@]}" ) while read -r -d $'\0' generated_file; do current_go_generated_files+=("${generated_file}") done < <(find . -name BUILD.bazel -print0) readonly current_go_generated_files for generated_file_path in "${current_go_generated_files[@]}"; do mkdir -p \ "$(dirname \ "${temp_dir_current_generated_files}/${generated_file_path}")" cp "${generated_file_path}" \ "${temp_dir_current_generated_files}/${generated_file_path}" done # Update build files. go mod tidy -compat="${COMPAT}" # Update deps.bzl. "${BAZEL_CMD}" run //:gazelle-update-repos # Update all BUILD.bazel files. "${BAZEL_CMD}" run //:gazelle # Compare current with new build files. local new_go_generated_files=( "${go_generated_files[@]}" ) while read -r -d $'\0' generated_file; do new_go_generated_files+=("${generated_file}") done < <(find . -name BUILD.bazel -print0) readonly new_go_generated_files for generated_file_path in "${new_go_generated_files[@]}"; do if ! cmp -s "${generated_file_path}" \ "${temp_dir_current_generated_files}/${generated_file_path}"; then echo "ERROR: ${generated_file_path} needs to be updated. Please follow \ the instructions on go/tink-workflows#update-go-build." >&2 exit 1 fi done ) } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/copy_credentials.sh000077500000000000000000000066461461743517500236300ustar00rootroot00000000000000#!/bin/bash # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #################################################################################### # This script takes credentials injected into the environment via the Kokoro job # configuration and copies them to the expected locations. # # The second argument indicates whether all KMS service credentials should be # copied (all) or only credentials for a specific KMS service (gcp|aws). # # Usage insructions: # # ./kokoro/testutils/copy_credentials.sh # TESTDATA_DIR= KMS_SERVICE= ####################################### # Process command line arguments. # # Globals: # TESTDATA_DIR # KMS_SERVICE ####################################### process_args() { TESTDATA_DIR="$1" readonly TESTDATA_DIR KMS_SERVICE="$2" readonly KMS_SERVICE if [[ -z "${TESTDATA_DIR}" ]]; then echo "Testdata directory must be set" >&2 exit 1 fi if [[ ! -d "${TESTDATA_DIR}" ]]; then echo "Testdata directory \"${TESTDATA_DIR}\" doesn't exist" >&2 exit 1 fi if [[ -z "${KMS_SERVICE}" ]]; then echo "KMS service must be specified" >&2 exit 1 fi } ####################################### # Copy GCP credentials. # # Globals: # TESTDATA_DIR # TINK_TEST_SERVICE_ACCOUNT ####################################### copy_gcp_credentials() { if [[ -z "${TINK_TEST_SERVICE_ACCOUNT}" ]]; then echo "ERROR: TINK_TEST_SERVICE_ACCOUNT is expected to be set" >&2 exit 1 fi cp "${TINK_TEST_SERVICE_ACCOUNT}" "${TESTDATA_DIR}/gcp/credential.json" } ####################################### # Copy AWS credentials. # # Globals: # TESTDATA_DIR # AWS_TINK_TEST_SERVICE_ACCOUNT ####################################### copy_aws_credentials() { if [[ -z "${AWS_TINK_TEST_SERVICE_ACCOUNT}" ]]; then echo "ERROR: AWS_TINK_TEST_SERVICE_ACCOUNT is expected to be set" >&2 exit 1 fi # Create the different format for the AWS credentials local -r aws_key_id="AKIATNYZMJOHVMN7MSYH" local -r aws_key="$(cat ${AWS_TINK_TEST_SERVICE_ACCOUNT})" cat < "${TESTDATA_DIR}/aws/credentials.ini" [default] aws_access_key_id = ${aws_key_id} aws_secret_access_key = ${aws_key} END cat < "${TESTDATA_DIR}/aws/credentials.cred" [default] accessKey = ${aws_key_id} secretKey = ${aws_key} END cat < "${TESTDATA_DIR}/aws/credentials.csv" User name,Password,Access key ID,Secret access key,Console login link tink-user1,,${aws_key_id},${aws_key},https://235739564943.signin.aws.amazon.com/console END } main() { if [[ -z "${KOKORO_ROOT}" ]]; then echo "Not running on Kokoro, skipping copying credentials." exit 0 fi process_args "$@" case "${KMS_SERVICE}" in aws) copy_aws_credentials ;; gcp) copy_gcp_credentials ;; all) copy_aws_credentials copy_gcp_credentials ;; *) echo "Invalid KMS service \"${KMS_SERVICE}\"" >&2 exit 1 esac } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/github_release_util.sh000077500000000000000000000162231461743517500243100ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # This script performs a source release on GitHub for a given repo, that is: # - Creates a release branch (if it does not yet exist), # - Creates a release tag. set -eo pipefail # Parameters and arguments. These will be populated/modified by args parsing. # Options. # Whether to actually create a release. This is false by default and meant to # prevent accidental releases. DO_RUN_ACTION="false" # Commit at which to make the release. If unspecified, the release is made from # HEAD. COMMIT_HASH= # Optional personal access token. ACCESS_TOKEN= # Arguments. # Action to be performed. ACTION= # This must be of the form `MAJOR.MINOR.PATCH`. VERSION= # Repo name after github.com/tink-crypto/, e.g., tink-cc. REPO_NAME= # Derived variables. GITHUB_REPO_URL= RELEASE_BRANCH= TAG= GITHUB_REFS= BRANCH_EXISTS="false" # Constants. readonly GITHUB_ORG_URL="github.com/tink-crypto" usage() { echo "Usage: $0 [-rh] [-c ] [-t ] \\" echo " " echo " : The action to be performed (crete_branch|create_tag)." echo " : The version identifier in MAJOR.MINOR.PATCH format." echo " : The name of the repository (e.g. \"tink-cc\")." echo " -c: Commit hash to use as HEAD of the release branch (optional)." echo " -t: Access token. Without this, the default is SSH (optional)." echo " -r: Whether to actually create a release; this is false by default." echo " -h: Show this help message." exit 1 } process_params() { while getopts "rhc:t:" opt; do case "${opt}" in r) DO_RUN_ACTION="true" ;; c) COMMIT_HASH="${OPTARG}" ;; t) ACCESS_TOKEN="${OPTARG}" ;; *) usage ;; esac done shift $((OPTIND - 1)) readonly DO_RUN_ACTION readonly COMMIT_HASH readonly ACCESS_TOKEN ACTION="$1" if [[ ! "${ACTION}" =~ create_branch|create_tag ]]; then echo "ERROR: Expected (create_branch|create_tag) got ${ACTION}" >&2 usage fi readonly ACTION VERSION="$2" if [[ ! "${VERSION}" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then echo "ERROR: Invalid version format: expected MAJOR.MINOR.PATCH, got \ ${VERSION}" >&2 usage fi readonly VERSION REPO_NAME="$3" if [[ -z "${REPO_NAME}" ]]; then echo "ERROR: Repo name must be specified." >&2 usage fi readonly REPO_NAME # Use SSH by default. local protocol_and_credentials="ssh://git" if [[ -n "${ACCESS_TOKEN}" ]]; then protocol_and_credentials="https://ise-crypto:${ACCESS_TOKEN}" fi readonly protocol_and_credentials GITHUB_REPO_URL="${protocol_and_credentials}@${GITHUB_ORG_URL}/${REPO_NAME}" readonly GITHUB_REPO_URL # Release branch is only MAJOR.MINOR. readonly RELEASE_BRANCH="$(echo "${VERSION}" | cut -d'.' -f1,2)" # Splitting declaration and assignment guarantees correct propagation of the # exit code of the subshell. local GITHUB_REFS GITHUB_REFS="$(git ls-remote "${GITHUB_REPO_URL}")" readonly GITHUB_REFS local -r expected_release_branch="refs/heads/${RELEASE_BRANCH}" if echo "${GITHUB_REFS}" | grep "${expected_release_branch}" > /dev/null; then BRANCH_EXISTS="true" fi readonly BRANCH_EXISTS if [[ "${ACTION}" == "create_tag" ]]; then if [[ "${BRANCH_EXISTS}" == "false" ]]; then echo "ERROR: The release branch does not exist in \ ${GITHUB_ORG_URL}/${REPO_NAME}." >&2 return 1 fi local -r release_tag="v${VERSION}" local -r expected_release_tag="refs/tags/${release_tag}" if echo "${GITHUB_REFS}" | grep "${expected_release_tag}" > /dev/null; then echo "ERROR The tag \"${release_tag}\" already exists in \ ${GITHUB_ORG_URL}/${REPO_NAME}." >&2 return 1 fi fi } ####################################### # Prints a command # # Args: # Command to execute. # ####################################### print_command() { printf '%q ' '+' "$@" echo } ####################################### # Runs a command if DO_RUN_ACTION is true. # # Args: # Command to execute. # Globals: # DO_RUN_ACTION # ####################################### run_command() { if [[ "${DO_RUN_ACTION}" == "false" ]]; then echo " *** Dry run, command not executed. ***" return 0 fi # Actually run the command. "$@" return $? } ####################################### # Prints and runs a command. # # Args: # Command to execute. # ####################################### print_and_run_command() { print_command "$@" run_command "$@" } ####################################### # Creates and checks out to the release branch. # # If COMMIT_HASH is specified, use COMMIT_HASH as HEAD for the branch. # # Globals: # RELEASE_BRANCH # COMMIT_HASH # ####################################### git_create_release_branch() { if [[ "${BRANCH_EXISTS}" == "true" ]]; then echo "WARNING: The release branch already exists. Nothing to do." return 0 fi # Target branch does not exist so we create the release branch. if [[ -n "${COMMIT_HASH:-}" ]]; then # Use COMMIT_HASH as HEAD for this branch. print_and_run_command git branch "${RELEASE_BRANCH}" "${COMMIT_HASH}" else print_and_run_command git branch "${RELEASE_BRANCH}" fi print_and_run_command git push origin "${RELEASE_BRANCH}" } ####################################### # Creates a release tag. # # Globals: # RELEASE_BRANCH # REPO_NAME # VERSION # ####################################### git_create_release_tag() { if [[ "${BRANCH_EXISTS}" == "false" ]]; then echo "ERROR: The release branch does not exist in \ ${GITHUB_ORG_URL}/${REPO_NAME}." >&2 return 1 fi local -r release_tag="v${VERSION}" local -r expected_release_tag="refs/tags/${release_tag}" if echo "${GITHUB_REFS}" | grep "${expected_release_tag}" > /dev/null; then echo "ERROR The tag \"${release_tag}\" already exists in \ ${GITHUB_ORG_URL}/${REPO_NAME}." >&2 return 1 fi print_and_run_command git checkout "${RELEASE_BRANCH}" print_and_run_command git tag -a "${release_tag}" \ -m "${REPO_NAME} version ${VERSION}" print_and_run_command git push origin "${release_tag}" } main() { process_params "$@" # Avoid logging the full URL; replace GIT_URL with a version that omits user # and access token. local -r protocol="$(echo "${GITHUB_REPO_URL}" | cut -d':' -f1)" local -r github_repo="$(echo "${GITHUB_REPO_URL}" | cut -d'@' -f2)" print_command git clone "${protocol}://...@${github_repo}" run_command git clone "${GITHUB_REPO_URL}" print_and_run_command cd "${REPO_NAME}" case "${ACTION}" in create_branch) git_create_release_branch ;; create_tag) git_create_release_tag ;; esac } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/github_release_util_test.sh000077500000000000000000000301511461743517500253430ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ DEFAULT_DIR="$(pwd)" if [[ -n "${TEST_SRCDIR}" ]]; then DEFAULT_DIR="${TEST_SRCDIR}" fi readonly DEFAULT_DIR readonly CLI="${DEFAULT_DIR}/${1:-"github_release_util.sh"}" readonly TEST_UTILS="${DEFAULT_DIR}/${2:-test_utils.sh}" # Load the test library. source "${TEST_UTILS}" test_GitHubReleaseUtil_CreateBranchMinorSucceeds() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo git clone ssh://git@github.com/tink-crypto/some-repo git branch 1.6 git push origin 1.6 EOF local -r actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_git_cmds_file.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main EOF ;; "clone") local -r repo_name="${1##*/}" mkdir "${repo_name}" ;; *) ;; # Do nothing esac } # Run this in the caller's environment. ( source "${CLI}" -r create_branch 1.6.0 some-repo &> /dev/null ) ASSERT_CMD_SUCCEEDED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateBranchMinorWithCommitSucceeds() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo git clone ssh://git@github.com/tink-crypto/some-repo git branch 1.6 6c68b48c884e0aeb983b8864f35187d9584d0d74 git push origin 1.6 EOF local -r actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_git_cmds_file.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main EOF ;; "clone") local -r repo_name="${1##*/}" mkdir "${repo_name}" ;; *) ;; # Do nothing esac } # Run this in the caller's environment. ( source "${CLI}" -r -c 6c68b48c884e0aeb983b8864f35187d9584d0d74 \ create_branch 1.6.0 some-repo &> /dev/null ) ASSERT_CMD_SUCCEEDED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateTagPatchSucceeds() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo git clone ssh://git@github.com/tink-crypto/some-repo git checkout 1.6 git tag -a v1.6.2 -m some-repo version 1.6.2 git push origin v1.6.2 EOF local -r actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_git_cmds_file.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main 9940095f3081a116fa7a1337ad5ba27a3ccc59fe refs/heads/1.6 EOF ;; "clone") local -r repo_name="${1##*/}" mkdir "${repo_name}" ;; *) ;; # Do nothing. esac } # Run this in the caller's environment. ( source "${CLI}" -r -c 6c68b48c884e0aeb983b8864f35187d9584d0d74 \ create_tag 1.6.2 some-repo &> /dev/null ) ASSERT_CMD_SUCCEEDED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateBranchFailsWhenLsRemoteFails() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo EOF local actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_cmds.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") return 1 ;; *) ;; # Do nothing. esac } # Run this in a subshell to prevent exiting on failure. ( source "${CLI}" -r create_branch 1.6.2 some-repo &> /dev/null ) ASSERT_CMD_FAILED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" echo "" > "${actual_git_cmds_file}" } test_GitHubReleaseUtil_CreateBranchFailsWhenCloneFails() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo git clone ssh://git@github.com/tink-crypto/some-repo EOF local actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_cmds.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main EOF ;; "clone") return 1 ;; *) ;; # Do nothing. esac } # Run this in a subshell to prevent exiting on failure. ( source "${CLI}" -r create_branch 1.6.2 some-repo &> /dev/null ) ASSERT_CMD_FAILED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateTagFailsIfBranchDoesNotExist() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo EOF local actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_cmds.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main EOF ;; *) ;; # Do nothing. esac } # Run this in a subshell to prevent exiting on failure. ( source "${CLI}" -r create_tag 1.6.2 some-repo &> /dev/null ) ASSERT_CMD_FAILED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateTagFailsIfReleaseTagAlreadyExists() { cd "${TEST_CASE_TMPDIR}" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ssh://git@github.com/tink-crypto/some-repo EOF local actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_cmds.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main 112a7d3a0453a1d926448519f94fe5a91c69be45 refs/heads/1.6 8c266441044c4dfaf7560e21663a8037043b750b refs/tags/v1.6.2 195ec3c1edeee8877ab5dc287f95c4402e3fb510 refs/tags/v1.6.1 c6f48771296bca0bd22724b208abafeae7d7b764 refs/tags/v1.6.0 EOF ;; *) ;; # Do nothing. esac } # Run this in a subshell to prevent exiting on failure. ( source "${CLI}" -r create_tag 1.6.2 some-repo &> /dev/null ) ASSERT_CMD_FAILED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_FailsWhenInvalidVersion() { cd "${TEST_CASE_TMPDIR}" for action in create_branch create_tag; do ( source "${CLI}" -r "${action}" 1 some-repo &> /dev/null ) ASSERT_CMD_FAILED ( source "${CLI}" -r "${action}" 1.2 some-repo &> /dev/null ) ASSERT_CMD_FAILED ( source "${CLI}" -r "${action}" 1.2.a some-repo &> /dev/null ) ASSERT_CMD_FAILED ( source "${CLI}" -r "${action}" a.b.c some-repo &> /dev/null ) ASSERT_CMD_FAILED ( source "${CLI}" -r "${action}" 1.2.3.4 some-repo &> /dev/null ) ASSERT_CMD_FAILED ( source "${CLI}" -r "${action}" invalid some-repo &> /dev/null ) ASSERT_CMD_FAILED done } test_GitHubReleaseUtil_FailsWhenNoRepoNameIsGiven() { cd "${TEST_CASE_TMPDIR}" for action in create_branch create_tag; do # Run this in a subshell to prevent exiting on failure. ( source "${CLI}" -r "${action}" 1.6.0 &> /dev/null ) ASSERT_CMD_FAILED done } test_GitHubReleaseUtil_CreateBranchUsesCorrectGithubToken() { cd "${TEST_CASE_TMPDIR}" local -r access_token="a227da63673c236090a067c3f96b62e74dbd5857" local -r expected_url="https://ise-crypto:${access_token}@github.com/tink-crypto/some-repo" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ${expected_url} git clone ${expected_url} git branch 1.6 git push origin 1.6 EOF local -r actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_git_cmds_file.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main EOF ;; "clone") local -r repo_name="${1##*/}" mkdir "${repo_name}" ;; *) ;; # Do nothing esac } # Run this in the caller's environment. ( source "${CLI}" -r -t "${access_token}" create_branch 1.6.0 some-repo \ &> /dev/null ) ASSERT_CMD_SUCCEEDED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } test_GitHubReleaseUtil_CreateTagUsesCorrectGithubToken() { cd "${TEST_CASE_TMPDIR}" local -r access_token="a227da63673c236090a067c3f96b62e74dbd5857" local -r expected_url="https://ise-crypto:${access_token}@github.com/tink-crypto/some-repo" local -r expected_git_cmds_file="${TEST_CASE_TMPDIR}/expected_cmds.txt" cat << EOF > ${expected_git_cmds_file} git ls-remote ${expected_url} git clone ${expected_url} git checkout 1.6 git tag -a v1.6.2 -m some-repo version 1.6.2 git push origin v1.6.2 EOF local -r actual_git_cmds_file="${TEST_CASE_TMPDIR}/actual_git_cmds_file.txt" # Mock git command. git() { local -r command="$1" shift 1 cmd_and_args="git ${command} $@" echo "${cmd_and_args}" >> "${actual_git_cmds_file}" case "${command}" in "ls-remote") cat << EOF 6c68b48c884e0aeb983b8864f35187d9584d0d74 HEAD 6c68b48c884e0aeb983b8864f35187d9584d0d74 refs/heads/main 112a7d3a0453a1d926448519f94fe5a91c69be45 refs/heads/1.6 EOF ;; "clone") local -r repo_name="${1##*/}" mkdir "${repo_name}" ;; *) ;; # Do nothing esac } # Run this in the caller's environment. ( source "${CLI}" -r -t "${access_token}" create_tag 1.6.2 some-repo \ &> /dev/null ) ASSERT_CMD_SUCCEEDED ASSERT_FILE_EQUALS "${actual_git_cmds_file}" "${expected_git_cmds_file}" } main() { run_all_tests "$@" } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/go_test_container_images.sh000066400000000000000000000024001461743517500253110ustar00rootroot00000000000000#!/bin/bash # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ _image_prefix() { local -r artifact_registry_url="us-docker.pkg.dev" local -r test_project="tink-test-infrastructure" local -r artifact_registry_repo="tink-ci-images" echo "${artifact_registry_url}/${test_project}/${artifact_registry_repo}" } # Linux container images for Tink Go libraries. readonly TINK_GO_BASE_IMAGE_NAME="linux-tink-go-base" # Image from 2024-03-19. readonly TINK_GO_BASE_IMAGE_HASH="309617d28992a6b381ef3cbb229375d1a0907a5423be5856f43fa87da3490401" readonly TINK_GO_BASE_IMAGE="$(_image_prefix)/${TINK_GO_BASE_IMAGE_NAME}@sha256:${TINK_GO_BASE_IMAGE_HASH}" unset -f _image_prefix tink-go-gcpkms-2.2.0/kokoro/testutils/install_go.sh000077500000000000000000000033371461743517500224260ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # This script installs a recent version of Go into a temporary directory. The Go # bin directory is then added to the PATH environment variable. # # NOTE: This script MUST be sourced to update the environment of the calling # script. # # Usage instructions: # # source ./kokoro/testutils/install_go.sh install_temp_go() { local -r go_version="1.20.10" local -r platform="$(uname | tr '[:upper:]' '[:lower:]')" local go_platform case "${platform}" in 'linux') go_platform='linux-amd64' ;; 'darwin') go_platform='darwin-amd64' ;; *) echo "Unsupported platform, unable to install Go." exit 1 ;; esac readonly go_platform local -r go_archive="go${go_version}.${go_platform}.tar.gz" local -r go_url="https://go.dev/dl/${go_archive}" local -r go_tmpdir=$(mktemp -dt tink-go.XXXXXX) ( cd "${go_tmpdir}" curl -OLsS "${go_url}" tar -xzf "${go_archive}" ) export GOROOT="${go_tmpdir}/go" export PATH="${go_tmpdir}/go/bin:${PATH}" } if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]] ; then install_temp_go fi tink-go-gcpkms-2.2.0/kokoro/testutils/run_bazel_tests.sh000077500000000000000000000100011461743517500234600ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # This script runs all the Bazel tests within a given workspace directory. # # Users must spcify the WORKSPACE directory. Optionally, the user can specify # a set of additional manual targets to run. # # Note: -E extends the trap to shell functions, command substitutions, and # commands executed in a subshell environment. set -eEo pipefail # Print some debug output on error before exiting. trap print_debug_output ERR usage() { echo "Usage: $0 [-mh] [-b ...] [-t ...] \\" echo " [ ...]" echo " -m: Runs only the manual targets. If set, manual targets must be" echo " provided." echo " -b: Comma separated list of flags to pass to `bazel build`." echo " -t: Comma separated list of flags to pass to `bazel test`." echo " -h: Help. Print this usage information." exit 1 } readonly PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')" MANUAL_ONLY="false" WORKSPACE_DIR= MANUAL_TARGETS= BAZEL_CMD="bazel" BUILD_FLAGS=() TEST_FLAGS=() ####################################### # Process command line arguments. # # Globals: # WORKSPACE_DIR # MANUAL_TARGETS ####################################### process_args() { # Parse options. while getopts "mhb:t:" opt; do case "${opt}" in m) MANUAL_ONLY="true" ;; b) BUILD_FLAGS=($(echo "${OPTARG}" | tr ',' '\n')) ;; t) TEST_FLAGS=($(echo "${OPTARG}" | tr ',' '\n')) ;; *) usage ;; esac done shift $((OPTIND - 1)) WORKSPACE_DIR="$1" readonly WORKSPACE_DIR if [[ -z "${WORKSPACE_DIR}" ]]; then usage fi shift 1 MANUAL_TARGETS=("$@") readonly MANUAL_TARGETS if [[ "${MANUAL_ONLY}" == "true" ]] && (( ${#MANUAL_TARGETS[@]} == 0 )); then usage fi # Use Bazelisk (https://github.com/bazelbuild/bazelisk) if available. if command -v "bazelisk" &> /dev/null; then BAZEL_CMD="bazelisk" fi readonly BAZEL_CMD echo "Using: $(which ${BAZEL_CMD})" } ####################################### # Print some debugging output. ####################################### print_debug_output() { ls -l df -h } main() { process_args "$@" TEST_FLAGS+=( --strategy=TestRunner=standalone --test_output=all ) local -r workspace_dir="$(cd ${WORKSPACE_DIR} && pwd)" if [[ "${PLATFORM}" == 'darwin' ]]; then TEST_FLAGS+=( --jvmopt="-Djava.net.preferIPv6Addresses=true" ) if [[ "${workspace_dir}" =~ javascript ]]; then BUILD_FLAGS+=( --experimental_inprocess_symlink_creation ) TEST_FLAGS+=( --experimental_inprocess_symlink_creation ) fi fi readonly BUILD_FLAGS readonly TEST_FLAGS ( set -x cd "${workspace_dir}" if [[ "${MANUAL_ONLY}" == "false" ]]; then time "${BAZEL_CMD}" build "${BUILD_FLAGS[@]}" -- ... # Exit code 4 means targets build correctly but no tests were found. See # https://bazel.build/docs/scripts#exit-codes. bazel_test_return=0 time "${BAZEL_CMD}" test "${TEST_FLAGS[@]}" -- ... || bazel_test_return="$?" if (( $bazel_test_return != 0 && $bazel_test_return != 4 )); then return "${bazel_test_return}" fi fi # Run specific manual targets. if (( ${#MANUAL_TARGETS[@]} > 0 )); then time "${BAZEL_CMD}" build "${BUILD_FLAGS[@]}" -- "${MANUAL_TARGETS[@]}" time "${BAZEL_CMD}" test "${TEST_FLAGS[@]}" -- "${MANUAL_TARGETS[@]}" fi ) } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/run_command.sh000077500000000000000000000065551461743517500226020ustar00rootroot00000000000000#!/bin/bash # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # Utility script to optionally run a command optionally in a new container. # # This script must be run from inside the Tink library to run the command for. # # NOTE: When running in a new container, this sctips mounts the parent folder of # `pwd`. Other dependencies, if any, are assumed to be located there. For # example, if running tink-py tests, this script assumes: # - pwd => /path/to/parent/tink-py # - mount path => /path/to/parent # - ls /path/to/parent => tink_cc tink_py. set -eo pipefail usage() { cat <] [-k ] -c: [Optional] Container image to run the command on. -k: [Optional] Service key file path for pulling the image from the Google Artifact Registry (https://cloud.google.com/artifact-registry). -e: [Optional] File containing a list of environment variables to pass to Docker using --env-file (see https://docs.docker.com/engine/reference/commandline/run/#env). -h: Help. Print this usage information. EOF exit 1 } # Args. COMMAND= # Options. CONTAINER_IMAGE_NAME= GCR_SERVICE_KEY_PATH= DOCKER_ENV_FILE= ####################################### # Process command line arguments. ####################################### process_args() { # Parse options. while getopts "hc:k:e:" opt; do case "${opt}" in c) CONTAINER_IMAGE_NAME="${OPTARG}" ;; k) GCR_SERVICE_KEY_PATH="${OPTARG}" ;; e) DOCKER_ENV_FILE="${OPTARG}" ;; *) usage ;; esac done shift $((OPTIND - 1)) readonly CONTAINER_IMAGE_NAME readonly GCR_SERVICE_KEY_PATH readonly DOCKER_ENV_FILE readonly COMMAND=("$@") } main() { process_args "$@" if [[ -z "${CONTAINER_IMAGE_NAME:-}" ]]; then echo "Running command on the host" time "${COMMAND[@]}" else echo "Running command on a new container from image ${CONTAINER_IMAGE_NAME}" if [[ ! -z "${GCR_SERVICE_KEY_PATH:-}" ]]; then # Activate service account to read from a private artifact registry repo. gcloud auth activate-service-account --key-file="${GCR_SERVICE_KEY_PATH}" gcloud config set project tink-test-infrastructure gcloud auth configure-docker us-docker.pkg.dev --quiet fi local -r path_to_mount="$(dirname "$(pwd)")" local -r library_to_test="$(basename "$(pwd)")" time docker pull "${CONTAINER_IMAGE_NAME}" local docker_opts=( --network="host" --mount type=bind,src="${path_to_mount}",dst=/deps --workdir=/deps/"${library_to_test}" --rm ) if [[ -n "${DOCKER_ENV_FILE}" ]]; then docker_opts+=( --env-file="${DOCKER_ENV_FILE}" ) fi readonly docker_opts time docker run "${docker_opts[@]}" "${CONTAINER_IMAGE_NAME}" \ bash -c "$(echo "${COMMAND[@]}")" fi } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/run_go_mod_tests.sh000077500000000000000000000124471461743517500236470ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # This script runs tests on a given Go module. # # Usage: # ./kokoro/testutils/run_gomod_tests.sh \ # \ # \ # \ # set -eo pipefail FULL_GITHUB_MODULE_NAME= GO_MODULE_LOCAL_PATH= GO_MODULE_VERSION= GO_MODULE_GITHUB_HEAD_BRANCH= usage() { echo "Usage: $0 \\" echo " " exit 1 } ####################################### # Process command line arguments. # # Globals: # FULL_GITHUB_MODULE_NAME # GO_MODULE_LOCAL_PATH # GO_MODULE_VERSION # GO_MODULE_GITHUB_HEAD_BRANCH ####################################### process_args() { FULL_GITHUB_MODULE_NAME="$1" readonly FULL_GITHUB_MODULE_NAME GO_MODULE_LOCAL_PATH="$2" readonly GO_MODULE_LOCAL_PATH GO_MODULE_VERSION="$3" readonly GO_MODULE_VERSION GO_MODULE_GITHUB_HEAD_BRANCH="$4" readonly GO_MODULE_GITHUB_HEAD_BRANCH if [[ -z "${FULL_GITHUB_MODULE_NAME}" ]]; then usage fi if [[ -z "${GO_MODULE_LOCAL_PATH}" ]]; then usage fi if [[ -z "${GO_MODULE_VERSION}" ]]; then usage fi if [[ -z "${GO_MODULE_GITHUB_HEAD_BRANCH}" ]]; then usage fi } ####################################### # Add a require statement for a module and a replace statement to point it # to the local copy. # Arguments: # full_github_module_name: The full module name. # module_local_path: The root directory of the local Go module. # tink_version: Tink version. ####################################### function overlay_module() { local full_github_module_name="$1" local module_local_path="$2" local tink_version="$3" go mod edit "-require=${full_github_module_name}@v${tink_version}" go mod edit "-replace=${full_github_module_name}=${module_local_path}" } ####################################### # Search the go.mod being tested for internal dependencies and overlay them with # the local copies. # # Globals: # FULL_GITHUB_MODULE_NAME # GO_MODULE_LOCAL_PATH # GO_MODULE_VERSION ####################################### overlay_internal_deps() { declare -a internal_deps while read internal_dep; do internal_deps+=("${internal_dep}") done < <(grep "${FULL_GITHUB_MODULE_NAME}" "${GO_MODULE_LOCAL_PATH}/go.mod" \ | grep -v ^module \ | awk '{print $1}') # If internal_deps are found... if [[ ! -z "${internal_deps+x}" ]]; then for full_dep_name in "${internal_deps[@]}"; do local dep_name="$(echo "${full_dep_name}" \ | sed "s#${FULL_GITHUB_MODULE_NAME}/##")" overlay_module \ "${full_dep_name}" \ "${dep_name}" \ "${GO_MODULE_VERSION}" done fi } ####################################### # Builds and tests a given local module. # # Globals: # GO_MODULE_LOCAL_PATH # Outputs: # Prints progress to STDOUT. ####################################### build_and_test_local_go_mod() { echo "### Testing local Go module at ${GO_MODULE_LOCAL_PATH}" ( set -x cd "${GO_MODULE_LOCAL_PATH}" go build -v ./... go test -v ./... ) } ####################################### # Builds and tests a given local module. # # Globals: # FULL_GITHUB_MODULE_NAME # GO_MODULE_LOCAL_PATH # GO_MODULE_VERSION # GO_MODULE_GITHUB_HEAD_BRANCH # Outputs: # Prints progress to STDOUT. ####################################### test_go_module_depending_on_local_one() { # Create a temporary directory for performing module tests. local -r test_tmp_dir="$(mktemp -dt tink-gomod-test.XXXXXX)" local -r go_module_tmp_directory="${test_tmp_dir}/go-mod-test" mkdir "${go_module_tmp_directory}" ( cd "${go_module_tmp_directory}" echo "Using go binary from $(which go): $(go version)" set -x # Initialize a test Go module. go mod init tink-go-mod-test overlay_module \ "${FULL_GITHUB_MODULE_NAME}" \ "${GO_MODULE_LOCAL_PATH}" \ "${GO_MODULE_VERSION}" overlay_internal_deps # Print the prepared go.mod. cat go.mod # Get the module at the latest commit and print graph output depicting # direct dependencies. go get -v "${FULL_GITHUB_MODULE_NAME}@${GO_MODULE_GITHUB_HEAD_BRANCH}" # Pint contextual information concerning dependencies. go mod graph | grep tink go list -m all | grep tink ) # Leave a clean environment for subsequent tests. go clean -modcache rm -rf "${test_tmp_dir}" } main() { process_args "$@" build_and_test_local_go_mod # Skip this test for modules that are not on github.com/google/tink. if [[ "${FULL_GITHUB_MODULE_NAME}" =~ github.com/google/tink[a-z./]+ ]]; then test_go_module_depending_on_local_one fi } main "$@" tink-go-gcpkms-2.2.0/kokoro/testutils/test_utils.sh000077500000000000000000000103161461743517500224650ustar00rootroot00000000000000#!/bin/bash # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ # Set of utilities to run unit tests for bash scripts. # # Example usage: # From your test script: # source some/path/to/test_utils.sh # # # Test functions must be defined as follows: # test__() { # # Do some ground work. # # Run the test script. # ./path/to/script_to_test ... # ASSERT_CMD_SUCCEEDED # ASSERT_FILE_EQUALS # } # # # Finds all the functions starting with `test_`, extracts test name and # # test case, and run them. # run_all_tests "$@" # # This is either set by Bazel or generated. : "${TEST_TMPDIR:="$(mktemp -td test.XXXXX)"}" readonly TEST_TMPDIR # Temporary directory for the testcase to use. TEST_CASE_TMPDIR= # Current test name. _CURRENT_TEST_SCOPE= # Current test case. _CURRENT_TEST_CASE= # True if at least one of the test cases terminated with an error. _HAS_ERROR="false" _print_testcase_failed_and_exit() { echo "[ FAILED ] ${_CURRENT_TEST_SCOPE}.${_CURRENT_TEST_CASE}" exit 1 } ####################################### # Starts a new test case. # # Globals: # _CURRENT_TEST_SCOPE # _CURRENT_TEST_CASE ####################################### _start_test_case() { echo "[ RUN ] ${_CURRENT_TEST_SCOPE}.${_CURRENT_TEST_CASE}" # Create a tmp dir for the test case. TEST_CASE_TMPDIR="${TEST_TMPDIR}/${_CURRENT_TEST_SCOPE}/${_CURRENT_TEST_CASE}" mkdir -p "${TEST_CASE_TMPDIR}" } ####################################### # Ends a test case printing a success message. # # Globals: # _CURRENT_TEST_SCOPE # _CURRENT_TEST_CASE ####################################### _end_test_case_with_success() { test_case="$1" echo "[ OK ] ${_CURRENT_TEST_SCOPE}.${_CURRENT_TEST_CASE}" } ####################################### # Returns the list of tests defined in the test script. # # A test case is a function of the form: # test__ # # This function returns all the functions starting with `test_`. # # Globals: # None # Arguments: # None ####################################### _get_all_tests() { declare -F | while read line; do case "${line}" in "declare -f test_"*) echo "${line#declare -f }" ;; esac done } ####################################### # Runs a given test function. # # A test case is a function of the form: # test__ # # This script extracts test name and test case from the name. # # Globals: # _CURRENT_TEST_SCOPE # Arguments: # None ####################################### _do_run_test() { test_function="$1" IFS=_ read _CURRENT_TEST_SCOPE _CURRENT_TEST_CASE <<< "${test_function#test_}" _start_test_case ( # Make sure we exit only when assertions fail. set +e "${test_function}" ) local -r result=$? if (( $result == 0 )); then _end_test_case_with_success else _HAS_ERROR="true" fi } ####################################### # Runs all the test cases defined in the test script file. # Globals: # None # Arguments: # None # ####################################### run_all_tests() { for test in $(_get_all_tests); do _do_run_test "${test}" done # Make sure we return an error code for the failing test if [[ "${_HAS_ERROR}" == "true" ]]; then exit 1 fi } ASSERT_CMD_SUCCEEDED() { if (( $? != 0 )); then _print_testcase_failed_and_exit fi } ASSERT_CMD_FAILED() { if (( $? == 0 )); then _print_testcase_failed_and_exit fi } ASSERT_FILE_EQUALS() { input_file="$1" expected_file="$2" if ! diff "${input_file}" "${expected_file}"; then _print_testcase_failed_and_exit fi } tink-go-gcpkms-2.2.0/testdata/000077500000000000000000000000001461743517500161735ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/testdata/gcp/000077500000000000000000000000001461743517500167445ustar00rootroot00000000000000tink-go-gcpkms-2.2.0/testdata/gcp/BUILD.bazel000066400000000000000000000006051461743517500206230ustar00rootroot00000000000000package(default_visibility = ["//visibility:public"]) licenses(["notice"]) exports_files(srcs = ["credential.json"]) filegroup( name = "credentials", testonly = 1, srcs = [ "credential.json", "key_name.txt", ], ) filegroup( name = "bad_credentials", testonly = 1, srcs = [ "credential_bad.json", "key_name_bad.txt", ], ) tink-go-gcpkms-2.2.0/testdata/gcp/README.md000066400000000000000000000005511461743517500202240ustar00rootroot00000000000000This folder contains GCP credentials that are used for testing Tink. For security reasons, all credentials in this folder are invalid. If you want to run tests that depend on them, please create your own [Cloud KMS key](https://cloud.google.com/kms/docs/creating-keys), and copy the credentials to `gcp/credential.json` and the key URI to `gcp/key_name.txt`. tink-go-gcpkms-2.2.0/testdata/gcp/credential.json000066400000000000000000000030431461743517500217510ustar00rootroot00000000000000{ "type": "service_account", "project_id": "tink-test-infrastructure", "private_key_id": "some_bad_private_key_id", "private_key": "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMtJlaQD79xGIC28\nowTpj7wkdi34piSubtDKttgC3lL00ioyQf/WMqLnyDWySNufCjhavQ7/sxXQAUCL\n5B3WDwM8+mFqQM2wJB18NBWBSfGOFSMwVQyWv7Y/1AFr+PvNKVlw4RZ4G8VuJzXZ\n9v/+5zyKv8py66sGVoHPI+LGfIprAgMBAAECgYEAxcgX8PVrnrITiKwpJxReJbyL\nxnpOmw2i/zza3BseVzOebjNrhw/NQDWl0qhcvmBjvyR5IGiiwiwXq8bu8CBdhRiE\nw3vKf1iuVOKhH07RB2wvCaGbVlB/p15gYau3sTRn5nej0tjYHX7xa/St/DwPk2H/\nxYGTRhyYtNL6wdtMjYECQQD+LVVJf0rLnxyPADTcz7Wdb+FUX79nWtMlzQOEB09+\nJj4ie0kD0cIvTQFjV3pOsg3uW2khFpjg110TXpJJfPjhAkEAzL7RhhfDdL7Dn2zl\n1orUthcGa2pzEAmg1tGBNb1pOg7LbVHKSa3GOOwyPRsActoyrPw18/fXaJdEfByY\ne9kwywJAB7rHMjH9y01uZ+bgtKpYYo5JcvBqeLEpZKfkaHp0b2ioURIguU4Csr+L\nwEKjxIrjo5ECFHCEe6nw+arRlgyH4QJBAIfQmEn733LEzB0n7npXU2yKb363eSYN\nTPzSsoREZdXWVIjqtWYUeKXvwA+apryJEw5+qwdvwxslJI+zpE6bLusCQE6M1lO9\nN6A3PtQv7Z3XwrEE/sPEVv4M4VHj0YHLs/32UuSXq5taMizKILfis1Stry4WjRHp\nQxEqdLrIkb13NH8=\n-----END PRIVATE KEY-----", "client_email": "unit-and-integration-testing@tink-test-infrastructure.iam.gserviceaccount.com", "client_id": "111876397550362269561", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/unit-and-integration-testing%40tink-test-infrastructure.iam.gserviceaccount.com" } tink-go-gcpkms-2.2.0/testdata/gcp/credential_bad.json000066400000000000000000000030431461743517500225570ustar00rootroot00000000000000{ "type": "service_account", "project_id": "tink-test-infrastructure", "private_key_id": "some_bad_private_key_id", "private_key": "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMtJlaQD79xGIC28\nowTpj7wkdi34piSubtDKttgC3lL00ioyQf/WMqLnyDWySNufCjhavQ7/sxXQAUCL\n5B3WDwM8+mFqQM2wJB18NBWBSfGOFSMwVQyWv7Y/1AFr+PvNKVlw4RZ4G8VuJzXZ\n9v/+5zyKv8py66sGVoHPI+LGfIprAgMBAAECgYEAxcgX8PVrnrITiKwpJxReJbyL\nxnpOmw2i/zza3BseVzOebjNrhw/NQDWl0qhcvmBjvyR5IGiiwiwXq8bu8CBdhRiE\nw3vKf1iuVOKhH07RB2wvCaGbVlB/p15gYau3sTRn5nej0tjYHX7xa/St/DwPk2H/\nxYGTRhyYtNL6wdtMjYECQQD+LVVJf0rLnxyPADTcz7Wdb+FUX79nWtMlzQOEB09+\nJj4ie0kD0cIvTQFjV3pOsg3uW2khFpjg110TXpJJfPjhAkEAzL7RhhfDdL7Dn2zl\n1orUthcGa2pzEAmg1tGBNb1pOg7LbVHKSa3GOOwyPRsActoyrPw18/fXaJdEfByY\ne9kwywJAB7rHMjH9y01uZ+bgtKpYYo5JcvBqeLEpZKfkaHp0b2ioURIguU4Csr+L\nwEKjxIrjo5ECFHCEe6nw+arRlgyH4QJBAIfQmEn733LEzB0n7npXU2yKb363eSYN\nTPzSsoREZdXWVIjqtWYUeKXvwA+apryJEw5+qwdvwxslJI+zpE6bLusCQE6M1lO9\nN6A3PtQv7Z3XwrEE/sPEVv4M4VHj0YHLs/32UuSXq5taMizKILfis1Stry4WjRHp\nQxEqdLrIkb13NH8=\n-----END PRIVATE KEY-----", "client_email": "unit-and-integration-testing@tink-test-infrastructure.iam.gserviceaccount.com", "client_id": "111876397550362269561", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/unit-and-integration-testing%40tink-test-infrastructure.iam.gserviceaccount.com" } tink-go-gcpkms-2.2.0/testdata/gcp/key_name.txt000066400000000000000000000001561461743517500212770ustar00rootroot00000000000000projects/tink-test-infrastructure/locations/global/keyRings/unit-and-integration-testing/cryptoKeys/aead-key tink-go-gcpkms-2.2.0/testdata/gcp/key_name_bad.txt000066400000000000000000000001331461743517500221000ustar00rootroot00000000000000projects/non-existing-project/locations/global/keyRings/some-key-ring/cryptoKeys/aead-key tink-go-gcpkms-2.2.0/version.bzl000066400000000000000000000001511461743517500165550ustar00rootroot00000000000000"""Version of the current release of the Tink Go GCP KMS Extension""" TINK_GO_GCPKMS_EXTENSION = "2.2.0"