Comments (3)
Transformation string is generated incorrect because currently the test generator does not support two step generation for handling the below constraint type. Two step generation is needed because the class type of key
is known only after the generation of init
method.
instanceOf[key, java.security.PublicKey] || instanceOf[key, java.security.PrivateKey] || instanceOf[cert, java.security.cert.Certificate]|| encmode in {3, 4} => alg(transformation) in {"RSA"};
Cipher cipher0 = Cipher.getInstance("RSA"); // wrong transformation string is generated
cipher0.init(1, secretKey);
byte[] pre_ciphertext = cipher0.update(pre_plaintext);
Assertions.hasEnsuredPredicate(pre_ciphertext);
Assertions.mustNotBeInAcceptingState(cipher0);
pBEKeySpec0.clearPassword();
Assertions.mustBeInAcceptingState(pBEKeySpec0);
Following test cases have the above issue
- cipherInvalidTest23
- cipherInvalidTest24
- cipherInvalidTest25
- cipherInvalidTest26
- cipherInvalidTest27
- cipherInvalidTest28
- cipherValidTest13()
- cipherValidTest14()
- cipherValidTest15()
- cipherValidTest16()
- cipherValidTest17()
- cipherValidTest18()
- cipherValidTest26()
- cipherValidTest27()
- cipherValidTest28()
- cipherValidTest29()
- cipherValidTest30()
- cipherValidTest31()
from cognicrypt_testgen.
Test generator does not recognize negated predicates like below in the REQUIRES section. Thus it generates the code from the associated specification. (for the below case it is Cipher
)
REQUIRES
!encrypted[output1, _];
@Test
public void macInvalidTest9() throws IllegalStateException, BadPaddingException, NoSuchPaddingException,
IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeyException, ShortBufferException {
Certificate cert = null;
byte[] plainText = null;
byte[] pre_plaintext = null;
Cipher cipher0 = Cipher.getInstance("RSA");
cipher0.init(1, cert);
byte[] pre_ciphertext = cipher0.update(pre_plaintext);
byte[] cipherText = cipher0.doFinal(plainText);
Assertions.hasEnsuredPredicate(cipherText);
Assertions.mustBeInAcceptingState(cipher0);
int outOffset = 0;
Mac mac0 = Mac.getInstance("HmacMD5");
mac0.doFinal(cipherText, outOffset);
Assertions.notHasEnsuredPredicate(cipherText); // FAILS
Assertions.mustNotBeInAcceptingState(mac0);
}
@Test
public void macInvalidTest22() throws IllegalStateException, BadPaddingException, NoSuchPaddingException,
IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeyException, ShortBufferException {
Certificate cert = null;
byte[] plainText = null;
byte[] pre_plaintext = null;
Cipher cipher0 = Cipher.getInstance("RSA");
cipher0.init(1, cert);
byte[] pre_ciphertext = cipher0.update(pre_plaintext);
byte[] cipherText = cipher0.doFinal(plainText);
Assertions.hasEnsuredPredicate(cipherText);
Assertions.mustBeInAcceptingState(cipher0);
int outOffset = 0;
byte inp = 0;
Mac mac0 = Mac.getInstance("HmacMD5");
mac0.update(inp);
mac0.doFinal(cipherText, outOffset);
Assertions.notHasEnsuredPredicate(cipherText); // FAILS
Assertions.mustNotBeInAcceptingState(mac0);
}
from cognicrypt_testgen.
CONSTRAINTS
offset < len;
@Test
public void macValidTest10() throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException {
int offset = 0;
int len = 0; // initialised with incorrect value
byte[] pre_input = null;
Key key = null;
Mac mac0 = Mac.getInstance("HmacMD5");
mac0.init(key);
mac0.update(pre_input, offset, len);
byte[] output1 = mac0.doFinal();
Assertions.hasEnsuredPredicate(output1); // FAILS
Assertions.mustBeInAcceptingState(mac0);
}
from cognicrypt_testgen.
Related Issues (14)
- RunTestGeneratorHandler is triggered twice on every run
- Required parameters are not generated
- Wrong assertions HOT 3
- All 68 failing test cases with develop ruleset & SELECT ALL strategy HOT 1
- All 17 failing test cases with develop ruleset & SELECT FIRST strategy HOT 1
- Plugin fails for new ruleset
- Handle ClassNotFoundException in Utils.isSubType method
- Create method arguments as local variables
- Generate method calls with AnyType parameter
- Incorrect assertion parameter HOT 3
- Failing test suites with eval ruleset HOT 1
- Failing test suites with develop ruleset
- Incorrect assertion parameter for SecureRandom HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cognicrypt_testgen.