Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Log file
*.log
logfileConf.txt

# BlueJ files
*.ctxt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ public void deleteClientData() {
* @see #encryptAES(String, String)
*/
@Deprecated
public static String encryptRC4(String input, String key) {
return RC4.encrypt(input, key);
public static String encryptRC4(String input, String key) throws CryptoException {
//return RC4.encrypt(input, key);
throw new CryptoException("RC4 is insecure and should not be used. Use AES instead.");
}

/**
Expand All @@ -149,7 +150,8 @@ public static String encryptRC4(String input, String key) {
*/
@Deprecated
public static String decryptRC4(String input, String key) throws CryptoException {
return RC4.decrypt(input, key);
//return RC4.decrypt(input, key);
throw new CryptoException("RC4 is insecure and should not be used. Use AES instead.");
}

/**
Expand Down
45 changes: 11 additions & 34 deletions JFramework/crypto/src/test/java/crypto/algorithm/RC4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,20 @@

public class RC4Test {

@Test
public void encrypt_decrypt() {

for (int i : plainTextLengths) {
for (int i2 : keyLengths) {

String plain = genString(i);
String key = genString(i2);

String encrypted = Crypto.encryptRC4(plain, key);
String decrypted = null;
try {
decrypted = Crypto.decryptRC4(encrypted, key);
} catch (CryptoException e) {
e.printStackTrace();
assert false;
}

assertEquals(plain, decrypted);
}
}
}
@Test(expected = CryptoException.class)
public void encryptRC4ShouldFail() throws CryptoException {
String plain = genString(10);
String key = genString(10);

@Test
public void decryptWrongString() {
String encrypted = "NJ12_eEyaN8cf348RQf9_w=";
try {
Crypto.decryptRC4(encrypted, "richktest");
assert false;
} catch (CryptoException e) {
//e.printStackTrace();
assert true;
}
// this should fail, as RC4 is insecure
Crypto.encryptRC4(plain, key);
}

@Test
public void encrypt_decrypt__BcCompability() {
@Test(expected = CryptoException.class)
public void decryptRC4ShouldFail() throws CryptoException {
String encrypted = "NJ12_eEyaN8cf348RQf9_w=";
// this should fail, as RC4 is insecure
Crypto.decryptRC4(encrypted, "richktest");
}


Expand Down