Tìm hiểu các khái niệm chính trong Tink
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Khi bắt đầu làm việc với Tink lần đầu tiên, bạn nên hiểu rõ một số khái niệm chính trước khi bắt đầu hành trình của mình. Các khái niệm này được mô tả trong các phần sau.
Nguyên sinh
Tink sử dụng dữ liệu gốc làm khối dựng mã hoá giúp quản lý thuật toán cơ sở để người dùng có thể thực hiện các tác vụ mã hoá một cách an toàn. Dữ liệu nguyên gốc xác định thông tin chi tiết về thuật toán mật mã và loại khoá.
Tính năng gốc do Tink hỗ trợ:
- Mã hoá đã xác thực với dữ liệu được liên kết (AEAD): Phương pháp nguyên gốc phổ biến nhất để mã hoá dữ liệu; phù hợp với hầu hết các nhu cầu mã hoá. AEAD cung cấp tính bảo mật qua văn bản thuần tuý và cho phép xác minh tính toàn vẹn và tính xác thực của tệp. Xem bài viết Mã hoá đã xác thực bằng dữ liệu được liên kết (AEAD).
- Mã hoá xác định: Một dữ liệu nguyên gốc luôn tạo cùng một bản mật mã cho một văn bản thuần tuý và khoá nhất định. Điều này có thể gây rủi ro vì kẻ tấn công chỉ cần tìm ra thuật toán mật mã nào tương ứng với một dữ liệu nhập bằng văn bản thuần tuý nhất định để xác định thuật toán đó. Xem phần AEAD xác định.
- Chữ ký số: Chữ ký số bất đối xứng (xem bài viết Mã hoá khoá bất đối xứng) để xác nhận tính xác thực và tính toàn vẹn của dữ liệu đã ký. Xem phần Chữ ký số.
- Mã hoá kết hợp: Một phương thức gốc kết hợp phương thức mã hoá khoá bất đối xứng và mã hoá khoá đối xứng (xem Mã hoá khoá bất đối xứng và Mã hoá khoá đối xứng). Phương thức mã hoá kết hợp kết hợp hiệu quả của quá trình mã hoá đối xứng với sự tiện lợi của phương thức mã hoá bằng khoá công khai. Để mã hoá thư, một khoá đối xứng mới sẽ được tạo và dùng để mã hoá dữ liệu văn bản thuần tuý, trong khi khoá công khai của người nhận chỉ được dùng để mã hoá khoá đối xứng. Thuật toán mật mã cuối cùng bao gồm văn bản mật mã đối xứng và khoá đối xứng đã mã hoá. Xem phần Mã hoá kết hợp.
- Mã xác thực thư (MAC): Một mô hình đối xứng (xem phần Mã hoá khoá đối xứng) để xác nhận tính xác thực và tính toàn vẹn của dữ liệu. Xem Mã xác thực thư (MAC).
- Truyền trực tuyến AEAD: Một dữ liệu gốc cung cấp phương thức mã hoá đã xác thực để truyền trực tuyến dữ liệu; hữu ích khi dữ liệu cần được mã hoá quá lớn để được xử lý trong một bước. Xem phần Truyền trực tuyến AEAD.
Xem phần Các dữ liệu gốc được hỗ trợ theo ngôn ngữ để biết thông tin về khả năng tương thích.
Để biết thêm thông tin, hãy xem phần thiết kế ban đầu.
Các loại khoá
Một loại khoá triển khai một nguyên gốc cụ thể. Hầu hết dữ liệu gốc đều có một số loại khoá để lựa chọn tuỳ thuộc vào yêu cầu của bạn về tính bảo mật, thời gian chạy và dung lượng. Ví dụ: AES128_GCM là một AEAD nhanh chóng và hiệu quả cho hầu hết nhu cầu. Vui lòng xem thêm trong phần Các loại phím được hỗ trợ theo ngôn ngữ.
Bộ bàn phím và ô điều khiển bộ phím
Tink sử dụng tập hợp khoá để quản lý khoá. Về cơ bản, tập hợp khoá là một tập hợp các khoá hỗ trợ việc xoay khoá. Các thuộc tính đáng chú ý của tập hợp khoá là:
- Mỗi khoá trong tập hợp khoá có một mã nhận dạng duy nhất trong tập hợp khoá. Mã nhận dạng này thường được thêm dưới dạng tiền tố vào mỗi thuật toán mật mã, chữ ký hoặc thẻ được tạo để cho biết khoá nào đã được sử dụng (xem cách bản mật mã thẻ của Tink để biết thêm thông tin).
- Mỗi lần trong một tập hợp khoá, chỉ có một khoá là chính. Hiện tại, khoá chính trong tập hợp khoá là khoá "đang được sử dụng".
- Tất cả các khoá trong một tập hợp khoá phải là cách triển khai có cùng một dữ liệu gốc (chẳng hạn như AEAD), nhưng có thể có nhiều loại khoá (ví dụ: khoá AES-GCM và khoá XCHACHA20-POLY1305).
Mỗi quá trình triển khai Tink đều cung cấp các API để tạo hoặc chỉnh sửa tập hợp khoá. Tuy nhiên, bạn nên sử dụng công cụ CLI Tinkey của chúng tôi.
Người dùng thao tác trên một tập hợp phím bằng ô điều khiển tập hợp phím. Xử lý tập hợp phím sẽ hạn chế việc hiển thị nội dung khoá nhạy cảm thực tế. Thư viện này cũng tóm tắt một tập hợp khoá cho phép người dùng có được dữ liệu gốc "bao bọc" toàn bộ tập hợp khoá. Ví dụ: bạn có thể lấy dữ liệu gốc AEAD của một tập hợp khoá có các khoá N
; việc mã hoá và giải mã bằng dữ liệu gốc thu được sau đó sử dụng khoá chính trong tập hợp khoá.
Để biết thêm thông tin, hãy xem nội dung thiết kế tập hợp phím.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eTink utilizes primitives as fundamental cryptographic building blocks for secure data operations, covering encryption, signatures, and message authentication.\u003c/p\u003e\n"],["\u003cp\u003eKeysets in Tink efficiently manage multiple keys for a single purpose, enabling features like key rotation and supporting various key types within a set.\u003c/p\u003e\n"],["\u003cp\u003eKeyset handles provide a secure abstraction layer, allowing users to interact with keys and perform cryptographic operations without directly exposing sensitive key material.\u003c/p\u003e\n"],["\u003cp\u003eTink offers a diverse selection of primitives and key types, accommodating varying security, performance, and storage requirements, with options like AEAD, digital signatures, and hybrid encryption.\u003c/p\u003e\n"]]],["Tink employs cryptographic building blocks called *primitives*, which define algorithms and key types. These include AEAD, Deterministic encryption, Digital signature, Hybrid encryption, MAC, and Streaming AEAD. *Key types* implement primitives, offering choices based on security and performance. *Keysets*, a set of keys with unique IDs, manage key rotation. *Keyset handles* abstract keysets, providing access to a primitive that operates over the entire keyset, including encryption/decryption with the primary key.\n"],null,["# Understand Key Concepts in Tink\n\nWhen you start working with Tink for the first time, there are some key concepts\nyou should understand before you begin your journey; these are described in the\nfollowing sections.\n\nPrimitives\n----------\n\nTink uses *primitives* as cryptographic building blocks that manage an\nunderlying algorithm so users can perform cryptographic tasks safely. A\nprimitive defines the details of a cryptographic algorithm and the key type.\n\nPrimitives supported by Tink:\n\n- **Authenticated Encryption with Associated Data (AEAD)** : The most common primitive for data encryption; suitable for most encryption needs. AEAD provides plaintext confidentiality, and allows verification of its integrity and authenticity. See [Authenticated Encryption with Associated Data\n (AEAD)](/tink/aead).\n- **Deterministic encryption:** A primitive that always produces the same ciphertext for a given plaintext and key. This can be risky, because an attacker only needs to find out which ciphertext corresponds to a given plaintext input to identify it. See [Deterministic\n AEAD](/tink/deterministic-aead).\n- **Digital signature** : An asymmetric (see *Asymmetric key encryption* ) primitive for confirming the authenticity and integrity of signed data. See [Digital signature](/tink/digital-signature).\n- **Hybrid encryption** : A primitive that combines asymmetric key encryption and symmetric key encryption (see *Asymmetric key encryption* and *Symmetric\n key encryption* ). Hybrid encryption combines the efficiency of symmetric encryption with the convenience of public-key encryption. To encrypt a message, a fresh symmetric key is generated and used to encrypt the plaintext data, while the recipient's public key is used to encrypt the symmetric key only. The final ciphertext consists of the symmetric ciphertext and the encrypted symmetric key. See [Hybrid\n encryption](/tink/hybrid).\n- **Message Authentication Code (MAC)** : A symmetric (see *Symmetric key\n encryption* ) primitive for confirming the authenticity and integrity of data. See [Message Authentication Code (MAC)](/tink/mac).\n- **Streaming AEAD** : A primitive providing authenticated encryption for streaming data; useful when the data to be encrypted is too large to be processed in a single step. See [Streaming AEAD](/tink/streaming-aead).\n\nSee [Supported primitives by language](/tink/primitives-by-language) for\ncompatibility information.\n\nFor more info, see [primitive design](/tink/design/primitives_and_interfaces).\n\nKey types\n---------\n\nA *key type* implements a specific primitive. Most primitives have several key\ntypes to choose from depending on your requirements for security, runtime, and\nspace. For example, AES128_GCM is an [AEAD](/tink/aead) that is fast and\neffective for most needs. See more at [Supported key types by\nlanguage](/tink/supported-key-types).\n\nKeysets \\& keyset handles\n-------------------------\n\nTink uses *keysets* for managing keys. A keyset is essentially a set of keys\nthat facilitate key rotation. Noteworthy properties of a keyset are:\n\n- Each key in a keyset has a unique ID, which is unique within a keyset. This ID is usually added as a prefix to each produced ciphertext, signature or tag to indicate which key was used (see how Tink [tags\n ciphertexts](/tink/design/keysets#tagging_ciphertexts) for more info).\n- Only one key at a time in a keyset is *primary*. A primary key in a keyset is the key \"in use\" at the moment.\n- All the keys in a keyset *must* be implementations of the same primitive (such as AEAD), but can have different key types (for example, an AES-GCM and XCHACHA20-POLY1305 key).\n\nEach Tink implementation provides APIs to create or edit keysets. However, we\nrecommend using [Tinkey](/tink/tinkey-overview) our CLI tool.\n\nUsers operate over a keyset using *keyset handles* . A keyset handle limits the\nexposure of the actual sensitive key material. It also abstracts a keyset\nallowing users to obtain a primitive that \"wraps\" the entire keyset. For\nexample, you can get an AEAD primitive of a keyset with `N` keys; encryption and\ndecryption with the obtained primitive then uses the primary key in the keyset.\n\nFor more info, see [keyset design](/tink/design/keysets)."]]