use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesEaxKeyManagerTest method testAes256EaxTemplate.
@Test
public void testAes256EaxTemplate() throws Exception {
KeyTemplate template = AesEaxKeyManager.aes256EaxTemplate();
assertEquals(new AesEaxKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(KeyTemplate.OutputPrefixType.TINK, template.getOutputPrefixType());
AesEaxKeyFormat format = AesEaxKeyFormat.parseFrom(ByteString.copyFrom(template.getValue()), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(32, format.getKeySize());
assertTrue(format.hasParams());
assertEquals(16, format.getParams().getIvSize());
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesGcmSivKeyManagerTest method testRawAes128GcmSivTemplate.
@Test
public void testRawAes128GcmSivTemplate() throws Exception {
KeyTemplate template = AesGcmSivKeyManager.rawAes128GcmSivTemplate();
assertEquals(new AesGcmSivKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(KeyTemplate.OutputPrefixType.RAW, template.getOutputPrefixType());
AesGcmSivKeyFormat format = AesGcmSivKeyFormat.parseFrom(ByteString.copyFrom(template.getValue()), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(16, format.getKeySize());
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesGcmSivKeyManagerTest method testRawAes256GcmSivTemplate.
@Test
public void testRawAes256GcmSivTemplate() throws Exception {
KeyTemplate template = AesGcmSivKeyManager.rawAes256GcmSivTemplate();
assertEquals(new AesGcmSivKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(KeyTemplate.OutputPrefixType.RAW, template.getOutputPrefixType());
AesGcmSivKeyFormat format = AesGcmSivKeyFormat.parseFrom(ByteString.copyFrom(template.getValue()), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(32, format.getKeySize());
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method testRawRsa4096SsaPkcs1Sha512F4Template.
@Test
public void testRawRsa4096SsaPkcs1Sha512F4Template() throws Exception {
KeyTemplate template = RsaSsaPkcs1SignKeyManager.rawRsa4096SsaPkcs1Sha512F4Template();
assertThat(template.getTypeUrl()).isEqualTo(new RsaSsaPkcs1SignKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.hasParams()).isTrue();
assertThat(format.getParams().getHashType()).isEqualTo(HashType.SHA512);
assertThat(format.getModulusSizeInBits()).isEqualTo(4096);
assertThat(new BigInteger(1, format.getPublicExponent().toByteArray())).isEqualTo(BigInteger.valueOf(65537));
}
use of com.google.crypto.tink.KeyTemplate in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method testAes256CtrHmacSha2561MBTemplate.
@Test
public void testAes256CtrHmacSha2561MBTemplate() throws Exception {
KeyTemplate template = AesCtrHmacStreamingKeyManager.aes256CtrHmacSha2561MBTemplate();
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(1 << 20);
}
Aggregations