35

Tink:用于GCP、安卓和iOS的谷歌加密软件库

 5 years ago
source link: http://www.infoq.com/cn/news/2018/09/google-tink-cryto-ios-android?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Tink 是由一些谷歌加密工程师和安全工程师开发的一种多语言的、跨平台的加密软件库,意在帮助开发人员无需成为加密专家就可以正确地实现加密。经过最近两年的开发, 1.2版本中添加了对GCP、安卓和iOS平台以及C++和Objective-C的支持

Tink源自于另一个 谷歌的项目 。该项目意在加固加密软件库应对偏斜随机数(biased nonces)、无效曲线(invalid curves)等已知攻击,并确保DSA、RSA、AES-EAX等广为使用的加密算法给出正常的行为。基于该项目的经验,谷歌工程师着手创建了这个新的软件库,目标是提供易于正确使用并难以误用的安全API。例如,为防止出现可导致加密算法安全性降低的随机数重用问题,Tink不允许用户传递随机数。同时,Tink努力使其提供的每个API都有尽可能明确的安全保证。例如,如果一个特定的操作对 选择密文攻击(chosen-ciphertext attack) 是安全的,那么该保证会显示在接口上,并且实现该操作所用的每个原语都必须满足同一保证。

Tink当前提供四种 加密操作 。每种操作都是由特定的原语实现的:

  • 对相关联数据经认证的加密。(原语:AEAD)。
  • 消息认证代码(原语:MAC)。
  • 数字签名(原语:PublicKeySign和PublicKeyVerify)
  • 混合加密(原语:HybridEncrypt和HybridDecrypt)。

每个操作都有一组关联的最小属性,并具有一个保证。一个原语可以有多种实现,用户通过实例化 相应类型的密钥 选择具体使用的实现。例如,下面的代码使用 AEAD原语 实现AES-EAX加密文本:

import com.google.crypto.tink.Aead;
import com.google.crypto.tink.KeysetHandle;
import com.google.crypto.tink.aead.AeadFactory;
import com.google.crypto.tink.aead.AeadKeyTemplates;
// 1. 生成密钥。
KeysetHandle keysetHandle = KeysetHandle.generateNew(
  AeadKeyTemplates.AES256_EAX);
// 2. 获取原语。
Aead aead = AeadFactory.getPrimitive(keysetHandle);
// 3. 使用原语。
byte[] plaintext = ...;
byte[] additionalData = ...;
byte[] ciphertext = aead.encrypt(plaintext, additionalData);

除了加密操作,Tink还提供对密码管理的支持,包括密钥版本管理、密钥旋转,以及支持远程密钥管理系统(KMS,key management system)。当前,Tink支持下列KMS:

  • Google Cloud KMS。
  • Amazon KMS。
  • Android Keystore。
  • Apple iOS KeyChain(计划中)。

Tink当前支持Java、C++和Objective-C。 意向于2018年12月发布的1.3版本 将提供对C#、Go和JavaScript/Node的支持。

尽管Tink并非受谷歌官方支持的产品,但是它已经用于一些谷歌产品,其中包括AdMob、Google Pay、Google Assistant、Firebase和Search API等。

查看英文原文: Tink is Google Cryptographic Library for the Cloud, Android, and iOS


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK