use of com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat in project tink by google.
the class JwtRsaSsaPkcs1SignKeyManagerTest method testJwtRsa4096AlgoRS512F4TemplateWithManager_ok.
@Test
public void testJwtRsa4096AlgoRS512F4TemplateWithManager_ok() throws Exception {
JwtRsaSsaPkcs1KeyFormat format = JwtRsaSsaPkcs1KeyFormat.parseFrom(KeyTemplates.get("JWT_RS512_4096_F4").getValue(), ExtensionRegistryLite.getEmptyRegistry());
new JwtRsaSsaPkcs1SignKeyManager().keyFactory().validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat in project tink by google.
the class JwtRsaSsaPkcs1SignKeyManagerTest method testJwtRsa3072AlgoRS384F4TemplateWithManager_ok.
@Test
public void testJwtRsa3072AlgoRS384F4TemplateWithManager_ok() throws Exception {
JwtRsaSsaPkcs1KeyFormat format = JwtRsaSsaPkcs1KeyFormat.parseFrom(KeyTemplates.get("JWT_RS384_3072_F4").getValue(), ExtensionRegistryLite.getEmptyRegistry());
new JwtRsaSsaPkcs1SignKeyManager().keyFactory().validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat in project tink by google.
the class JwtRsaSsaPkcs1SignKeyManagerTest method invalidKeyFormat_smallPublicExponents_throw.
// Note: we use Theory as a parametrized test -- different from what the Theory framework intends.
@Theory
public void invalidKeyFormat_smallPublicExponents_throw(@FromDataPoints("algorithmParam") JwtRsaSsaPkcs1Algorithm algorithm, @FromDataPoints("sizes") int keySize) throws GeneralSecurityException {
JwtRsaSsaPkcs1KeyFormat format = createKeyFormat(algorithm, keySize, RSAKeyGenParameterSpec.F4.subtract(BigInteger.ONE));
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
use of com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat in project tink by google.
the class JwtRsaSsaPkcs1SignKeyManagerTest method testJwtRsa3072AlgoRS256F4TemplateWithManager_ok.
@Test
public void testJwtRsa3072AlgoRS256F4TemplateWithManager_ok() throws Exception {
JwtRsaSsaPkcs1KeyFormat format = JwtRsaSsaPkcs1KeyFormat.parseFrom(KeyTemplates.get("JWT_RS256_3072_F4").getValue(), ExtensionRegistryLite.getEmptyRegistry());
new JwtRsaSsaPkcs1SignKeyManager().keyFactory().validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat in project tink by google.
the class JwtRsaSsaPkcs1SignKeyManagerTest method checkTemplate.
private static void checkTemplate(KeyTemplate template, JwtRsaSsaPkcs1Algorithm algorithm, int moduloSize, int publicExponent) throws Exception {
assertThat(template.getTypeUrl()).isEqualTo(new JwtRsaSsaPkcs1SignKeyManager().getKeyType());
JwtRsaSsaPkcs1KeyFormat format = JwtRsaSsaPkcs1KeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertThat(format.getAlgorithm()).isEqualTo(algorithm);
assertThat(format.getModulusSizeInBits()).isEqualTo(moduloSize);
assertThat(new BigInteger(1, format.getPublicExponent().toByteArray())).isEqualTo(BigInteger.valueOf(publicExponent));
}
Aggregations