use of com.google.crypto.tink.proto.KmsEnvelopeAeadKeyFormat in project tink by google.
the class AeadKeyTemplatesTest method testCreateKmsEnvelopeAeadKeyTemplate.
@Test
public void testCreateKmsEnvelopeAeadKeyTemplate() throws Exception {
// Intentionally using "weird" or invalid values for parameters,
// to test that the function correctly puts them in the resulting template.
String kekUri = "some example KEK URI";
KeyTemplate dekTemplate = AeadKeyTemplates.AES256_GCM;
KeyTemplate template = AeadKeyTemplates.createKmsEnvelopeAeadKeyTemplate(kekUri, dekTemplate);
assertEquals(new KmsEnvelopeAeadKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
KmsEnvelopeAeadKeyFormat format = KmsEnvelopeAeadKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(kekUri, format.getKekUri());
assertEquals(dekTemplate.toString(), format.getDekTemplate().toString());
}
use of com.google.crypto.tink.proto.KmsEnvelopeAeadKeyFormat in project tink by google.
the class AeadKeyTemplatesTest method testCreateKmsEnvelopeAeadKeyFormat.
@Test
public void testCreateKmsEnvelopeAeadKeyFormat() throws Exception {
// Intentionally using "weird" or invalid values for parameters,
// to test that the function correctly puts them in the resulting template.
String kekUri = "some example KEK URI";
KeyTemplate dekTemplate = AeadKeyTemplates.AES256_GCM;
KeyTemplate template = AeadKeyTemplates.createKmsEnvelopeAeadKeyTemplate(kekUri, dekTemplate);
assertEquals(KmsEnvelopeAeadKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
KmsEnvelopeAeadKeyFormat format = KmsEnvelopeAeadKeyFormat.parseFrom(template.getValue());
assertEquals(kekUri, format.getKekUri());
assertEquals(dekTemplate.toString(), format.getDekTemplate().toString());
}
use of com.google.crypto.tink.proto.KmsEnvelopeAeadKeyFormat in project tink by google.
the class KmsEnvelopeAeadKeyManagerTest method createKeyTemplate.
@Test
public void createKeyTemplate() throws Exception {
// Intentionally using "weird" or invalid values for parameters,
// to test that the function correctly puts them in the resulting template.
String kekUri = "some example KEK URI";
KeyTemplate dekTemplate = AesCtrHmacAeadKeyManager.aes128CtrHmacSha256Template();
KeyTemplate template = KmsEnvelopeAeadKeyManager.createKeyTemplate(kekUri, dekTemplate);
assertThat(new KmsEnvelopeAeadKeyManager().getKeyType()).isEqualTo(template.getTypeUrl());
assertThat(KeyTemplate.OutputPrefixType.RAW).isEqualTo(template.getOutputPrefixType());
KmsEnvelopeAeadKeyFormat format = KmsEnvelopeAeadKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(kekUri).isEqualTo(format.getKekUri());
assertThat(dekTemplate.getTypeUrl()).isEqualTo(format.getDekTemplate().getTypeUrl());
assertThat(dekTemplate.getValue()).isEqualTo(format.getDekTemplate().getValue().toByteArray());
}
Aggregations