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

Fix StaticInitializationVectorABICase2 runtime errors #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

knewbury01
Copy link

@knewbury01 knewbury01 commented Jun 7, 2020

Hello! For anyone who might require the benchmark suite to be runnable (free of runtime errors), I have made a simple change to one of the benchmarks in the suite. - I will totally understand however if that is not the aim of this project, as I know this is mainly a benchmark for crypto API misuse detection static analysis tools.

If there is anything that is unclear or that I need to adjust , let me know :)

Two errors:

  1. java.lang.NumberFormatException in line 17
  2. java.security.InvalidAlgorithmParameterException in line 22

Stack trace of Error 1:

Exception in thread "main" java.lang.NumberFormatException: For input string: "abcde"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Byte.parseByte(Byte.java:149)
	at java.lang.Byte.parseByte(Byte.java:175)
	at org.cryptoapi.bench.staticinitializationvector.StaticInitializationVectorABICase2.go(StaticInitializationVectorABICase2.java:17)
	at org.cryptoapi.bench.staticinitializationvector.StaticInitializationVectorABICase2.main(StaticInitializationVectorABICase2.java:41)

Reason for error:

  • [parseByte}(https://docs.oracle.com/javase/8/docs/api/java/lang/Byte.html#parseByte-java.lang.String-) expects the String used to denote byte values. It appears that String.getBytes was the intended call here.

Stack trace of Error 2:

Exception in thread "main" java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long
	at com.sun.crypto.provider.CipherCore.init(CipherCore.java:585)
	at com.sun.crypto.provider.AESCipher.engineInit(AESCipher.java:346)
	at javax.crypto.Cipher.implInit(Cipher.java:809)
	at javax.crypto.Cipher.chooseProvider(Cipher.java:867)
	at javax.crypto.Cipher.init(Cipher.java:1399)
	at javax.crypto.Cipher.init(Cipher.java:1330)
	at org.cryptoapi.bench.staticinitializationvector.StaticInitializationVectorABICase2.go(StaticInitializationVectorABICase2.java:22)
	at org.cryptoapi.bench.staticinitializationvector.StaticInitializationVectorABICase2.main(StaticInitializationVectorABICase2.java:36)

Reason for error:

  • the AES IV must be 16 bytes, was previously 5

Additional:

  • there are actually a few instances of the 2nd runtime error in the suite currently, if you are interested to apply this fix, I will go and annotate the rest as well :) Thanks!

Two errors:
java.lang.NumberFormatException in line 17
java.security.InvalidAlgorithmParameterException in line 22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant