Skip to content

Commit 94f258d

Browse files
tholenstmorambro
authored andcommitted
Internal change
COPYBARA_INTEGRATE_REVIEW=tink-crypto/tink#563 from yoavamit:master 4912787b7611705e0307482f27fb1ef9b49651a3 PiperOrigin-RevId: 450438135 Change-Id: I782c9518cabee96d56bbd4b9b6c30352cb5008b0
1 parent 0fdb6c2 commit 94f258d

File tree

593 files changed

+100668
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

593 files changed

+100668
-0
lines changed

.bazelversion

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.1.1

BUILD.bazel

+557
Large diffs are not rendered by default.

WORKSPACE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
workspace(name = "tink_java")
2+
3+
load("@tink_java//:tink_java_deps.bzl", "tink_java_deps")
4+
tink_java_deps()
5+
6+
load("@tink_java//:tink_java_deps_init.bzl", "tink_java_deps_init")
7+
tink_java_deps_init()

jar_jar_rules.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Rules File Format: https://github.com/bazelbuild/bazel/blob/master/third_party/jarjar/java/com/tonicsystems/jarjar/help.txt.
2+
#
3+
# Shade protobuf to avoid dependency version conflicts in user projects.
4+
# WARNING: the shaded package name com.google.crypto.tink.shaded.protobuf must
5+
# be kept in sync with src/main/resources/META-INF/proguard/tink.pro.
6+
rule com.google.protobuf.** com.google.crypto.tink.shaded.protobuf.@1

