use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class SignatureKeyTemplatesTest method rsaSsaPss4096.
@Test
public void rsaSsaPss4096() throws Exception {
KeyTemplate template = SignatureKeyTemplates.RSA_SSA_PSS_4096_SHA512_SHA512_64_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.SHA512, format.getParams().getSigHash());
assertEquals(HashType.SHA512, format.getParams().getMgf1Hash());
assertEquals(64, format.getParams().getSaltLength());
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 ecdsaP521Ieee.
@Test
public void ecdsaP521Ieee() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P521_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_P521, 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 ecdsaP256.
@Test
public void ecdsaP256() throws Exception {
KeyTemplate template = SignatureKeyTemplates.ECDSA_P256;
assertEquals(new EcdsaSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, 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.DER, format.getParams().getEncoding());
}
use of com.google.crypto.tink.proto.KeyTemplate in project tink by google.
the class StreamingAeadKeyTemplatesTest method testAes256CtrHmacSha256_1MB.
@Test
public void testAes256CtrHmacSha256_1MB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES256_CTR_HMAC_SHA256_1MB;
assertEquals(new AesCtrHmacStreamingKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesCtrHmacStreamingKeyFormat format = AesCtrHmacStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(32, format.getKeySize());
assertEquals(32, format.getParams().getDerivedKeySize());
assertEquals(HashType.SHA256, format.getParams().getHkdfHashType());
assertEquals(1048576, 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 StreamingAeadKeyTemplatesTest method testAes256GcmHkdf_1MB.
@Test
public void testAes256GcmHkdf_1MB() throws Exception {
KeyTemplate template = StreamingAeadKeyTemplates.AES256_GCM_HKDF_1MB;
assertEquals(new AesGcmHkdfStreamingKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.RAW, template.getOutputPrefixType());
AesGcmHkdfStreamingKeyFormat format = AesGcmHkdfStreamingKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(32, format.getKeySize());
assertEquals(32, format.getParams().getDerivedKeySize());
assertEquals(HashType.SHA256, format.getParams().getHkdfHashType());
assertEquals(1048576, format.getParams().getCiphertextSegmentSize());
}
Aggregations