use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class KeyHandleTest method getKeyTemplate.
@Test
public void getKeyTemplate() throws Exception {
KeyTemplate keyTemplate = KeyTemplates.get("ED25519_RAW");
TinkKey key = new DummyTinkKey(/* hasSecret= */
false, keyTemplate);
KeyHandle keyHandle = KeyHandle.createFromKey(key, KeyAccess.publicAccess());
KeyTemplate returnedKeyTemplate = keyHandle.getKeyTemplate();
assertThat(returnedKeyTemplate.getValue()).isEqualTo(keyTemplate.getValue());
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class KeyHandleTest method createFromKey_keyDataSymmetric_shouldHaveSecret.
@Test
public void createFromKey_keyDataSymmetric_shouldHaveSecret() throws Exception {
KeyTemplate kt = KeyTemplates.get("AES128_EAX");
KeyData kd = Registry.newKeyData(kt);
KeyHandle kh = KeyHandle.createFromKey(kd, kt.getOutputPrefixType());
assertThat(kh.hasSecret()).isTrue();
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class ProtoKeyTest method testProtoKey_keyDataSYMMETRIC_shouldHaveSecret.
@Test
public void testProtoKey_keyDataSYMMETRIC_shouldHaveSecret() throws GeneralSecurityException {
KeyTemplate kt = KeyTemplates.get("AES128_EAX");
KeyData kd = Registry.newKeyData(kt);
ProtoKey pk = new ProtoKey(kd, kt.getOutputPrefixType());
assertThat(pk.getProtoKey()).isEqualTo(kd);
assertThat(pk.getOutputPrefixType()).isEqualTo(kt.getOutputPrefixType());
assertThat(pk.hasSecret()).isTrue();
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class ProtoKeyTest method testGetKeyTemplate_shouldThrow.
@Test
public void testGetKeyTemplate_shouldThrow() throws GeneralSecurityException {
KeyTemplate kt = AesEaxKeyManager.aes128EaxTemplate();
KeyData kd = Registry.newKeyData(kt);
ProtoKey pk = new ProtoKey(kd, kt.getOutputPrefixType());
assertThrows(UnsupportedOperationException.class, pk::getKeyTemplate);
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class ProtoKeyTest method testProtoKey_keyDataASYMMETRICPUBLIC_shouldNotHaveSecret.
@Test
public void testProtoKey_keyDataASYMMETRICPUBLIC_shouldNotHaveSecret() throws GeneralSecurityException {
KeyTemplate kt = KeyTemplates.get("ED25519");
KeyData kd = Registry.getPublicKeyData(kt.getTypeUrl(), Registry.newKeyData(kt).getValue());
ProtoKey pk = new ProtoKey(kd, kt.getOutputPrefixType());
assertThat(pk.getProtoKey()).isEqualTo(kd);
assertThat(pk.getOutputPrefixType()).isEqualTo(kt.getOutputPrefixType());
assertThat(pk.hasSecret()).isFalse();
}
Aggregations