kokoro/testutils/copy_credentials.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
####################################################################################
17+
18+
# This script takes credentials injected into the environment via the Kokoro job
19+
# configuration and copies them to the expected locations to facilitate
20+
# continuous integration testing.
21+
#
22+
# Usage insructions:
23+
#
24+
# ./kokoro/testutils/copy_credentials.sh <testdata dir>
25+
26+
if [[ -z "${KOKORO_ROOT}" ]]; then
27+
exit 0
28+
fi
29+
30+
readonly TESTDATA_DIR="${1}"
31+
32+
if [[ -z "${TESTDATA_DIR}" ]]; then
33+
echo "Testdata directory must be set" >&2
34+
exit 1
35+
fi
36+
37+
if [[ ! -d "${TESTDATA_DIR}" ]]; then
38+
echo "Testdata directory \"${TESTDATA_DIR}\" doesn't exist" >&2
39+
exit 1
40+
fi
41+
42+
cp "${TINK_TEST_SERVICE_ACCOUNT}" "${TESTDATA_DIR}/credential.json"
43+
44+
# Create the different format for the AWS credentials
45+
readonly AWS_KEY_ID="AKIATNYZMJOHVMN7MSYH"
46+
readonly AWS_KEY="$(cat ${AWS_TINK_TEST_SERVICE_ACCOUNT})"
47+
48+
cat <<END \
49+
| tee "${TESTDATA_DIR}/aws_credentials_cc.txt" \
50+
"${TESTDATA_DIR}/credentials_aws.ini" \
51+
> /dev/null
52+
[default]
53+
aws_access_key_id = ${AWS_KEY_ID}
54+
aws_secret_access_key = ${AWS_KEY}
55+
END
56+
57+
cat <<END > "${TESTDATA_DIR}/credentials_aws.cred"
58+
[default]
59+
accessKey = ${AWS_KEY_ID}
60+
secretKey = ${AWS_KEY}
61+
END
62+
63+
64+
cat <<END > "${TESTDATA_DIR}/credentials_aws.csv"
65+
User name,Password,Access key ID,Secret access key,Console login link
66+
tink-user1,,${AWS_KEY_ID},${AWS_KEY},https://235739564943.signin.aws.amazon.com/console
67+
END
+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
r"""Creates the "BUILD.bazel" file on Kororo.
15+
16+
Usage: python3 create_main_build_file.py \
17+
java_dependencies_file.txt \
18+
android_dependencies_file.txt \
19+
aws_kms_dependencies_file.txt \
20+
gcp_kms_dependencies_file.txt
21+
where the files contain a list of dependencies to be used in the created file.
22+
"""
23+
24+
import string
25+
import sys
26+
27+
TEMPLATE = string.Template("""\
28+
## This file is created using "create_main_build_file.py".
29+
30+
load("//tools:gen_maven_jar_rules.bzl", "gen_maven_jar_rules")
31+
load("//tools:check_deps.bzl", "check_deps")
32+
33+
package(default_visibility = ["//visibility:public"])
34+
35+
licenses(["notice"])
36+
37+
exports_files(["BUILD"])
38+
39+
# Maven jars.
40+
# DO NOT USE FOR ANY OTHER PURPOSES.
41+
42+
gen_maven_jar_rules(
43+
name = "tink",
44+
doctitle = "Tink Cryptography API",
45+
manifest_lines = [
46+
"Automatic-Module-Name: com.google.crypto.tink",
47+
],
48+
root_packages = [
49+
"com.google.crypto.tink",
50+
],
51+
deps = [
52+
$java_deps_formatted
53+
],
54+
)
55+
56+
gen_maven_jar_rules(
57+
name = "tink-android",
58+
doctitle = "Tink Cryptography API for Android",
59+
resources = glob([
60+
"src/main/resources/**",
61+
]),
62+
root_packages = [
63+
"com.google.crypto.tink",
64+
],
65+
shaded_packages = [
66+
# The following package(s) will be shaded, according to the rules
67+
# specified in shading_rules.
68+
"com.google.protobuf",
69+
],
70+
shading_rules = "jar_jar_rules.txt",
71+
deps = [
72+
$andr_deps_formatted
73+
],
74+
)
75+
76+
gen_maven_jar_rules(
77+
name = "tink-awskms",
78+
doctitle = "Tink Cryptography API with AWS KMS",
79+
manifest_lines = [
80+
"Automatic-Module-Name: com.google.crypto.tink.integration.awskms",
81+
],
82+
root_packages = [
83+
"com.google.crypto.tink",
84+
],
85+
deps = [
86+
$awsk_deps_formatted
87+
],
88+
)
89+
90+
gen_maven_jar_rules(
91+
name = "tink-gcpkms",
92+
doctitle = "Tink Cryptography API with Google Cloud KMS",
93+
manifest_lines = [
94+
"Automatic-Module-Name: com.google.crypto.tink.integration.gcpkms",
95+
],
96+
root_packages = [
97+
"com.google.crypto.tink",
98+
],
99+
deps = [
100+
$gcpk_deps_formatted
101+
],
102+
)
103+
104+
# Check that tink-android depends on protobuf-lite, not the full version.
105+
check_deps(
106+
name = "tink-android-dep-checks",
107+
disallowed_deps = ["@com_google_protobuf//java/core:core"],
108+
required_deps = ["@com_google_protobuf//java/lite:lite"],
109+
deps = [":tink-android-unshaded"],
110+
)""")
111+
112+
113+
def _format_deps(deps_list):
114+
"""Maps a list of dependencies into a single string."""
115+
116+
stripped_deps = [l.strip() for l in sorted(deps_list)]
117+
indented_quoted_deps = [' "{}",'.format(l) for l in stripped_deps]
118+
return '\n'.join(indented_quoted_deps)
119+
120+
121+
def main():
122+
if len(sys.argv) != 5:
123+
sys.exit('4 Arguments Required')
124+
125+
with open(sys.argv[1], 'r') as f:
126+
java_deps_file_content = f.readlines()
127+
with open(sys.argv[2], 'r') as f:
128+
android_deps_file_content = f.readlines()
129+
with open(sys.argv[3], 'r') as f:
130+
aws_kms_deps_file_content = f.readlines()
131+
with open(sys.argv[4], 'r') as f:
132+
gcp_kms_deps_file_content = f.readlines()
133+
134+
print(
135+
TEMPLATE.substitute(
136+
java_deps_formatted=_format_deps(java_deps_file_content),
137+
andr_deps_formatted=_format_deps(android_deps_file_content),
138+
awsk_deps_formatted=_format_deps(aws_kms_deps_file_content),
139+
gcpk_deps_formatted=_format_deps(gcp_kms_deps_file_content)))
140+
141+
if __name__ == '__main__':
142+
main()

