Tink là gì?
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.
Tink là một thư viện mật mã nguồn mở do các nhà mật mã học và
kỹ sư bảo mật tại Google. Các API an toàn và đơn giản của Tink giúp giảm bớt tình trạng phổ biến
các sai sót qua thiết kế tập trung vào người dùng, triển khai cẩn thận và đánh giá mã,
và thử nghiệm mở rộng. Xem phần Mục tiêu trên trang này để
thông tin chi tiết hơn về những mục tiêu mà Tink được thiết kế để thực hiện.
Tink giúp người dùng không có nền tảng mật mã triển khai an toàn các công cụ chung
các nhiệm vụ mã hoá. Tại Google, Tink đã được triển khai trong hàng trăm sản phẩm
và hệ thống.
Vì sao nên dùng Tink?
Sau đây là những lý do quan trọng nhất để sử dụng Tink:
Dễ sử dụng
Mã hoá rất khó để đoán đúng. Với Tink, bạn có thể
mã hoá hoặc ký dữ liệu bằng
các đảm bảo bảo mật được tích hợp sẵn chỉ bằng một vài dòng mã. Tink cũng có thể
giúp bạn thay đổi khoá hoặc khoá an toàn bằng Hệ thống quản lý khoá bên ngoài
(KMS).
An toàn
Tink bổ sung các biện pháp bảo mật để hỗ trợ các thư viện nổi tiếng như BoringSSL
và Kiến trúc mã hoá Java
và hiển thị chúng ngay trong giao diện,
để người kiểm tra và công cụ
nhanh chóng tìm ra lỗ hổng. Tink cũng tách riêng các API
đều có khả năng gây nguy hiểm nên bạn có thể theo dõi chúng.
Chương trình này tương thích
Thuật toán mật mã tink tương thích với các thư viện mật mã học hiện có. Tiếng Tink
cũng hỗ trợ mã hoá hoặc lưu trữ khoá trong
Amazon KMS, Google Cloud KMS, Kho khoá Android và iOS Keychain.
Ai đang sử dụng Tink?
Tink được nhiều công ty sử dụng rộng rãi, trong đó có Google, Square và Thành phố
cũng như hàng trăm khách hàng của Google Cloud và đối tác của Google Pay. Cũng tink
hỗ trợ thư viện Jetpack Security, giúp bảo mật nhiều ứng dụng Android phổ biến
như Slack, Adidas, AirBnb và Nextdoor.
Mục tiêu của Tink
Mục tiêu chính của Tink so với các thư viện mật mã khác là gì và
Tink sử dụng các cơ chế chính nào để đạt được những mục tiêu này?
Tóm lại, Tink có hai mục tiêu:
- Tăng cường sự linh hoạt của hoạt động mã hoá: Người dùng có thể thay đổi khoá và
các thuật toán quảng cáo một cách đơn giản.
- Hỗ trợ đánh giá bảo mật: Mục tiêu của Tink là cho phép người dùng viết mã có
cục bộ có thể xem xét mức độ bảo mật bằng cách cung cấp giao diện thể hiện rõ
đảm bảo bảo mật.
Sau đây là các cơ chế chính mà Tink sử dụng để đạt được những mục tiêu này:
- Tink cung cấp các thành phần gốc và giao diện dưới dạng các thành phần trừu tượng quan trọng. Các
trừu tượng cho phép người dùng viết mã không chỉ định chính xác
được sử dụng, nhưng thay vào đó chỉ định khái niệm bảo mật dự kiến.
- Tink sử dụng khái niệm "keyset", là một tập hợp các khoá được
liên kết với một dữ liệu nguyên gốc cụ thể. Điều này dẫn đến việc người dùng phải viết mã
Tính năng này hoạt động với nhiều khoá.
- Trong Tink, các khoá không chỉ do tài liệu khoá cơ bản chỉ định mà còn
thuật toán mật mã cũng như tất cả tham số. Điều này có nghĩa là
một khoá Tink luôn chọn một hàm mật mã duy nhất trong số tất cả
có thể tồn tại và không có chỗ để diễn giải.
Các phần sau đây sẽ giải thích các khái niệm này chi tiết hơn.
Tính linh hoạt của mã hoá
Hãy cân nhắc làm việc với Kỹ thuật phần mềm tại Google,
một cuốn sách về các bài học rút ra trong lĩnh vực kỹ thuật phần mềm, cùng với
có tiêu đề phụ là "các bài học rút ra được từ chương trình theo thời gian". Trong đó, tác giả chuyển đến
rất dài để giải thích tác động của việc mọi thứ thay đổi. Chiến dịch này
thực tế cũng ảnh hưởng nhiều đến thiết kế của Tink. Trong mật mã học, điều quan trọng là
mà mọi người chuẩn bị cho sự thay đổi. Khoá sẽ bị rò rỉ và thuật toán sẽ bị hỏng.
Khả năng thay đổi khoá và thuật toán rất quan trọng đối với nhiều người dùng và
chuẩn bị là thận trọng.
Đánh giá bảo mật và tài sản địa phương
Tink quảng bá việc sử dụng các giao diện, chẳng hạn như giao diện AEAD của chúng tôi, cho phép
người dùng để mã hoá dữ liệu. Ngoài các bảo đảm bảo mật khác, AEAD
đảm bảo rằng nhiều lần mã hoá của cùng một chuỗi sẽ dẫn đến
mật mã.
Để xem cách sử dụng quy trình này, giả sử một kỹ sư muốn lưu trữ một số thông tin nhạy cảm
mã nhận dạng trong cookie người dùng. Chúng có thể cung cấp một lớp như sau:
class IdEncrypter {
public static IdEncrypter createFromAead(Aead aead);
public String encrypt(long id) throws GeneralSecurityException;
public long decrypt(String encrypted) throws GeneralSecurityException;
};
Khi truyền Aead
, bạn sẽ nhận được các thuộc tính sau:
- Mã này thông báo rằng để
IdEncrypter
thực hiện công việc, mã này yêu cầu
lược đồ mã hoá với các thuộc tính bảo mật mà Aead
cung cấp.
Ngoài ra, một
DeterministicAead
là không đủ -- IdEncrypter
yêu cầu hai mã hoá của
cùng một id thì khác nhau. Mặt khác, lấy tham số làm phiên bản của
trình mã hoá AES GCM (một phiên bản cụ thể của Aead
) sẽ quá tốn kém
nghiêm ngặt: mọi Aead đều đủ để IdEncrypter
thực hiện công việc của nó và không
cần phải là một thuật toán cụ thể.
- Quá trình đánh giá bảo mật có thể tính đến điểm này. Nhân viên đánh giá bảo mật sẽ
không cần phải đi qua toàn bộ kho lưu trữ mã để kiểm tra xem
ở đâu đó, ai đó đã tạo một lớp con của
Aead
không an toàn để sử dụng
cùng với IdEncrypter
. Thay vào đó, Tink cung cấp các thuộc tính bảo mật mà tất cả
Đối tượng Aead có và nhân viên đánh giá có thể kiểm tra để đảm bảo các đối tượng này là đủ.
Đặc biệt, điểm thứ hai đòi hỏi bạn phải hết sức chú ý. Người dùng thường yêu cầu thêm
các thuật toán "không chính xác" Aead
. Điểm trước minh hoạ lý do
điều này thật nguy hiểm: nếu có bất kỳ cách triển khai nào của Aead
không cung cấp các biện pháp đảm bảo bắt buộc về tính bảo mật, IdEncrypter
có thể trở nên không an toàn,
và kỹ sư thực hiện đánh giá bảo mật cần kiểm tra mã bổ sung
để kiểm tra xem đối tượng có được tạo thực thể chính xác hay không.
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.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eTink is an open-source cryptography library designed for easy and secure implementation of common cryptographic tasks, even for users without a cryptography background.\u003c/p\u003e\n"],["\u003cp\u003eTink prioritizes security by adding protections on top of existing libraries like BoringSSL, using distinct APIs for potentially risky operations, and ensuring ciphertext compatibility with other libraries.\u003c/p\u003e\n"],["\u003cp\u003eTink promotes cryptographic agility by enabling easy key and algorithm changes, and it supports integration with external key management systems like Amazon KMS and Google Cloud KMS.\u003c/p\u003e\n"],["\u003cp\u003eDesigned with security reviews in mind, Tink utilizes interfaces with clear security guarantees and the concept of keysets for enhanced security and code clarity.\u003c/p\u003e\n"],["\u003cp\u003eGoogle, Square, and Citadel are among the many companies that utilize Tink, further demonstrating its reliability and widespread adoption within various applications and systems.\u003c/p\u003e\n"]]],["Tink, a Google-developed open-source cryptography library, simplifies secure cryptographic implementation for users, even without cryptography expertise. It's designed for simplicity, security, and compatibility, supporting key rotation and external Key Management Systems (KMS). Tink prioritizes cryptographic agility, enabling easy key and algorithm changes, and facilitates security reviews by providing clear interfaces and security guarantees. It uses primitives, keysets, and comprehensive key specifications to achieve these goals, ensuring secure, verifiable, and adaptable cryptographic operations.\n"],null,["# What is Tink?\n\nTink is an open-source cryptography library written by cryptographers and\nsecurity engineers at Google. Tink's secure and simple APIs reduce common\npitfalls through user-centered design, careful implementation and code reviews,\nand extensive testing. See the [Goals](#tink_goals) section on this page for\nmore insight into which objectives Tink was designed to fulfil.\n\nTink helps users without a cryptography background safely implement common\ncryptographic tasks. At Google, Tink has been deployed in hundreds of products\nand systems.\n\nWhy should I use Tink?\n----------------------\n\nThe most important reasons to use Tink are:\n\n- **It's simple to use**\n\n Cryptography is difficult to get right. With Tink, you can\n [encrypt](/tink/encrypt-data) or [sign data](/tink/digitally-sign-data) with\n built-in security guarantees using just a few lines of code. Tink can also\n help you rotate keys or secure keys using external Key Management Systems\n (KMSs).\n- **It's secure**\n\n Tink adds security protections on top of well known libraries like BoringSSL\n and Java Cryptography Architecture and shows them right in the interfaces,\n so auditors and tools can quickly find gaps. Tink also separates APIs that\n are potentially dangerous, so you can monitor them.\n- **It's compatible**\n\n Tink ciphertexts are compatible with existing cryptography libraries. Tink\n also supports [encrypting or storing keys](/tink/client-side-encryption) in\n Amazon KMS, Google Cloud KMS, Android Keystore, and iOS Keychain.\n\nWho's using Tink?\n-----------------\n\nTink is widely used by many companies, including Google, Square, and Citadel, as\nwell as hundreds of Google Cloud customers and Google Pay partners. Tink also\npowers the Jetpack Security library, which secures many popular Android apps\nlike Slack, Adidas, AirBnb, and Nextdoor.\n\nTink Goals\n----------\n\nWhat are the main goals of Tink compared to other cryptographic libraries, and\nwhat are the main mechanisms which Tink uses to achieve these goals?\n\nIn short, Tink has two goals:\n\n1. *Promote cryptographic agility*: Users should be able to change keys and algorithms in a simple way.\n2. *Enable security reviews*: Tink aims to allow users to write code whose security can be reviewed locally, by providing interfaces which give clear security guarantees.\n\nThe main mechanisms Tink uses to achieve these goals are as follows:\n\n1. Tink provides primitives and interfaces as important abstractions. These abstractions allow users to write code which does not specify the exact algorithm to be used, but instead specifies the expected security notion.\n2. Tink uses the notion of a \"keyset\", which is a set of keys that are associated with a particular primitive. This results in users writing code which works with multiple keys.\n3. In Tink, keys are not only specified by the underlying key material, but also the cryptographic algorithm, as well as all parameters. This means that a Tink key always selects a unique cryptographic function from all possible functions which can exist, and leaves no room for interpretation.\n\nThe following sections explain these concepts in more detail.\n\n### Cryptographic agility\n\nConsider [Software Engineering at Google](https://abseil.io/resources/swe-book),\na book about lessons learned in the field of software engineering, with the\nsubtitle \"lessons learned from programming over time\". In it, the authors go to\ngreat lengths to implore the implications of the fact that things change. This\nfact also impacted much of the design of Tink. In cryptography, it is important\nthat one prepares for change. Keys will leak, and algorithms will be broken.\nBeing able to switch out keys and algorithms is crucial for many users, and\nbeing prepared is prudent.\n\n### Security reviews and local properties\n\nTink promotes the use of interfaces, such as our AEAD interface, which allows\nusers to encrypt data. Among [other security guarantees](https://developers.google.com/tink/aead#security_guarantees), an AEAD\nguarantees that multiple encryptions of the same string result in different\nciphertexts.\n\nTo see how this can be used, suppose an engineer wants to store some sensitive\nID in a user cookie. They might provide a class such as this: \n\n class IdEncrypter {\n public static IdEncrypter createFromAead(Aead aead);\n\n public String encrypt(long id) throws GeneralSecurityException;\n public long decrypt(String encrypted) throws GeneralSecurityException;\n };\n\nPassing an `Aead` obtains the following properties:\n\n1. The code communicates that for `IdEncrypter` to do its job, it requires an encryption scheme with the security properties an [`Aead` provides](https://developers.google.com/tink/aead#security_guarantees). Alternatively, a [`DeterministicAead`](https://developers.google.com/tink/deterministic-aead) wouldn't be enough -- the `IdEncrypter` requires that two encryptions of the same id are different. On the other hand, taking as parameter an instance of an AES GCM encrypter (one particular instance of an `Aead`) would be overly strict: any Aead is enough for `IdEncrypter` to do its job, and it does not need to be one specific algorithm.\n2. A security review can take this point into account. A security reviewer does not need to go through all of the entire code repository to check if somewhere, someone made a subclass of `Aead` which is not secure for use with `IdEncrypter`. Instead, Tink provides security properties which all Aead objects have, and the reviewer can check that these are sufficient.\n\nIn particular the second point requires a lot of care. Users often ask to add\nalgorithms which are 'not quite' an `Aead`. The previous point illustrates why\nthis is dangerous: if there is any implementation of `Aead` available which does\nnot provide the required security guarantees, `IdEncrypter` can become insecure,\nand the engineer performing a security review needs to examine additional code\nto check that the object is instantiated correctly."]]