CryptoPrimitives implements CryptoSuite { public Certificate bytesToCertificate(byte[] certBytes) throws CryptoException { if (certBytes == null || certBytes.length == 0) { throw new CryptoException("bytesToCertificate: input null or zero length"); } return getX509Certificate(certBytes); } 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 = CryptoException.class) public void testBytesToCertificateInvalidBytes() throws CryptoException { crypto.bytesToCertificate(INVALID_PEM_CERT.getBytes()); }
@Test (expected = CryptoException.class) public void testBytesToCertificateNullBytes() throws CryptoException { crypto.bytesToCertificate(null); }