kokoro/testutils/install_cmake.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
################################################################################
16+
17+
# This scripts installs CMake of a given version and SHA256. If the version is
18+
# not specified, DEFAULT_CMAKE_VERSION is used; similarly the digest is by
19+
# default DEFAULT_CMAKE_SHA256.
20+
#
21+
# NOTEs:
22+
# * If not running on Kokoro, this script will do nothing.
23+
# * This script MUST be sourced to update the environment of the calling
24+
# script.
25+
# * If a custom version is passed, the corresponding digest should be passed
26+
# too.
27+
#
28+
# Usage:
29+
# source ./kokoro/testutils/install_cmake.sh [version] [sha256]
30+
31+
readonly DEFAULT_CMAKE_VERSION="3.21.3"
32+
readonly DEFAULT_CMAKE_SHA256="a19aa9fcf368e9d923cdb29189528f0fe00a0d08e752ba4e547af91817518696"
33+
34+
install_cmake() {
35+
local cmake_version="${1:-${DEFAULT_CMAKE_VERSION}}"
36+
local cmake_sha256="${2:-${DEFAULT_CMAKE_SHA256}}"
37+
local cmake_name="cmake-${cmake_version}-linux-x86_64"
38+
local cmake_archive="${cmake_name}.tar.gz"
39+
local cmake_url="https://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_archive}"
40+
local cmake_tmpdir="$(mktemp -dt tink-cmake.XXXXXX)"
41+
(
42+
cd "${cmake_tmpdir}"
43+
curl -OLsS "${cmake_url}"
44+
echo "${cmake_sha256} ${cmake_archive}" | sha256sum -c
45+
46+
tar xzf "${cmake_archive}"
47+
)
48+
export PATH="${cmake_tmpdir}/${cmake_name}/bin:${PATH}"
49+
}
50+
51+
if [[ -n "${KOKORO_ROOT:-}" ]]; then
52+
# If specifying the version, users must also specify the digest.
53+
if (( "$#" == 1 )); then
54+
echo \
55+
"The SHA256 digest must be provided too when specifying CMake's version" \
56+
>&2
57+
exit 1
58+
fi
59+
install_cmake "$@"
60+
fi

kokoro/testutils/install_go.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
################################################################################
17+
18+
# This script installs a recent version of Go into a temporary directory. The Go
19+
# bin directory is then added to the PATH environment variable.
20+
#
21+
# NOTE: This script MUST be sourced to update the environment of the calling
22+
# script.
23+
#
24+
# Usage instructions:
25+
#
26+
# source ./kokoro/testutils/install_go.sh
27+
28+
install_temp_go() {
29+
local -r go_version="1.17.7"
30+
31+
local -r platform="$(uname | tr '[:upper:]' '[:lower:]')"
32+
local go_platform
33+
case "${platform}" in
34+
'linux')
35+
go_platform='linux-amd64'
36+
;;
37+
'darwin')
38+
go_platform='darwin-amd64'
39+
;;
40+
*)
41+
echo "Unsupported platform, unable to install Go."
42+
exit 1
43+
;;
44+
esac
45+
readonly go_platform
46+
47+
local -r go_archive="go${go_version}.${go_platform}.tar.gz"
48+
local -r go_url="https://go.dev/dl/${go_archive}"
49+
50+
local -r go_tmpdir=$(mktemp -dt tink-go.XXXXXX)
51+
(
52+
cd "${go_tmpdir}"
53+
curl -OLsS "${go_url}"
54+
tar -xzf "${go_archive}"
55+
)
56+
57+
export GOROOT="${go_tmpdir}/go"
58+
export PATH="${go_tmpdir}/go/bin:${PATH}"
59+
}
60+
61+
if [[ -n "${KOKORO_ROOT:-}" ]] ; then
62+
install_temp_go
63+
fi

0 commit comments

Comments
 (0)