Thiết lập Tink C++

Sau khi cài đặt và thiết lập Tink, hãy tiếp tục với Các bước tiếp theo.

Khả năng tương thích

Tương thích với tất cả thư viện Ngoài ra, còn tương thích với Tink C++
Ngôn ngữ C++ >= 17 Không có
Hệ điều hành UbuntuLTS >= 20.04 (x86_64)
macOS >= 12.5 Monterey (x86_64)
Windows Server >= 2019 (x86_64)
Trình biên dịch GCC >= 7.5.0
Apple Clang >= 14
MSVC >= 2019
Hệ thống xây dựng Bazel >= 7 LTS CMake >= 3.22

Cài đặt

Tink C++

Thư viện C++ cốt lõi là tink-cc với bản phát hành mới nhất là 2.9.2.

Bazel

Bzlmod

Thêm đoạn mã này vào tệp MODULE.bazel:

bazel_dep(name = "tink_cc", version = "2.9.2")

CMake

Thêm tink-cc làm phần phụ thuộc trong cây.

cmake_minimum_required(VERSION 3.22)
project(YourProject CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
include(FetchContent)

# Import Tink as an in-tree dependency.
FetchContent_Declare(
  tink
  URL       https://github.com/tink-crypto/tink-cc/archive/refs/tags/v2.9.2.zip
  URL_HASH  SHA256=f5259652e09e26ca4a00c16c009a0930c18be0568e3fe34645db4208ebb57f8c
)
FetchContent_GetProperties(tink)
if(NOT googletest_POPULATED)
  FetchContent_Populate(tink)
    add_subdirectory(${tink_SOURCE_DIR} ${tink_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

add_executable(your_app your_app.cc)
target_link_libraries(your_app tink::static)

Tiện ích AWS KMS

Tiện ích Tink C++ AWS KMS là tink-cc-awskms với bản phát hành mới nhất là 2.0.1.

Bazel

WORKSPACE

Thêm đoạn mã này vào tệp WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "tink_cc",
    urls = ["https://github.com/tink-crypto/tink-cc/releases/download/v2.1.3/tink-cc-2.1.3.zip"],
    strip_prefix = "tink-2.1.3",
    sha256 = "14a3f64a56d7e9296889d7eba7a3b8787c3281e5bc5791033c54baf810a0b6ef",
)

load("@tink_cc//:tink_cc_deps.bzl", "tink_cc_deps")

tink_cc_deps()

load("@tink_cc//:tink_cc_deps_init.bzl", "tink_cc_deps_init")

tink_cc_deps_init()

http_archive(
    name = "tink_cc_awskms",
    urls = ["https://github.com/tink-crypto/tink-cc-awskms/archive/refs/tags/v2.0.1.zip"],
    strip_prefix = "tink-cc-awskms-2.0.1",
    sha256 = "366319b269f62af120ee312ce4c99ce3738ceb23ce3f9491b4859432f8b991a4",
)

load("@tink_cc_awskms//:tink_cc_awskms_deps.bzl", "tink_cc_awskms_deps")

tink_cc_awskms_deps()

Tiện ích Google Cloud KMS

Tiện ích Google Cloud KMS của Tink C++ là tink-cc-gcpkms, trong đó 2.7.0 là bản phát hành mới nhất.

Bazel

Thêm đoạn mã sau vào tệp MODULE.bazel của bạn:

bazel_dep(name = "tink_cc_gcpkms")

git_override(
    module_name = "tink_cc_gcpkms",
    remote = "https://github.com/tink-crypto/tink-cc-gcpkms",
    tag = "v2.7.0",
)

# ... Your dependencies here ...

Các bước tiếp theo

Sau khi thiết lập xong Tink, hãy tiếp tục với các bước sử dụng Tink tiêu chuẩn:

  • Chọn một thành phần gốc – Quyết định thành phần gốc cần sử dụng dựa trên trường hợp sử dụng của bạn
  • Quản lý khoá – Bảo vệ khoá bằng KMS bên ngoài, tạo tập hợp khoá và xoay vòng khoá