Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positives reported by CogniCrypt_TESTGEN #296

Closed
rakshitkr opened this issue Sep 20, 2020 · 2 comments · Fixed by #495
Closed

False Positives reported by CogniCrypt_TESTGEN #296

rakshitkr opened this issue Sep 20, 2020 · 2 comments · Fixed by #495

Comments

@rakshitkr
Copy link
Contributor

rakshitkr commented Sep 20, 2020

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
Copy link
Contributor Author

rakshitkr commented Dec 12, 2020

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
Copy link
Contributor Author

rakshitkr commented Dec 12, 2020

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

	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants