use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method getPublicKey_correctValues.
@Test
public void getPublicKey_correctValues() throws Exception {
if (TestUtil.isTsan()) {
// factory.createKey is too slow in Tsan.
return;
}
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA512, HashType.SHA512, 64, 4096, RSAKeyGenParameterSpec.F4);
RsaSsaPssPrivateKey key = factory.createKey(format);
assertThat(manager.getPublicKey(key)).isEqualTo(key.getPublicKey());
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method validateKeyFormat_hashMismatchDisallowed2_throws.
@Test
public void validateKeyFormat_hashMismatchDisallowed2_throws() throws Exception {
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA256, HashType.SHA512, 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 validateKeyFormat_hashMismatchDisallowed1_throws.
@Test
public void validateKeyFormat_hashMismatchDisallowed1_throws() throws Exception {
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA512, HashType.SHA256, 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 createKey_smallKey.
@Test
public void createKey_smallKey() throws Exception {
if (TestUtil.isTsan()) {
// factory.createKey is too slow in Tsan.
return;
}
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA256, HashType.SHA256, 32, 3072, RSAKeyGenParameterSpec.F4);
RsaSsaPssPrivateKey key = factory.createKey(format);
checkConsistency(key, format);
checkKey(key);
}
use of com.google.crypto.tink.proto.RsaSsaPssKeyFormat in project tink by google.
the class RsaSsaPssSignKeyManagerTest method createKey_alwaysNewElement.
@Test
public void createKey_alwaysNewElement() throws Exception {
if (TestUtil.isTsan()) {
// factory.createKey is too slow in Tsan.
return;
}
RsaSsaPssKeyFormat format = createKeyFormat(HashType.SHA256, HashType.SHA256, 32, 3072, RSAKeyGenParameterSpec.F4);
Set<String> keys = new TreeSet<>();
// Calls newKey multiple times and make sure that they generate different keys -- takes about a
// second per key.
int numTests = 5;
for (int i = 0; i < numTests; i++) {
RsaSsaPssPrivateKey key = factory.createKey(format);
keys.add(TestUtil.hexEncode(key.getQ().toByteArray()));
keys.add(TestUtil.hexEncode(key.getP().toByteArray()));
}
assertThat(keys).hasSize(2 * numTests);
}
Aggregations