CryptoAnalysis icon indicating copy to clipboard operation
CryptoAnalysis copied to clipboard

Incorrect number of occurrences for ConstraintError in a headless test

Open enriozuni opened this issue 5 years ago • 1 comments

The following project from Braga et al was headless tested.

public static void main(String[] args) throws Exception {

        // par de chaves de Ana e configurações do criptosistema
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC","SunEC");
        System.out.println("KeyPairGen "+kpg.getProvider().getName());
        
        Signature signerAna = Signature.getInstance("SHA512WithECDSA","SunEC");
        System.out.println("Signer "+signerAna.getProvider().getName());
        
        // Beto configura seu criptosistema
        Signature verifierBeto = Signature.getInstance("SHA512WithECDSA","SunEC");
        System.out.println("Verifier "+verifierBeto.getProvider().getName());
}

I get an inconsistency between the error markers in the IDE console and the specification of expected errors in the headless test itself.

The error marker in the console shows:

ConstraintError violating CrySL rule for java.security.Signature (on Object #cdc10a3b31851aec5bfa5ba0d51d63d9cc0be3bf89fec1ba3fc1d1b3770cceba)
			First parameter (with value "SHA512WithECDSA") should be any of {SHA256withECDSA, SHA256withDSA, SHA256withRSA, SHA224withDSA, NONEwithDSA, SHA1withDSA}
			at statement: r2 = staticinvoke <java.security.Signature: java.security.Signature getInstance(java.lang.String,java.lang.String)>(varReplacer10, varReplacer11)

As seen above, the error marker shows only one ConstraintError violation for the Signature object, when in fact there are 2 in total for two different Signature objects.

On the other hand, when specifying the correct expected errors in the headless test itself, the test passes.

setErrorsCount("<example.DefinedProvider2: void main(java.lang.String[])>", ConstraintError.class, 2);

I have stated that the printed error markers are not complete for the ConstraintError for 2 or more objects of the same type (e.g Signature).

enriozuni avatar Sep 17 '19 14:09 enriozuni

See comment to #187

johspaeth avatar Oct 15 '19 08:10 johspaeth

Fixed in #486

smeyer198 avatar Nov 30 '23 11:11 smeyer198