diff --git a/CryptoAnalysis/src/test/java/tests/headless/ReportedIssueTest.java b/CryptoAnalysis/src/test/java/tests/headless/ReportedIssueTest.java index 7465e2abe..e90c5bc9e 100644 --- a/CryptoAnalysis/src/test/java/tests/headless/ReportedIssueTest.java +++ b/CryptoAnalysis/src/test/java/tests/headless/ReportedIssueTest.java @@ -43,6 +43,9 @@ public void reportedIssues() { setErrorsCount("", ConstraintError.class, 1); setErrorsCount("", RequiredPredicateError.class, 3); + setErrorsCount("", IncompleteOperationError.class, 1); + setErrorsCount("", RequiredPredicateError.class, 4); + // TODO toCharArray() is not currently not considered when evaluating NeverTypeOfErrors setErrorsCount("", NeverTypeOfError.class, 0); setErrorsCount("", RequiredPredicateError.class, 3); diff --git a/CryptoAnalysisTargets/ReportedIssues/pom.xml b/CryptoAnalysisTargets/ReportedIssues/pom.xml index 280f473a2..5f6776100 100644 --- a/CryptoAnalysisTargets/ReportedIssues/pom.xml +++ b/CryptoAnalysisTargets/ReportedIssues/pom.xml @@ -15,4 +15,12 @@ + + + + commons-codec + commons-codec + 1.10 + + \ No newline at end of file diff --git a/CryptoAnalysisTargets/ReportedIssues/src/main/java/issue69/Issue69.java b/CryptoAnalysisTargets/ReportedIssues/src/main/java/issue69/Issue69.java new file mode 100644 index 000000000..773f4619e --- /dev/null +++ b/CryptoAnalysisTargets/ReportedIssues/src/main/java/issue69/Issue69.java @@ -0,0 +1,25 @@ +package issue69; + +import org.apache.commons.codec.binary.Base64; + +import javax.crypto.Cipher; +import java.security.Key; +import java.security.KeyFactory; +import java.security.spec.X509EncodedKeySpec; + +public class Issue69 { + + private static final String KEY_ALGORITHM = "RSA"; + + public void encryptByPublicKey(String publicKey) throws Exception { + byte[] keyBytes = new Base64().decode(publicKey.getBytes()); + X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes); + KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); + Key publicK = keyFactory.generatePublic(x509KeySpec); + + Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm()); + + // RequiredPredicateError because no predicate is ensured on 'keyBytes' + cipher.init(Cipher.ENCRYPT_MODE, publicK); + } +}