use of com.google.crypto.tink.proto.AesGcmHkdfStreamingKeyFormat in project tink by google.
the class StreamingAeadKeyTemplatesTest method testAes128GcmHkdf_4KB.
@Test
public void testAes128GcmHkdf_4KB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES128_GCM_HKDF_4KB;
assertEquals(new AesGcmHkdfStreamingKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesGcmHkdfStreamingKeyFormat format = AesGcmHkdfStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(16, format.getKeySize());
assertEquals(16, format.getParams().getDerivedKeySize());
assertEquals(HashType.SHA256, format.getParams().getHkdfHashType());
assertEquals(4096, format.getParams().getCiphertextSegmentSize());
}
use of com.google.crypto.tink.proto.AesGcmHkdfStreamingKeyFormat in project tink by google.
the class StreamingAeadKeyTemplates method createAesGcmHkdfStreamingKeyTemplate.
/**
* @return a {@code KeyTemplate} containing a {@code AesGcmHkdfStreamingKeyFormat}
* with some specified parameters.
*/
public static KeyTemplate createAesGcmHkdfStreamingKeyTemplate(int mainKeySize, HashType hkdfHashType, int derivedKeySize, int ciphertextSegmentSize) {
AesGcmHkdfStreamingParams keyParams = AesGcmHkdfStreamingParams.newBuilder().setCiphertextSegmentSize(ciphertextSegmentSize).setDerivedKeySize(derivedKeySize).setHkdfHashType(hkdfHashType).build();
AesGcmHkdfStreamingKeyFormat format = AesGcmHkdfStreamingKeyFormat.newBuilder().setKeySize(mainKeySize).setParams(keyParams).build();
return KeyTemplate.newBuilder().setValue(format.toByteString()).setTypeUrl(new AesGcmHkdfStreamingKeyManager().getKeyType()).setOutputPrefixType(OutputPrefixType.RAW).build();
}
Aggregations