use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method createCorruptedModulusPrimitive_throws.
@Test
public void createCorruptedModulusPrimitive_throws() throws Exception {
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA512, HashType.SHA512, 64, 4096, RSAKeyGenParameterSpec.F4);
RsaSsaPssPrivateKey originalKey = factory.createKey(format);
byte[] originalN = originalKey.getPublicKey().getN().toByteArray();
originalN[0] = (byte) (originalN[0] ^ 0x01);
ByteString corruptedN = ByteString.copyFrom(originalN);
RsaSsaPssPublicKey corruptedPub = RsaSsaPssPublicKey.newBuilder().setVersion(originalKey.getPublicKey().getVersion()).setN(corruptedN).setE(originalKey.getPublicKey().getE()).build();
RsaSsaPssPrivateKey corruptedKey = RsaSsaPssPrivateKey.newBuilder().setVersion(originalKey.getVersion()).setPublicKey(corruptedPub).setD(originalKey.getD()).setP(originalKey.getP()).setQ(originalKey.getQ()).setDp(originalKey.getDp()).setDq(originalKey.getDq()).setCrt(originalKey.getCrt()).build();
assertThrows(GeneralSecurityException.class, () -> manager.getPrimitive(corruptedKey, PublicKeySign.class));
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method testRawRsa3072PssSha256F4TemplateWithManager.
@Test
public void testRawRsa3072PssSha256F4TemplateWithManager() throws Exception {
RsaSsaPssKeyFormat format = RsaSsaPssKeyFormat.parseFrom(RsaSsaPssSignKeyManager.rawRsa3072PssSha256F4Template().getValue(), ExtensionRegistryLite.getEmptyRegistry());
new RsaSsaPssSignKeyManager().keyFactory().validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method validateKeyFormat_valid.
@Test
public void validateKeyFormat_valid() throws Exception {
RsaSsaPssKeyFormat format = validKeyFormat();
factory.validateKeyFormat(format);
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method validateKeyFormat_sha1Disallowed_throws.
@Test
public void validateKeyFormat_sha1Disallowed_throws() throws Exception {
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA1, HashType.SHA1, 32, 3072, RSAKeyGenParameterSpec.F4);
assertThrows(GeneralSecurityException.class, () -> factory.validateKeyFormat(format));
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method testRsa3072PssSha256F4TemplateWithManager.
@Test
public void testRsa3072PssSha256F4TemplateWithManager() throws Exception {
RsaSsaPssKeyFormat format = RsaSsaPssKeyFormat.parseFrom(RsaSsaPssSignKeyManager.rsa3072PssSha256F4Template().getValue(), ExtensionRegistryLite.getEmptyRegistry());
new RsaSsaPssSignKeyManager().keyFactory().validateKeyFormat(format);
}
Aggregations