X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Futil%2FCipherInfo.java;h=4c20710a7db980246d334e9fdeb13f54f0220130;hb=3252dc36fadd1a7e5f13bc01401e10565d61f635;hp=5860c119903a17407c7dea83010af02954c3d909;hpb=6c66b3ecc23234fc5f5d98bcc7c54f66bfdeaab8;p=gigi.git diff --git a/src/org/cacert/gigi/util/CipherInfo.java b/src/org/cacert/gigi/util/CipherInfo.java index 5860c119..4c20710a 100644 --- a/src/org/cacert/gigi/util/CipherInfo.java +++ b/src/org/cacert/gigi/util/CipherInfo.java @@ -25,8 +25,7 @@ public class CipherInfo implements Comparable { public CipherInfoGenerator() throws ReflectiveOperationException { SSLContextImpl sc = new SSLContextImpl.TLS12Context(); - Method m = SSLContextImpl.class - .getDeclaredMethod("getSupportedCipherSuiteList"); + Method m = SSLContextImpl.class.getDeclaredMethod("getSupportedCipherSuiteList"); m.setAccessible(true); Object o = m.invoke(sc); Class cipherSuiteList = o.getClass(); @@ -58,8 +57,8 @@ public class CipherInfo implements Comparable { macSize = mac.getDeclaredField("size"); macSize.setAccessible(true); } - public CipherInfo generateInfo(String suiteName) - throws IllegalArgumentException, IllegalAccessException { + + public CipherInfo generateInfo(String suiteName) throws IllegalArgumentException, IllegalAccessException { Object suite = names.get(suiteName); String keyExchange = exchange.get(suite).toString(); Object bulkCipher = cipher.get(suite); @@ -79,12 +78,12 @@ public class CipherInfo implements Comparable { padding = transformationParts[2]; } - return new CipherInfo(suiteName, keyExchange, - transformationParts[0], keysize * 8, chaining, padding, - macNam, macSiz * 8); + return new CipherInfo(suiteName, keyExchange, transformationParts[0], keysize * 8, chaining, padding, + macNam, macSiz * 8); } } + String keyExchange; String cipher; int keySize; @@ -94,9 +93,8 @@ public class CipherInfo implements Comparable { int macSize; String suiteName; - private CipherInfo(String suiteName, String keyExchange, String cipher, - int keySize, String cipherChaining, String cipherPadding, - String macName, int macSize) { + private CipherInfo(String suiteName, String keyExchange, String cipher, int keySize, String cipherChaining, + String cipherPadding, String macName, int macSize) { this.suiteName = suiteName; this.keyExchange = keyExchange; this.cipher = cipher; @@ -129,9 +127,11 @@ public class CipherInfo implements Comparable { } return null; } + public String getSuiteName() { return suiteName; } + /** * 5: ECDHE, AES||CAMELLIA, keysize >=256
* 4: DHE, AES||CAMELLIA, keysize >= 256
@@ -143,8 +143,7 @@ public class CipherInfo implements Comparable { * @return the strength */ public int getStrength() { - if (cipher.equals("NULL") || cipher.equals("RC4") - || cipher.contains("DES")) { + if (cipher.equals("NULL") || cipher.equals("RC4") || cipher.contains("DES")) { return 0; } boolean ecdhe = keyExchange.startsWith("ECDHE"); @@ -168,16 +167,16 @@ public class CipherInfo implements Comparable { } return 0; } - private static final String[] CIPHER_RANKING = new String[]{"CAMELLIA", - "AES", "RC4", "3DES", "DES", "DES40"}; + + private static final String[] CIPHER_RANKING = new String[] { "CAMELLIA", "AES", "RC4", "3DES", "DES", "DES40" }; @Override public String toString() { - return "CipherInfo [keyExchange=" + keyExchange + ", cipher=" + cipher - + ", keySize=" + keySize + ", cipherChaining=" + cipherChaining - + ", cipherPadding=" + cipherPadding + ", macName=" + macName - + ", macSize=" + macSize + "]"; + return "CipherInfo [keyExchange=" + keyExchange + ", cipher=" + cipher + ", keySize=" + keySize + + ", cipherChaining=" + cipherChaining + ", cipherPadding=" + cipherPadding + ", macName=" + macName + + ", macSize=" + macSize + "]"; } + /** * ECDHE
* GCM
@@ -255,15 +254,17 @@ public class CipherInfo implements Comparable { return suiteName.compareTo(o.suiteName); } + static String[] cipherRanking = null; + public static String[] getCompleteRanking() { if (cipherRanking == null) { - String[] ciphers = filterCiphers((Iterable) cig.names - .keySet()); + String[] ciphers = filterCiphers((Iterable) cig.names.keySet()); cipherRanking = ciphers; } return cipherRanking; } + private static String[] filterCiphers(Iterable toFilter) { TreeSet chosenCiphers = new TreeSet(); for (String o : toFilter) { @@ -282,6 +283,7 @@ public class CipherInfo implements Comparable { } return ciphers; } + public static String[] filter(String[] supportedCipherSuites) { return filterCiphers(Arrays.asList(supportedCipherSuites)); }