Search in sources :

Example 11 with ProtoKey

use of com.google.crypto.tink.tinkkey.internal.ProtoKey in project tink by google.

the class KeysetHandleTest method primaryKey_shouldWork.

@Test
public void primaryKey_shouldWork() throws Exception {
    KeyTemplate kt1 = KeyTemplates.get("AES128_EAX");
    KeyTemplate kt2 = KeyTemplates.get("HMAC_SHA256_256BITTAG");
    KeysetHandle ksh = KeysetManager.withKeysetHandle(KeysetHandle.generateNew(kt1)).add(kt2).getKeysetHandle();
    KeyHandle kh = ksh.primaryKey();
    ProtoKey pk = (ProtoKey) kh.getKey(SecretKeyAccess.insecureSecretAccess());
    assertThat(pk.getProtoKey().getTypeUrl()).isEqualTo(kt1.getTypeUrl());
}
Also used : ProtoKey(com.google.crypto.tink.tinkkey.internal.ProtoKey) KeyHandle(com.google.crypto.tink.tinkkey.KeyHandle) Test(org.junit.Test)

Aggregations

ProtoKey (com.google.crypto.tink.tinkkey.internal.ProtoKey)11 Test (org.junit.Test)7 KeyData (com.google.crypto.tink.proto.KeyData)6 KeyHandle (com.google.crypto.tink.tinkkey.KeyHandle)5 KeyTemplate (com.google.crypto.tink.KeyTemplate)3 AesEaxKey (com.google.crypto.tink.proto.AesEaxKey)3 Keyset (com.google.crypto.tink.proto.Keyset)3 AesEaxKeyFormat (com.google.crypto.tink.proto.AesEaxKeyFormat)2 KeyAccess (com.google.crypto.tink.tinkkey.KeyAccess)2 SecretKeyAccess (com.google.crypto.tink.tinkkey.SecretKeyAccess)2 ByteString (com.google.protobuf.ByteString)2 GeneralSecurityException (java.security.GeneralSecurityException)2 TreeSet (java.util.TreeSet)2 Expect (com.google.common.truth.Expect)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 KeysetManager (com.google.crypto.tink.KeysetManager)1 AesEaxKeyManager (com.google.crypto.tink.aead.AesEaxKeyManager)1 TinkConfig (com.google.crypto.tink.config.TinkConfig)1 KeyStatusTypeProtoConverter (com.google.crypto.tink.internal.KeyStatusTypeProtoConverter)1 AesGcmKey (com.google.crypto.tink.proto.AesGcmKey)1