CryptoPrimitives implements CryptoSuite { void setSecurityLevel(final int securityLevel) throws InvalidArgumentException { logger.trace(format("setSecurityLevel to %d", securityLevel)); if (securityCurveMapping.isEmpty()) { throw new InvalidArgumentException("Security curve mapping has no entries."); } if (!securityCurveMapping.containsKey(securityLevel)) { StringBuilder sb = new StringBuilder(); String sp = ""; for (int x : securityCurveMapping.keySet()) { sb.append(sp).append(x); sp = ", "; } throw new InvalidArgumentException(format("Illegal security level: %d. Valid values are: %s", securityLevel, sb.toString())); } String lcurveName = securityCurveMapping.get(securityLevel); logger.debug(format("Mapped curve strength %d to %s", securityLevel, lcurveName)); X9ECParameters params = ECNamedCurveTable.getByName(lcurveName); if (params == null) { InvalidArgumentException invalidArgumentException = new InvalidArgumentException( format("Curve %s defined for security strength %d was not found.", curveName, securityLevel)); logger.error(invalidArgumentException); throw invalidArgumentException; } curveName = lcurveName; this.securityLevel = securityLevel; } CryptoPrimitives(); Certificate bytesToCertificate(byte[] certBytes); PrivateKey bytesToPrivateKey(byte[] pemKey); @Override boolean verify(byte[] pemCertificate, String signatureAlgorithm, byte[] signature, byte[] plainText); KeyStore getTrustStore(); void addCACertificateToTrustStore(File caCertPem, String alias); void addCACertificateToTrustStore(byte[] bytes, String alias); @Override void loadCACertificates(Collection<Certificate> certificates); @Override void loadCACertificatesAsBytes(Collection<byte[]> certificatesBytes); @Override KeyPair keyGen(); @Override byte[] sign(PrivateKey key, byte[] data); String generateCertificationRequest(String subject, KeyPair pair); @Override byte[] hash(byte[] input); @Override CryptoSuiteFactory getCryptoSuiteFactory(); void init(); @Override Properties getProperties(); byte[] certificateToDER(String certificatePEM);  }
@Test (expected = InvalidArgumentException.class) public void testSecurityLevel() throws InvalidArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException { CryptoPrimitives testCrypto = new CryptoPrimitives(); testCrypto.setSecurityLevel(2001); }