use of com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method testRsa3072SsaPkcs1Sha256F4Template.
@Test
public void testRsa3072SsaPkcs1Sha256F4Template() throws Exception {
KeyTemplate template = RsaSsaPkcs1SignKeyManager.rsa3072SsaPkcs1Sha256F4Template();
assertThat(template.getTypeUrl()).isEqualTo(new RsaSsaPkcs1SignKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.TINK);
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.hasParams()).isTrue();
assertThat(format.getParams().getHashType()).isEqualTo(HashType.SHA256);
assertThat(format.getModulusSizeInBits()).isEqualTo(3072);
assertThat(new BigInteger(1, format.getPublicExponent().toByteArray())).isEqualTo(BigInteger.valueOf(65537));
}
use of com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method testRawRsa3072SsaPkcs1Sha256F4TemplateWithManager.
@Test
public void testRawRsa3072SsaPkcs1Sha256F4TemplateWithManager() throws Exception {
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(RsaSsaPkcs1SignKeyManager.rawRsa3072SsaPkcs1Sha256F4Template().getValue(), ExtensionRegistryLite.getEmptyRegistry());
new RsaSsaPkcs1SignKeyManager().keyFactory().validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method testRawRsa3072SsaPkcs1Sha256F4Template.
@Test
public void testRawRsa3072SsaPkcs1Sha256F4Template() throws Exception {
KeyTemplate template = RsaSsaPkcs1SignKeyManager.rawRsa3072SsaPkcs1Sha256F4Template();
assertThat(template.getTypeUrl()).isEqualTo(new RsaSsaPkcs1SignKeyManager().getKeyType());
assertThat(template.getOutputPrefixType()).isEqualTo(KeyTemplate.OutputPrefixType.RAW);
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.hasParams()).isTrue();
assertThat(format.getParams().getHashType()).isEqualTo(HashType.SHA256);
assertThat(format.getModulusSizeInBits()).isEqualTo(3072);
assertThat(new BigInteger(1, format.getPublicExponent().toByteArray())).isEqualTo(BigInteger.valueOf(65537));
}
use of com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method validateKeyFormat_unknownHashDisallowed.
@Test
public void validateKeyFormat_unknownHashDisallowed() throws Exception {
RsaSsaPkcs1KeyFormat format = createKeyFormat(HashType.UNKNOWN_HASH, 3072, RSAKeyGenParameterSpec.F4);
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
use of com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat in project tink by google.
the class RsaSsaPkcs1SignKeyManagerTest method testRsa4096SsaPkcs1Sha512F4TemplateWithManager.
@Test
public void testRsa4096SsaPkcs1Sha512F4TemplateWithManager() throws Exception {
RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.parseFrom(RsaSsaPkcs1SignKeyManager.rsa4096SsaPkcs1Sha512F4Template().getValue(), ExtensionRegistryLite.getEmptyRegistry());
new RsaSsaPkcs1SignKeyManager().keyFactory().validateKeyFormat(format);
}
Aggregations