ตั้งค่า Tink C++

หลังจากติดตั้งและตั้งค่า Tink แล้ว ให้ทำตามขั้นตอนถัดไป

ความเข้ากันได้

เข้ากันได้กับไลบรารีทั้งหมด เข้ากันได้กับ Tink C++ ด้วย
ภาษา C++ >= 17 ไม่มี
ระบบปฏิบัติการ UbuntuLTS >= 20.04 (x86_64)
macOS >= 12.5 Monterey (x86_64)
Windows Server >= 2019 (x86_64)
คอมไพเลอร์ GCC >= 7.5.0
Apple Clang >= 14
MSVC >= 2019
ระบบบิลด์ Bazel >= 7 LTS CMake >= 3.22

การติดตั้ง

Tink C++

ไลบรารี C++ หลักคือ tink-cc โดยมี 2.9.1 เป็นเวอร์ชันล่าสุด

Bazel

Bzlmod

เพิ่มโค้ดนี้ลงในไฟล์ MODULE.bazel

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

CMake

เพิ่ม tink-cc เป็นทรัพยากร Dependency ในโครงสร้าง

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.1.zip
  URL_HASH  SHA256=247a79909be0e6b7e6096e87fd8fc2707c14f7a5051e4faf783c5a55656e3055
)
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)

ส่วนขยาย AWS KMS

ส่วนขยาย Tink C++ AWS KMS คือ tink-cc-awskms โดยมีเวอร์ชัน 2.0.1 เป็นเวอร์ชันล่าสุด

Bazel

WORKSPACE

เพิ่มโค้ดนี้ลงในไฟล์ 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()

ส่วนขยาย Google Cloud KMS

ส่วนขยาย Tink C++ Google Cloud KMS คือ tink-cc-gcpkms โดยมีเวอร์ชัน 2.6.0 เป็นเวอร์ชันล่าสุด

Bazel

เพิ่มโค้ดต่อไปนี้ลงในไฟล์ MODULE.bazel

bazel_dep(name = "tink_cc_gcpkms")

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

# ... Your dependencies here ...

ขั้นตอนถัดไป

เมื่อตั้งค่า Tink เสร็จแล้ว ให้ทำตามขั้นตอนการใช้งาน Tink มาตรฐานดังนี้

  • เลือก Primitive - ตัดสินใจว่าจะใช้ Primitive ใด ตามกรณีการใช้งาน
  • จัดการคีย์ - ปกป้องคีย์ด้วย KMS ภายนอก สร้างชุดคีย์ และหมุนเวียนคีย์