use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method testCreateEcdsaKeyTemplate.
@Test
public void testCreateEcdsaKeyTemplate() throws Exception {
// Intentionally using "weird" or invalid values for parameters,
// to test that the function correctly puts them in the resulting template.
HashType hashType = HashType.SHA512;
EllipticCurveType curve = EllipticCurveType.NIST_P224;
EcdsaSignatureEncoding encoding = EcdsaSignatureEncoding.IEEE_P1363;
KeyTemplate template = SignatureKeyTemplates.createEcdsaKeyTemplate(hashType, curve, encoding);
assertEquals(EcdsaSignKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue());
assertEquals(hashType, format.getParams().getHashType());
assertEquals(curve, format.getParams().getCurve());
assertEquals(encoding, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class StreamingAeadKeyTemplatesTest method testAES128_CTR_HMAC_SHA256_4KB.
@Test
public void testAES128_CTR_HMAC_SHA256_4KB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES128_CTR_HMAC_SHA256_4KB;
assertEquals(AesCtrHmacStreamingKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.parseFrom(template.getValue());
assertEquals(16, format.getKeySize());
assertEquals(16, format.getParams().getDerivedKeySize());
assertEquals(HashType.SHA256, format.getParams().getHkdfHashType());
assertEquals(4096, format.getParams().getCiphertextSegmentSize());
assertEquals(HashType.SHA256, format.getParams().getHmacParams().getHash());
assertEquals(32, format.getParams().getHmacParams().getTagSize());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method testECDSA_P384.
@Test
public void testECDSA_P384() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P384;
assertEquals(EcdsaSignKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue());
assertTrue(format.hasParams());
assertEquals(HashType.SHA512, format.getParams().getHashType());
assertEquals(EllipticCurveType.NIST_P384, format.getParams().getCurve());
assertEquals(EcdsaSignatureEncoding.DER, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method testECDSA_P521.
@Test
public void testECDSA_P521() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P521;
assertEquals(EcdsaSignKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue());
assertTrue(format.hasParams());
assertEquals(HashType.SHA512, format.getParams().getHashType());
assertEquals(EllipticCurveType.NIST_P521, format.getParams().getCurve());
assertEquals(EcdsaSignatureEncoding.DER, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class StreamingAeadKeyTemplatesTest method testAES128_GCM_HKDF_4KB.
@Test
public void testAES128_GCM_HKDF_4KB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES128_GCM_HKDF_4KB;
assertEquals(AesGcmHkdfStreamingKeyManager.TYPE_URL, template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesGcmHkdfStreamingKeyFormat format = AesGcmHkdfStreamingKeyFormat.parseFrom(template.getValue());
assertEquals(16, format.getKeySize());
assertEquals(16, format.getParams().getDerivedKeySize());
assertEquals(HashType.SHA256, format.getParams().getHkdfHashType());
assertEquals(4096, format.getParams().getCiphertextSegmentSize());
}
Aggregations