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

Wrong assertions #12

Open
rakshitkr opened this issue Dec 7, 2020 · 3 comments
Open

Wrong assertions #12

rakshitkr opened this issue Dec 7, 2020 · 3 comments
Labels
bug Something isn't working develop ruleset

Comments

@rakshitkr
Copy link
Collaborator

rakshitkr commented Dec 7, 2020

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

		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		char[] passwordIn = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Assertions.hasEnsuredPredicate(keyStore0);
		Assertions.mustBeInAcceptingState(keyStore0);

		char[] password = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX");
		keyManagerFactory0.init(keyStore0, password);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

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

		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		char[] passwordIn = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Assertions.hasEnsuredPredicate(keyStore0);
		Assertions.mustBeInAcceptingState(keyStore0);

		char[] password = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX", (String) null);
		keyManagerFactory0.init(keyStore0, password);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

	}
	@Test
	public void keyManagerFactoryValidTest6() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {

		ManagerFactoryParameters params = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX");
		keyManagerFactory0.init(params);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

	}
@rakshitkr
Copy link
Collaborator Author

rakshitkr commented Dec 7, 2020

Issue 404 : getTransitions() return unexpected transition getInstance->load->getKey->setEntry->store for KeyStore. Either getInstance->load->getKey or getInstance->load->setEntry->store are expected.

Assertions.hasEnsuredPredicate(key) fails because of issue 310 in CryptoAnalysis

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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

	@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);
		Assertions.mustNotBeInAcceptingState(keyStore0); // mustBeInAcceptingState is correct

	}

@rakshitkr
Copy link
Collaborator Author

rakshitkr commented Dec 7, 2020

getTransitions() return unexpected transition Gets->DWOU->Updates->Digests for MessageDigest. Only Gets->DWOU and Gets->Updates->Digests are expected. Furthermore, it does not return expected transition Gets->Updates->Digests as described here

Hence messageDigestInvalidTest3 to messageDigestInvalidTest9 are wrongly classified as invalid tests and messageDigestInvalidTest10 to messageDigestInvalidTest13, messageDigestValidTest6 & messageDigestValidTest8 are generated additionally.

@Test
	public void messageDigestInvalidTest3() throws NoSuchAlgorithmException {

		byte pre_inbyte = 0;

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

	}

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

		byte pre_inbyte = 0;

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

	}

	@Test
	public void messageDigestInvalidTest5() throws NoSuchAlgorithmException {

		byte[] pre_inbytearr = null;

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

	}

	@Test
	public void messageDigestInvalidTest6() throws NoSuchAlgorithmException {

		byte[] pre_inbytearr = null;
		int pre_off = 0;
		int pre_len = 0;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256");
		messageDigest0.update(pre_inbytearr, pre_off, pre_len);
		byte[] out = messageDigest0.digest();
		Assertions.notHasEnsuredPredicate(out); // hasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0); // mustBeInAcceptingState is correct

	}

	@Test
	public void messageDigestInvalidTest7() throws NoSuchAlgorithmException {

		ByteBuffer pre_inpBuf = null;

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

	}

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

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

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

	}

	@Test
	public void messageDigestInvalidTest9() throws NoSuchAlgorithmException {

		byte pre_inbyte = 0;
		byte[] inbytearr = null;

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

	}

	@Test
	public void messageDigestInvalidTest10() throws NoSuchAlgorithmException {

		byte[] inbytearr = null;

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

	}

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

		byte[] inbytearr = null;

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

	}

	@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);
		messageDigest0.digest(out, off, len);
		Assertions.hasEnsuredPredicate(out); // notHasEnsuredPredicate is correct
		Assertions.mustNotBeInAcceptingState(messageDigest0);

	}

	@Test
	public void messageDigestInvalidTest13() throws NoSuchAlgorithmException {

		byte[] inbytearr = null;

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

	}

        @Test
	public void messageDigestValidTest6() throws NoSuchAlgorithmException {

		byte[] pre_inbytearr = null;
		int pre_off = 0;
		byte[] inbytearr = null;
		int pre_len = 0;

		MessageDigest messageDigest0 = MessageDigest.getInstance("SHA-256");
		byte[] out = messageDigest0.digest(inbytearr);
		messageDigest0.update(pre_inbytearr, pre_off, pre_len);
		out = messageDigest0.digest();
		Assertions.hasEnsuredPredicate(out); // notHasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(messageDigest0);

	}

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

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

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

	}

@rakshitkr rakshitkr added bug Something isn't working develop ruleset labels Dec 7, 2020
@rakshitkr
Copy link
Collaborator Author

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

		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		char[] passwordIn = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Assertions.hasEnsuredPredicate(keyStore0);
		Assertions.mustBeInAcceptingState(keyStore0);

		char[] password = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX");
		keyManagerFactory0.init(keyStore0, password);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

	}

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

		InputStream fileinput = null;
		String keyStoreAlgorithm = null;
		char[] passwordIn = null;

		KeyStore keyStore0 = KeyStore.getInstance(keyStoreAlgorithm);
		keyStore0.load(fileinput, passwordIn);
		Assertions.hasEnsuredPredicate(keyStore0);
		Assertions.mustBeInAcceptingState(keyStore0);

		char[] password = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX", (String) null);
		keyManagerFactory0.init(keyStore0, password);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

	}

	@Test
	public void keyManagerFactoryValidTest6() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {

		ManagerFactoryParameters params = null;

		KeyManagerFactory keyManagerFactory0 = KeyManagerFactory.getInstance("PKIX");
		keyManagerFactory0.init(params);
		KeyManager[] keyManager = keyManagerFactory0.getKeyManagers();
		Assertions.notHasEnsuredPredicate(keyManager); // hasEnsuredPredicate is correct
		Assertions.mustBeInAcceptingState(keyManagerFactory0);

	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working develop ruleset
Projects
None yet
Development

No branches or pull requests

1 participant