@Test
public void generateSecret() throws Exception {

  BigInteger max = new BigInteger(2048, new Random());
  int maxSizeInBytes = RsaKem.bigIntSizeInBytes(max);
  Set<String> secrets = new TreeSet<>();
  for (int i = 0; i < 100; i++) {
    byte[] secret = RsaKem.generateSecret(max);
    BigInteger secretBigInt = new BigInteger(1, secret);
    secrets.add(new String(secret, UTF_8));
    assertThat(secret).hasLength(maxSizeInBytes);
    assertThat(secretBigInt.signum()).isEqualTo(1);
    assertThat(secretBigInt.compareTo(max)).isLessThan(0);
  }
  assertThat(secrets).hasSize(100);
}