use of com.google.crypto.tink.proto.KeyData in project tink by google.
the class KeyHandleTest method createFromKey_keyDataRemote_shouldNotHaveSecret.
@Test
public void createFromKey_keyDataRemote_shouldNotHaveSecret() throws Exception {
KeyTemplate kt = KeyTemplates.get("ED25519");
KeyData kd = KeyData.newBuilder().mergeFrom(Registry.newKeyData(kt)).setKeyMaterialType(KeyData.KeyMaterialType.REMOTE).build();
KeyHandle kh = KeyHandle.createFromKey(kd, kt.getOutputPrefixType());
assertThat(kh.hasSecret()).isFalse();
}
use of com.google.crypto.tink.proto.KeyData in project tink by google.
the class KeyHandleTest method generateNew_compareWith_createFromKeyViaProtoKey_shouldBeEqual.
@Test
public void generateNew_compareWith_createFromKeyViaProtoKey_shouldBeEqual() throws Exception {
KeyTemplate template = KeyTemplates.get("AES128_EAX");
KeyData keyData = Registry.newKeyData(template);
ProtoKey protoKey = new ProtoKey(keyData, template.getOutputPrefixType());
KeyHandle handle1 = KeyHandle.generateNew(template);
KeyHandle handle2 = KeyHandle.createFromKey(protoKey, SecretKeyAccess.insecureSecretAccess());
expect.that(handle1.getStatus()).isEqualTo(handle2.getStatus());
ProtoKey outputProtoKey1 = (ProtoKey) handle1.getKey(SecretKeyAccess.insecureSecretAccess());
ProtoKey outputProtoKey2 = (ProtoKey) handle2.getKey(SecretKeyAccess.insecureSecretAccess());
expect.that(outputProtoKey1.getOutputPrefixType()).isEqualTo(outputProtoKey2.getOutputPrefixType());
expect.that(handle1.hasSecret()).isEqualTo(handle2.hasSecret());
}
use of com.google.crypto.tink.proto.KeyData in project tink by google.
the class ProtoKeyTest method testProtoKey_keyDataUNKNOWN_shouldHaveSecret.
@Test
public void testProtoKey_keyDataUNKNOWN_shouldHaveSecret() throws GeneralSecurityException {
KeyTemplate kt = KeyTemplates.get("ED25519");
KeyData kd = KeyData.newBuilder().mergeFrom(Registry.newKeyData(kt)).setKeyMaterialType(KeyData.KeyMaterialType.UNKNOWN_KEYMATERIAL).build();
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.proto.KeyData in project tink by google.
the class ProtoKeyTest method testProtoKey_keyDataREMOTE_shouldNotHaveSecret.
@Test
public void testProtoKey_keyDataREMOTE_shouldNotHaveSecret() throws GeneralSecurityException {
KeyTemplate kt = KeyTemplates.get("ED25519");
KeyData kd = KeyData.newBuilder().mergeFrom(Registry.newKeyData(kt)).setKeyMaterialType(KeyData.KeyMaterialType.REMOTE).build();
ProtoKey pk = new ProtoKey(kd, kt.getOutputPrefixType());
assertThat(pk.getProtoKey()).isEqualTo(kd);
assertThat(pk.getOutputPrefixType()).isEqualTo(kt.getOutputPrefixType());
assertThat(pk.hasSecret()).isFalse();
}
use of com.google.crypto.tink.proto.KeyData in project tink by google.
the class ProtoKeyTest method testProtoKey_keyDataASYMMETRICPRIVATE_shouldHaveSecret.
@Test
public void testProtoKey_keyDataASYMMETRICPRIVATE_shouldHaveSecret() throws GeneralSecurityException {
KeyTemplate kt = KeyTemplates.get("ED25519");
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();
}
Aggregations