use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method rsaSsaPkcs1_3072.
@Test
public void rsaSsaPkcs1_3072() throws Exception {
KeyTemplate template = SignatureKeyTemplates.RSA_SSA_PKCS1_3072_SHA256_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.SHA256, format.getParams().getHashType());
assertEquals(3072, 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 ecdsaP256IeeeWithoutPrefix.
@Test
public void ecdsaP256IeeeWithoutPrefix() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P256_IEEE_P1363_WITHOUT_PREFIX;
assertEquals(new EcdsaSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertTrue(format.hasParams());
assertEquals(HashType.SHA256, format.getParams().getHashType());
assertEquals(EllipticCurveType.NIST_P256, 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 SignatureKeyTemplatesTest method ecdsaP384.
@Test
public void ecdsaP384() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P384;
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.DER, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method ed25519.
@Test
public void ed25519() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ED25519;
assertEquals(new Ed25519PrivateKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, 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 rsaSsaPss3072.
@Test
public void rsaSsaPss3072() throws Exception {
KeyTemplate template = SignatureKeyTemplates.RSA_SSA_PSS_3072_SHA256_SHA256_32_F4;
assertEquals(new RsaSsaPssSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
RsaSsaPssKeyFormat format = RsaSsaPssKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertTrue(format.hasParams());
assertEquals(HashType.SHA256, format.getParams().getSigHash());
assertEquals(HashType.SHA256, format.getParams().getMgf1Hash());
assertEquals(32, format.getParams().getSaltLength());
assertEquals(3072, format.getModulusSizeInBits());
assertEquals(BigInteger.valueOf(65537), new BigInteger(1, format.getPublicExponent().toByteArray()));
}
Aggregations