use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method rsaSsaPkcs1_4096.
@Test
public void rsaSsaPkcs1_4096() throws Exception {
KeyTemplate template = SignatureKeyTemplates.RSA_SSA_PKCS1_4096_SHA512_F4;
assertEquals(new RsaSsaPkcs1SignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertTrue(format.hasParams());
assertEquals(HashType.SHA512, format.getParams().getHashType());
assertEquals(4096, format.getModulusSizeInBits());
assertEquals(BigInteger.valueOf(65537), new BigInteger(1, format.getPublicExponent().toByteArray()));
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method createEcdsaKeyTemplate.
@Test
public void createEcdsaKeyTemplate() 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.UNKNOWN_CURVE;
EcdsaSignatureEncoding encoding = EcdsaSignatureEncoding.IEEE_P1363;
OutputPrefixType prefixType = OutputPrefixType.TINK;
KeyTemplate template = SignatureKeyTemplates.createEcdsaKeyTemplate(hashType, curve, encoding, prefixType);
assertEquals(new EcdsaSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
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 SignatureKeyTemplatesTest method ed25519WithRawOutput.
@Test
public void ed25519WithRawOutput() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ED25519WithRawOutput;
assertEquals(new Ed25519PrivateKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
// Empty format.
assertTrue(template.getValue().isEmpty());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method ecdsaP384Ieee.
@Test
public void ecdsaP384Ieee() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P384_IEEE_P1363;
assertEquals(new EcdsaSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertTrue(format.hasParams());
assertEquals(HashType.SHA512, format.getParams().getHashType());
assertEquals(EllipticCurveType.NIST_P384, format.getParams().getCurve());
assertEquals(EcdsaSignatureEncoding.IEEE_P1363, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class StreamingAeadKeyTemplatesTest method testAes128CtrHmacSha256_4KB.
@Test
public void testAes128CtrHmacSha256_4KB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES128_CTR_HMAC_SHA256_4KB;
assertEquals(new AesCtrHmacStreamingKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.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());
assertEquals(HashType.SHA256, format.getParams().getHmacParams().getHash());
assertEquals(32, format.getParams().getHmacParams().getTagSize());
}
Aggregations