CryptoAnalysis icon indicating copy to clipboard operation
CryptoAnalysis copied to clipboard

False Positives reported by CogniCrypt_TESTGEN

Open rakshitkr opened this issue 4 years ago • 2 comments

Below test cases are failing because CryptoAnalysis cannot handle multiple initial transition edges.

PKIXBuilderParameters

@Test
	public void pKIXBuilderParametersValidTest2() throws InvalidAlgorithmParameterException {

		Set trustAnchors = null;
		CertSelector certSelector = null;

		PKIXBuilderParameters pKIXBuilderParameters0 = new PKIXBuilderParameters(trustAnchors, certSelector);
		Assertions.hasEnsuredPredicate(pKIXBuilderParameters0); // FAILS
		Assertions.mustBeInAcceptingState(pKIXBuilderParameters0); // FAILS

	}

SSLParameters

@Test
	public void sSLParametersValidTest1() {

		SSLParameters sSLParameters0 = new SSLParameters(new String[] { "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" },
				new String[] { "TLSv1.2" });
		Assertions.hasEnsuredPredicate(sSLParameters0); // FAILS
		Assertions.mustBeInAcceptingState(sSLParameters0); // FAILS

	}
@Test
	public void sSLParametersValidTest2() {

		SSLParameters sSLParameters0 = new SSLParameters(new String[] { "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" });
		sSLParameters0.setProtocols(new String[] { "TLSv1.2" });
		Assertions.hasEnsuredPredicate(sSLParameters0); // FAILS
		Assertions.mustBeInAcceptingState(sSLParameters0); // FAILS

	}
@Test
	public void sSLParametersInvalidTest2() {

		SSLParameters sSLParameters0 = new SSLParameters(new String[] { "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" });
		Assertions.notHasEnsuredPredicate(sSLParameters0); // FAILS
		Assertions.mustNotBeInAcceptingState(sSLParameters0); // FAILS

	}

rakshitkr avatar Sep 20 '20 11:09 rakshitkr

Below test cases are failing because Assertions.hasEnsuredPredicate(key) is not generated immediately after Key key = keyStore0.getKey(alias, passwordKey) (refer issue 310)

Wrong test classification and wrong state assertion due to issue 322

KeyStore

        @Test
	public void keyStoreInvalidTest10() throws NoSuchAlgorithmException, UnrecoverableKeyException, IOException,
			KeyStoreException, CertificateException {

		char[] passwordKey = null;
		String alias = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		char[] passwordIn = null;
		LoadStoreParameter paramStore = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Key key = keyStore0.getKey(alias, passwordKey);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(key); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest11() throws NoSuchAlgorithmException, UnrecoverableKeyException, IOException,
			KeyStoreException, CertificateException, NoSuchProviderException {

		char[] passwordKey = null;
		String alias = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		char[] passwordIn = null;
		LoadStoreParameter paramStore = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm, (Provider) null);
		keyStore0.load(fileinput, passwordIn);
		Key key = keyStore0.getKey(alias, passwordKey);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(key); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest12() throws NoSuchAlgorithmException, UnrecoverableKeyException, IOException,
			KeyStoreException, CertificateException {

		char[] passwordKey = null;
		String alias = null;
		Entry entry = null;
		LoadStoreParameter paramLoad = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		LoadStoreParameter paramStore = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(paramLoad);
		Key key = keyStore0.getKey(alias, passwordKey);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(key); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);
	}

	@Test
	public void keyStoreInvalidTest13() throws NoSuchAlgorithmException, UnrecoverableKeyException, IOException,
			KeyStoreException, CertificateException {

		char[] passwordKey = null;
		String alias = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		OutputStream fileoutput = null;
		char[] passwordOut = null;
		char[] passwordIn = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Key key = keyStore0.getKey(alias, passwordKey);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(fileoutput, passwordOut);
		Assertions.hasEnsuredPredicate(key); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest14() throws NoSuchAlgorithmException, IOException, KeyStoreException,
			CertificateException, UnrecoverableEntryException {

		String aliasGet = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		char[] passwordIn = null;
		LoadStoreParameter paramStore = null;
		ProtectionParameter protParamGet = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		keyStore0.getEntry(aliasGet, protParamGet);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(keyStore0); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest15() throws NoSuchAlgorithmException, IOException, KeyStoreException,
			CertificateException, NoSuchProviderException, UnrecoverableEntryException {

		String aliasGet = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		char[] passwordIn = null;
		LoadStoreParameter paramStore = null;
		ProtectionParameter protParamGet = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm, (Provider) null);
		keyStore0.load(fileinput, passwordIn);
		keyStore0.getEntry(aliasGet, protParamGet);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(keyStore0); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest16() throws NoSuchAlgorithmException, IOException, KeyStoreException,
			CertificateException, UnrecoverableEntryException {

		String aliasGet = null;
		Entry entry = null;
		LoadStoreParameter paramLoad = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		LoadStoreParameter paramStore = null;
		ProtectionParameter protParamGet = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(paramLoad);
		keyStore0.getEntry(aliasGet, protParamGet);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(paramStore);
		Assertions.hasEnsuredPredicate(keyStore0); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

	@Test
	public void keyStoreInvalidTest17() throws NoSuchAlgorithmException, IOException, KeyStoreException,
			CertificateException, UnrecoverableEntryException {

		String aliasGet = null;
		Entry entry = null;
		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		String aliasSet = null;
		ProtectionParameter protParamSet = null;
		OutputStream fileoutput = null;
		char[] passwordOut = null;
		char[] passwordIn = null;
		ProtectionParameter protParamGet = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		keyStore0.getEntry(aliasGet, protParamGet);
		keyStore0.setEntry(aliasSet, entry, protParamSet);
		keyStore0.store(fileoutput, passwordOut);
		Assertions.hasEnsuredPredicate(keyStore0); // FAILS
		Assertions.mustNotBeInAcceptingState(keyStore0);

	}

rakshitkr avatar Dec 12 '20 23:12 rakshitkr

MessageDigest

ORDER : Gets, (DWOU | (Updates+, Digests))+

@Test
	public void messageDigestInvalidTest10() throws NoSuchAlgorithmException {

		byte[] inbytearr = null;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256");
		byte[] out = messageDigest0.digest(inbytearr);
                // update is skipped
		out = messageDigest0.digest();
		Assertions.hasEnsuredPredicate(out);  // notHasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0); // FAILS

	}

	@Test
	public void messageDigestInvalidTest11() throws NoSuchAlgorithmException, NoSuchProviderException {

		byte[] inbytearr = null;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256", (Provider) null);
		byte[] out = messageDigest0.digest(inbytearr);
                // update is skipped
		out = messageDigest0.digest();
		Assertions.hasEnsuredPredicate(out); // notHasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0); // FAILS

	}

	@Test
	public void messageDigestInvalidTest12() throws NoSuchAlgorithmException, DigestException {

		int off = 0;
		byte[] inbytearr = null;
		int len = 0;
		byte[] out = null;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256");
		out = messageDigest0.digest(inbytearr);
                // update is skipped
		messageDigest0.digest(out, off, len);
		Assertions.hasEnsuredPredicate(out); // notHasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0); // FAILS

	}

	@Test
	public void messageDigestInvalidTest13() throws NoSuchAlgorithmException {

		byte[] inbytearr = null;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256"):
		byte[] out = messageDigest0.digest(inbytearr);
                // // update is skipped
		out = messageDigest0.digest(inbytearr);
		Assertions.hasEnsuredPredicate(out); // notHasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0); // FAILS

	}

rakshitkr avatar Dec 12 '20 23:12 rakshitkr