Search in sources :

Example 1 with AesCmacKeyFormat

use of com.google.crypto.tink.proto.AesCmacKeyFormat in project tink by google.

the class AesCmacKeyManagerTest method createKey_multipleTimes.

@Test
public void createKey_multipleTimes() throws Exception {
    AesCmacKeyManager manager = new AesCmacKeyManager();
    AesCmacKeyFormat keyFormat = makeAesCmacKeyFormat(32, 16);
    assertThat(manager.keyFactory().createKey(keyFormat).getKeyValue()).isNotEqualTo(manager.keyFactory().createKey(keyFormat).getKeyValue());
}
Also used : AesCmacKeyFormat(com.google.crypto.tink.proto.AesCmacKeyFormat) Test(org.junit.Test)

Example 2 with AesCmacKeyFormat

use of com.google.crypto.tink.proto.AesCmacKeyFormat in project tink by google.

the class AesCmacKeyManagerTest method testRawAes256CmacTemplate.

@Test
public void testRawAes256CmacTemplate() throws Exception {
    KeyTemplate template = AesCmacKeyManager.rawAes256CmacTemplate();
    assertThat(template.getTypeUrl()).isEqualTo(new AesCmacKeyManager().getKeyType());
    assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
    AesCmacKeyFormat format = AesCmacKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
    assertThat(format.getKeySize()).isEqualTo(32);
    assertThat(format.getParams().getTagSize()).isEqualTo(16);
}
Also used : AesCmacKeyFormat(com.google.crypto.tink.proto.AesCmacKeyFormat) KeyTemplate(com.google.crypto.tink.KeyTemplate) Test(org.junit.Test)

Example 3 with AesCmacKeyFormat

use of com.google.crypto.tink.proto.AesCmacKeyFormat in project tink by google.

the class AesCmacKeyManagerTest method createKey_checkValues.

@Test
public void createKey_checkValues() throws Exception {
    AesCmacKeyFormat keyFormat = makeAesCmacKeyFormat(32, 16);
    AesCmacKey key = new AesCmacKeyManager().keyFactory().createKey(keyFormat);
    assertThat(key.getKeyValue()).hasSize(keyFormat.getKeySize());
    assertThat(key.getParams().getTagSize()).isEqualTo(keyFormat.getParams().getTagSize());
}
Also used : AesCmacKey(com.google.crypto.tink.proto.AesCmacKey) AesCmacKeyFormat(com.google.crypto.tink.proto.AesCmacKeyFormat) Test(org.junit.Test)

Example 4 with AesCmacKeyFormat

use of com.google.crypto.tink.proto.AesCmacKeyFormat in project tink by google.

the class AesCmacKeyManagerTest method testAes256CmacTemplate.

@Test
public void testAes256CmacTemplate() throws Exception {
    KeyTemplate template = AesCmacKeyManager.aes256CmacTemplate();
    assertThat(template.getTypeUrl()).isEqualTo(new AesCmacKeyManager().getKeyType());
    assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.TINK);
    AesCmacKeyFormat format = AesCmacKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
    assertThat(format.getKeySize()).isEqualTo(32);
    assertThat(format.getParams().getTagSize()).isEqualTo(16);
}
Also used : AesCmacKeyFormat(com.google.crypto.tink.proto.AesCmacKeyFormat) KeyTemplate(com.google.crypto.tink.KeyTemplate) Test(org.junit.Test)

Aggregations

AesCmacKeyFormat (com.google.crypto.tink.proto.AesCmacKeyFormat)4 Test (org.junit.Test)4 KeyTemplate (com.google.crypto.tink.KeyTemplate)2 AesCmacKey (com.google.crypto.tink.proto.AesCmacKey)1