use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class HmacPrfKeyManagerTest method testHmacSha256Template.
@Test
public void testHmacSha256Template() throws Exception {
KeyTemplate template = HmacPrfKeyManager.hmacSha256Template();
assertThat(template.getTypeUrl()).isEqualTo(new HmacPrfKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
HmacPrfKeyFormat format = HmacPrfKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getKeySize()).isEqualTo(32);
assertThat(format.getParams().getHash()).isEqualTo(HashType.SHA256);
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method testAes128CtrHmacSha2564KBTemplate.
@Test
public void testAes128CtrHmacSha2564KBTemplate() throws Exception {
KeyTemplate template = AesCtrHmacStreamingKeyManager.aes128CtrHmacSha2564KBTemplate();
assertThat(template.getTypeUrl()).isEqualTo(new AesCtrHmacStreamingKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getKeySize()).isEqualTo(16);
assertThat(format.getParams().getDerivedKeySize()).isEqualTo(16);
assertThat(format.getParams().getHkdfHashType()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getHash()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getTagSize()).isEqualTo(32);
assertThat(format.getParams().getCiphertextSegmentSize()).isEqualTo(4096);
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method testAes256CtrHmacSha2564KBTemplate.
@Test
public void testAes256CtrHmacSha2564KBTemplate() throws Exception {
KeyTemplate template = AesCtrHmacStreamingKeyManager.aes256CtrHmacSha2564KBTemplate();
assertThat(template.getTypeUrl()).isEqualTo(new AesCtrHmacStreamingKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getKeySize()).isEqualTo(32);
assertThat(format.getParams().getDerivedKeySize()).isEqualTo(32);
assertThat(format.getParams().getHkdfHashType()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getHash()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getTagSize()).isEqualTo(32);
assertThat(format.getParams().getCiphertextSegmentSize()).isEqualTo(4096);
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method testAes128CtrHmacSha2561MBTemplate.
@Test
public void testAes128CtrHmacSha2561MBTemplate() throws Exception {
KeyTemplate template = AesCtrHmacStreamingKeyManager.aes128CtrHmacSha2561MBTemplate();
assertThat(template.getTypeUrl()).isEqualTo(new AesCtrHmacStreamingKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getKeySize()).isEqualTo(16);
assertThat(format.getParams().getDerivedKeySize()).isEqualTo(16);
assertThat(format.getParams().getHkdfHashType()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getHash()).isEqualTo(HashType.SHA256);
assertThat(format.getParams().getHmacParams().getTagSize()).isEqualTo(32);
assertThat(format.getParams().getCiphertextSegmentSize()).isEqualTo(1 << 20);
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class HkdfPrfKeyManagerTest method testHkdfSha256Template.
@Test
public void testHkdfSha256Template() throws Exception {
KeyTemplate kt = HkdfPrfKeyManager.hkdfSha256Template();
assertThat(kt.getTypeUrl()).isEqualTo(new HkdfPrfKeyManager().getKeyType());
assertThat(kt.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
HkdfPrfKeyFormat format = HkdfPrfKeyFormat.parseFrom(kt.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getKeySize()).isEqualTo(32);
assertThat(format.getParams().getHash()).isEqualTo(HashType.SHA256);
}
Aggregations