use of com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat 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);
}
use of com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method validateKeyFormat_tagSizeTooBigSha512_throws.
@Test
public void validateKeyFormat_tagSizeTooBigSha512_throws() throws Exception {
AesCtrHmacStreamingKeyFormat format = createKeyFormat().setParams(createParams().setHmacParams(createHmacParams().setHash(HashType.SHA512).setTagSize(65))).build();
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
use of com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method testSkip.
@Test
public void testSkip() throws Exception {
AesCtrHmacStreamingKeyFormat format = createKeyFormat().build();
AesCtrHmacStreamingKey key = factory.createKey(format);
StreamingAead streamingAead = manager.getPrimitive(key, StreamingAead.class);
int offset = 0;
int plaintextSize = 1 << 16;
// Runs the test with different sizes for the chunks to skip.
StreamingTestUtil.testSkipWithStream(streamingAead, offset, plaintextSize, 1);
StreamingTestUtil.testSkipWithStream(streamingAead, offset, plaintextSize, 64);
StreamingTestUtil.testSkipWithStream(streamingAead, offset, plaintextSize, 300);
}
use of com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method validateKeyFormat_smallSegment_throws.
@Test
public void validateKeyFormat_smallSegment_throws() throws Exception {
AesCtrHmacStreamingKeyFormat format = createKeyFormat().setParams(createParams().setCiphertextSegmentSize(45)).build();
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
use of com.google.crypto.tink.proto.AesCtrHmacStreamingKeyFormat in project tink by google.
the class AesCtrHmacStreamingKeyManagerTest method validateKeyFormat_tagSizeTooBigSha256_throws.
@Test
public void validateKeyFormat_tagSizeTooBigSha256_throws() throws Exception {
AesCtrHmacStreamingKeyFormat format = createKeyFormat().setParams(createParams().setHmacParams(createHmacParams().setHash(HashType.SHA256).setTagSize(33))).build();
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
Aggregations