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 whatsmars misplaced corrections #2

Open
wants to merge 1 commit into
base: thesis-2018-anam-dodhy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions data/whatsmars/misuses/10/correct-usages/ConstructCipher.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.SecretKeyFactory;
import javax.crypto.SecretKey;
import javax.crypto.spec.PBEKeySpec;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

public class ConstructSecretKeySpec {
public void pattern(char[] password,byte[] salt,int iterationCount,int keylength,java.lang.String algorithm) throws Exception {
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWithHmacSHA512AndAES_128");
PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount, keylength);
SecretKey key = skf.generateSecret(pbeks);
byte[] keyMaterial = key.getEncoded();
SecretKeySpec sks = new SecretKeySpec(keyMaterial, algorithm);
}
}

8 changes: 0 additions & 8 deletions data/whatsmars/misuses/11/correct-usages/ConstructCipher.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.SecretKeyFactory;
import javax.crypto.SecretKey;
import javax.crypto.spec.PBEKeySpec;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

public class ConstructSecretKeySpec {
public void pattern(char[] password,byte[] salt,int iterationCount,int keylength,java.lang.String algorithm) throws Exception {
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWithHmacSHA512AndAES_128");
PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount, keylength);
SecretKey key = skf.generateSecret(pbeks);
byte[] keyMaterial = key.getEncoded();
SecretKeySpec sks = new SecretKeySpec(keyMaterial, algorithm);
}
}