After installing and setting up Tink, continue with Next Steps.
Tink Java
The core Java library is tink-java with 1.16.0 as the latest release. Tink Java supports Java 8 or newer.
Maven
You can include Tink Java using Maven:
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink</artifactId>
<version>1.16.0</version>
</dependency>
Bazel
Maven release artifact
The recommended way Bazel users can add Tink Java as a
dependency is by installing the Maven release artifact using the
rules_jvm_external
tool in their WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "6.1"
RULES_JVM_EXTERNAL_SHA ="d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac"
http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"com.google.crypto.tink:tink:1.16.0",
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Build from source
If you want to build tink-java
from source, for example to pin a specific
commit, you can include it as an http_archive
in your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
TINK_COMMIT="f4127f6b6ab9c367d41ade1f50db6f0ef9909044"
TINK_SHA256="e246f848f7749e37f558955ecb50345b04d79ddb9d8d1e8ae19f61e8de530582"
http_archive(
name = "tink_java",
urls = ["https://github.com/tink-crypto/tink-java/archive/%s.zip" % TINK_COMMIT],
strip_prefix = "tink-%s" % TINK_COMMIT,
sha256 = TINK_SHA256
)
load("@tink_java//:tink_java_deps.bzl", "TINK_MAVEN_ARTIFACTS", "tink_java_deps")
tink_java_deps()
load("@tink_java//:tink_java_deps_init.bzl", "tink_java_deps_init")
tink_java_deps_init()
# rules_jvm_external is imported and initialized by tink_java_deps and
# tink_java_deps_init.
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = TINK_MAVEN_ARTIFACTS + # ... other dependencies ...
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Tink Android
The core Android library is tink-java with 1.16.0 as the latest release.
Tink Android is fully supported starting from API level 24. Most parts of Tink are expected to work starting from API level 21. The parts where Tink does not run out of the box with API level 21 are:
The JWT library requires API level 24 since it uses classes such as
java.util.Optional
. This limitation can be avoided with desugaring.The classes in
com.google.crypto.tink.integration.android
are only fully tested starting from API level 23.Some APIs in
com.google.crypto.tink.streamingaead
useSeekableByteBufferChannel
which is only available from API level 24.
Due to technical reasons, we only test Tink on Android on Google internal infrastructure. We don't expect any problems because of this, but if you encounter any problems, please file an issue.
Tink Android requires no proguard configuration.
Gradle
You can use tink-android
from Gradle:
dependencies {
implementation 'com.google.crypto.tink:tink-android:1.16.0'
}
AWS KMS Extension
The Tink Java AWS KMS extension is tink-java-awskms with 1.11.0 as the latest release.
Maven
You can include the Tink Java AWS KMS extension using Maven:
<dependencies>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink-awskms</artifactId>
<version>1.11.0</version>
</dependency>
</dependencies>
Bazel
Maven release artifact
You can install the com.google.crypto.tink:tink-awskms
Maven artifact
alongside com.google.crypto.tink:tink
using the
rules_jvm_external
tool.
# ...
maven_install(
artifacts = [
"com.google.crypto.tink:tink:1.16.0",
"com.google.crypto.tink:tink-awskms:1.11.0",
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Build from source
If you want to build tink-awskms
from source, for example to pin a
specific commit, you can include it as an http_archive
in your WORKSPACE
file:
# ...
http_archive(
name = "tink_java",
urls = ["https://github.com/tink-crypto/tink-java/releases/download/v1.16.0/tink-java-1.16.0.zip"],
strip_prefix = "tink-java-1.16.0",
sha256 = "6bf0bb13281257fdf07d70abfc025f0e3ab18abd22646b1ada3fe297f7feaedb",
)
load("@tink_java//:tink_java_deps.bzl", "TINK_MAVEN_ARTIFACTS", "tink_java_deps")
tink_java_deps()
load("@tink_java//:tink_java_deps_init.bzl", "tink_java_deps_init")
tink_java_deps_init()
http_archive(
name = "tink_java_awskms",
urls = ["https://github.com/tink-crypto/tink-java-awskms/releases/download/v1.11.0/tink-java-awskms-1.11.0.zip"],
strip_prefix = "tink-java-awskms-1.11.0",
sha256 = "18f8faa7ba0019fc584f9e03f94221ebbcc83f059568d2277a4866003153e151",
)
load("@tink_java_awskms//:tink_java_awskms_deps.bzl", "TINK_JAVA_AWSKMS_MAVEN_ARTIFACTS")
maven_install(
artifacts = TINK_MAVEN_ARTIFACTS + TINK_JAVA_AWSKMS_MAVEN_ARTIFACTS + [
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Google Cloud KMS Extension
The Tink Java Google Cloud KMS extension is tink-java-gcpkms with 1.10.0 as the latest release.
Maven
You can include the Tink Java Google Cloud KMS extension using Maven:
<dependencies>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>tink-gcpkms</artifactId>
<version>1.10.0/version>
</dependency>
</dependencies>
Bazel
Maven release artifact
You can install the com.google.crypto.tink:tink-gcpkms
Maven artifact
alongside com.google.crypto.tink:tink
using the
rules_jvm_external
tool.
# ...
maven_install(
artifacts = [
"com.google.crypto.tink:tink:1.16.0",
"com.google.crypto.tink:tink-gcpkms:1.10.0",
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Build from source
If you want to build tink-gcpkms
from source, for example to pin a
specific commit, you can include it as an http_archive
in your WORKSPACE
file:
# ...
http_archive(
name = "tink_java",
urls = ["https://github.com/tink-crypto/tink-java/releases/download/v1.16.0/tink-java-1.16.0.zip"],
strip_prefix = "tink-java-1.16.0",
sha256 = "6bf0bb13281257fdf07d70abfc025f0e3ab18abd22646b1ada3fe297f7feaedb",
)
load("@tink_java//:tink_java_deps.bzl", "TINK_MAVEN_ARTIFACTS", "tink_java_deps")
tink_java_deps()
load("@tink_java//:tink_java_deps_init.bzl", "tink_java_deps_init")
tink_java_deps_init()
http_archive(
name = "tink_java_gcpkms",
urls = ["https://github.com/tink-crypto/tink-java-gcpkms/releases/download/v1.10.0/tink-java-gcpkms-1.10.0.zip"],
strip_prefix = "tink-java-gcpkms-1.10.0",
sha256 = "ad85625cc4409f2f6ab13a8eef39c965501585e9323d59652cce322b3d2c09a2",
)
load("@tink_java_gcpkms//:tink_java_gcpkms_deps.bzl", "TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS")
maven_install(
artifacts = TINK_MAVEN_ARTIFACTS + TINK_JAVA_GCPKMS_MAVEN_ARTIFACTS + [
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Tink Java Apps
The Tink Java Apps library provides implementations for Google Payment Method Token, Server-Side Verification of Google AdMob Rewarded Ads, and RFC 8291 - Message Encryption for Web Push with 1.11.0 as the latest release.
Maven
You can include the Tink Java Apps library using Maven:
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>apps-webpush</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>apps-paymentmethodtoken</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.google.crypto.tink</groupId>
<artifactId>apps-rewardedads</artifactId>
<version>1.11.0</version>
</dependency>
Bazel
You can install any of the com.google.crypto.tink:apps-*
Maven artifacts
using the rules_jvm_external
tool.
# ...
maven_install(
artifacts = [
"com.google.crypto.tink:apps-webpush:1.11.0",
"com.google.crypto.tink:apps-paymentmethodtoken:1.11.0",
"com.google.crypto.tink:apps-rewardedads:1.11.0",
# ... other dependencies ...
],
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Next steps
Once you've finished setting up Tink, continue with the standard Tink usage steps:
- Choose a primitive – Decide which primitive to use based on your use case
- Manage keys – Protect your keys with your external KMS, generate keysets, and rotate your keys