מה זה Tink?
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Tink היא ספריית קריפטוגרפיה בקוד פתוח שנכתבה על ידי קריפטוגרפיה
מהנדסי אבטחה ב-Google. ממשקי ה-API המאובטחים והפשוטים של Tink מפחיתים את הסיכון
המלכודות בעיצוב שמתמקד במשתמש, הטמעה קפדנית ובדיקות קוד,
ובדיקות מקיפות. בקטע יעדים בדף הזה מוסבר איך
לקבל יותר תובנות על המטרות שטינק נועד למלא.
Tink עוזר למשתמשים ללא רקע קריפטוגרפי להטמיע באופן בטוח
למשימות קריפטוגרפיות. ב-Google, שירות Tink נפרס במאות מוצרים
ומערכות.
למה כדאי להשתמש ב-Tink?
הסיבות החשובות ביותר לשימוש ב-Tink הן:
קל לשימוש
קשה להגדיר את הקריפטוגרפיה בצורה נכונה. עם Tink, אפשר
להצפין או לחתום על הנתונים באמצעות
אבטחה מובנית באמצעות כמה שורות קוד בלבד. Tink יכול גם
לעזור לך לבצע רוטציה של מפתחות או מפתחות מאובטחים באמצעות מערכות חיצוניות לניהול מפתחות
(KMS).
זה מאובטח
ב-Tink מוסיפים אמצעי אבטחה לספריות מוכרות כמו BoringSSL.
וארכיטקטורת קריפטוגרפיה של Java ומציגה אותם ישירות בממשקים,
כדי שהבודקים והכלים יוכלו לאתר פערים במהירות. Tink מפריד גם בין ממשקי API
שעלולים להיות מסוכנים, לכן תוכלו לעקוב אחריהם.
האפליקציה תואמת
טקסטים מוצפנים (ciphertext) של Tink תואמים לספריות הקריפטוגרפיה הקיימות. טינק
תומכת גם בהצפנה או אחסון של מפתחות
Amazon KMS, Google Cloud KMS, Android Keystore ו-iOS Keychain.
מי משתמש ב-Tink?
חברות רבות, כולל Google, Square ו-Citadel, נמצאות בשימוש נרחב ב-Tink,
וגם מאות לקוחות של Google Cloud ושותפים של Google Pay. טינק גם
שמפעיל את ספריית האבטחה של Jetpack, שמאבטחת הרבה אפליקציות פופולריות ל-Android
כמו Slack, Adidas, AirBnb ו-Nextdoor.
מטרות עסקיות קטנות
מהן המטרות העיקריות של Tink בהשוואה לספריות קריפטוגרפיות אחרות, וגם
מהם המנגנונים העיקריים ש-Tink משתמש בהם כדי להשיג את היעדים האלה?
בקיצור, ל-Tink יש שני יעדים:
- קידום גמישות קריפטוגרפית: המשתמשים צריכים להיות מסוגלים לשנות מפתחות
בצורה פשוטה.
- הפעלת בדיקות אבטחה: מטרת Tink היא לאפשר למשתמשים לכתוב קוד
ניתן לבדוק באופן מקומי את האבטחה, באמצעות ממשקים שמספקים
ואחריות אבטחה.
אלה המנגנונים העיקריים ש-Tink משתמש בהם כדי להשיג את היעדים האלה:
- Tink מספק פרימיטיביים וממשקים כהפשטות חשובות. האלה
הפשטה של נתונים מאפשרת למשתמשים לכתוב קוד שלא מציין
שיש להשתמש בו, אך במקום זאת מציין את תפיסת האבטחה הצפויה.
- Tink משתמש במושג 'קבוצת מפתחות', שהיא קבוצה של מפתחות
שמשויכים לפרימיטיבי מסוים. התוצאה היא שמשתמשים כותבים קוד
שפועל עם כמה מפתחות.
- ב-Tink, המפתחות לא מצוינים רק על ידי חומר המפתח הבסיסי, אלא
גם את האלגוריתם הקריפטוגרפי וגם את כל הפרמטרים. המשמעות היא
מפתח Tink תמיד בוחר פונקציה קריפטוגרפית ייחודית מכל אפשרות
יכולות להתקיים ולא משאירות מקום לפרשנות.
בחלקים הבאים נסביר את העקרונות האלה בפירוט.
גמישות קריפטוגרפית
כדאי לשקול את הנדסת תוכנה ב-Google,
ספר על שיעורים שנלמדו בתחום הנדסת התוכנה,
כתובית "שיעורים שנלמדו מהתכנות עם הזמן". בו, המחברים
מאמצים רבים כדי לשקף את ההשלכות של העובדה שדברים משתנים. הזה
גם השפיעו על חלק גדול מהעיצוב של Tink. בתחום הקריפטוגרפיה חשוב
שמתכוננים לשינוי. המפתחות ידלפו והאלגוריתמים ייכשלו.
היכולת להוציא מפתחות ואלגוריתמים חיונית למשתמשים רבים.
להיות מושכלים.
ביקורות אבטחה ונכסים מקומיים
Tink מקדם את השימוש בממשקים, כמו ממשק AEAD שלנו, שמאפשר
למשתמשים להצפין את הנתונים. בין אחריות אבטחה אחרת, מסמך AEAD
מבטיח שכמה הצפנות של אותה מחרוזת מובילות
מידע מוצפן (ciphertexts).
כדי לראות כיצד ניתן להשתמש בזה, נניח שמהנדס רוצה לאחסן נתונים
המזהה בקובץ Cookie של משתמש. הם עשויים להציג מחלקה כמו זו:
class IdEncrypter {
public static IdEncrypter createFromAead(Aead aead);
public String encrypt(long id) throws GeneralSecurityException;
public long decrypt(String encrypted) throws GeneralSecurityException;
};
העברת Aead
מקבלת את המאפיינים הבאים:
- הקוד מצהיר שכדי ש-
IdEncrypter
יבצע את פעולתו, הוא דורש
של סכמת ההצפנה עם מאפייני האבטחה שAead
מספק.
לחלופין,
DeterministicAead
לא מספיק – לפי הדרישות של IdEncrypter
, שתי הצפנה יש
שונים. לעומת זאת, לקחת כפרמטר כמופע של
הצפנת AES GCM (מופע ספציפי של Aead
) יהיה יותר מדי
מחמיר: כל Aead מספיק כדי IdEncrypter
לבצע את העבודה,
צריכים להיות אלגוריתם אחד ספציפי.
- בדיקת האבטחה יכולה להביא בחשבון את הנקודה הזו. בודק אבטחה עושה
לא צריך לעבור על כל מאגר הקודים כדי לבדוק
במקום כלשהו, מישהו יצר מחלקה משנית של
Aead
שאינה מאובטחת לשימוש
עם IdEncrypter
. במקום זאת, Tink מספק מאפייני אבטחה
לאובייקטים של Aead יש, והבודק יכול לבדוק שהם מספיקים.
באופן ספציפי, הנקודה השנייה מחייבת תשומת לב רבה. לעיתים קרובות משתמשים מבקשים להוסיף
אלגוריתמים Aead
. הנקודה הקודמת ממחישה למה
זה מסוכן: אם יש הטמעה זמינה של Aead
שעושה
לא יספק את התחייבויות האבטחה הנדרשות, IdEncrypter
עלול להפוך לבלתי מאובטח,
והמהנדס שמבצע בדיקת אבטחה צריך לבחון קוד נוסף
כדי לבדוק שהאובייקט נוצר (instantiation) בצורה נכונה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 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."]]