diff options
author | Sam Whited <sam@samwhited.com> | 2015-01-14 12:20:02 -0500 |
---|---|---|
committer | Sam Whited <sam@samwhited.com> | 2015-01-14 13:10:15 -0500 |
commit | 548a585b2c4af9b4c2a98faabb8855fcb260daf2 (patch) | |
tree | afde87c24c6e0d543b30e77c5d347b60e5a45515 /src/main/java/eu/siacs/conversations/utils | |
parent | a88824bb1d40f1373b22639815ed673c134f6777 (diff) |
Harden the TLS connection cipher suites
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/CryptoHelper.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java index 7a36e2ba..48b0cdf3 100644 --- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java @@ -2,12 +2,17 @@ package eu.siacs.conversations.utils; import java.security.SecureRandom; import java.text.Normalizer; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; -public class CryptoHelper { +import eu.siacs.conversations.Config; + +public final class CryptoHelper { public static final String FILETRANSFER = "?FILETRANSFERv1:"; - final protected static char[] hexArray = "0123456789abcdef".toCharArray(); - final protected static char[] vowels = "aeiou".toCharArray(); - final protected static char[] consonants = "bcdfghjklmnpqrstvwxyz".toCharArray(); + private final static char[] hexArray = "0123456789abcdef".toCharArray(); + private final static char[] vowels = "aeiou".toCharArray(); + private final static char[] consonants = "bcdfghjklmnpqrstvwxyz".toCharArray(); final public static byte[] ONE = new byte[] { 0, 0, 0, 1 }; public static String bytesToHex(byte[] bytes) { @@ -45,7 +50,7 @@ public class CryptoHelper { return randomWord(3, random) + "." + randomWord(7, random); } - protected static String randomWord(int lenght, SecureRandom random) { + private static String randomWord(int lenght, SecureRandom random) { StringBuilder builder = new StringBuilder(lenght); for (int i = 0; i < lenght; ++i) { if (i % 2 == 0) { @@ -91,4 +96,10 @@ public class CryptoHelper { builder.insert(35, " "); return builder.toString(); } + + public static String[] getSupportedCipherSuites(final String[] platformSupportedCipherSuites) { + final Collection<String> cipherSuites = new LinkedHashSet<>(Arrays.asList(Config.ENABLED_CIPHERS)); + cipherSuites.retainAll(Arrays.asList(platformSupportedCipherSuites)); + return cipherSuites.toArray(new String[cipherSuites.size()]); + } } |