iaik.security.ssl
Class CipherSuiteList

java.lang.Object
  |
  +--iaik.security.ssl.CipherSuiteList

public class CipherSuiteList
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class implements a list of cipher suites to select the enabled cipher suites etc. Actually it is an ordered set and not a list, i.e. each elements can appear only once.

See Also:
Serialized Form

Field Summary
static int L_DEFAULT
          Selection constant for a list with the default ciphersuites.
static int L_IMPLEMENTED
          Selection constant for a list with all implemented ciphersuites.
static int L_NONE
          Selection constant for an empty list.
 
Constructor Summary
CipherSuiteList()
          Create an empty ciphersuite list.
CipherSuiteList(CipherSuite suite)
          Create a new ciphersuite list with the specified suite as its only element.
CipherSuiteList(CipherSuite[] suites)
          Create a new ciphersuite list from the contents of the given array.
CipherSuiteList(CipherSuiteList suites)
          Create a copy of the given ciphersuite list.
CipherSuiteList(int which)
          Create a new ciphersuite list with the contents determined by the selection value.
 
Method Summary
 void add(CipherSuite suite)
          Add a ciphersuite to the end of this list.
 void add(CipherSuite[] suites)
          Add all ciphersuite from an array to this list in order.
 void clear()
          Remove all elements from this list.
 java.lang.Object clone()
          Return a clone of this ciphersuite list.
 boolean contains(CipherSuite suite)
          Test if the given ciphersuite is an element of this list.
 CipherSuite elementAt(int i)
          Return the element at the given index.
 java.util.Enumeration elements()
          Return an Enumeration of the elements of this list.
 void ensureAvailable()
          Make sure this list only contains ciphersuites that can actually be used.
 void insertSorted(CipherSuite suite)
          Perform a sorted insertion of the given ciphersuite into this list.
 void insertSorted(CipherSuite[] suites)
          Perform a sorted insertion of the ciphersuites from the given array into this list.
 void intersectWith(CipherSuiteList other)
          Compute the intersection of this list and another list.
 void remove(CipherSuite suite)
          Remove a ciphersuite from this list.
 void remove(CipherSuite[] suites)
          Remove all ciphersuite from an array from this list.
 int size()
          Return the number of elements in this list.
 void sort()
          Sort the ciphersuites by strength.
 CipherSuite[] toArray()
          Convert this list to an array of ciphersuites.
 java.lang.String toString()
          Return a string representation of this list.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

L_NONE

public static final int L_NONE
Selection constant for an empty list.

L_DEFAULT

public static final int L_DEFAULT
Selection constant for a list with the default ciphersuites.

L_IMPLEMENTED

public static final int L_IMPLEMENTED
Selection constant for a list with all implemented ciphersuites.
Constructor Detail

CipherSuiteList

public CipherSuiteList()
Create an empty ciphersuite list.

CipherSuiteList

public CipherSuiteList(int which)
Create a new ciphersuite list with the contents determined by the selection value. It should be one of L_xxx values defined for this class. The resulting list will be sorted.

Note that ensureAvailable() is automatically called on the created list.


CipherSuiteList

public CipherSuiteList(CipherSuite suite)
Create a new ciphersuite list with the specified suite as its only element.

CipherSuiteList

public CipherSuiteList(CipherSuite[] suites)
Create a new ciphersuite list from the contents of the given array. If a ciphersuite occurs multiple times in the array only the first occurrence is used.

CipherSuiteList

public CipherSuiteList(CipherSuiteList suites)
Create a copy of the given ciphersuite list.
Method Detail

add

public void add(CipherSuite suite)
Add a ciphersuite to the end of this list. If it is already contained in the list the call is ignored.

remove

public void remove(CipherSuite suite)
Remove a ciphersuite from this list. If it is not contained in the list the call is ignored.

contains

public boolean contains(CipherSuite suite)
Test if the given ciphersuite is an element of this list.

add

public void add(CipherSuite[] suites)
Add all ciphersuite from an array to this list in order.

remove

public void remove(CipherSuite[] suites)
Remove all ciphersuite from an array from this list.

clear

public void clear()
Remove all elements from this list.

toArray

public CipherSuite[] toArray()
Convert this list to an array of ciphersuites.

size

public int size()
Return the number of elements in this list.

elementAt

public CipherSuite elementAt(int i)
                      throws java.lang.ArrayIndexOutOfBoundsException
Return the element at the given index. An ArrayIndexOutOfBoundsException is thrown if the index is invalid.

elements

public java.util.Enumeration elements()
Return an Enumeration of the elements of this list.

insertSorted

public void insertSorted(CipherSuite suite)
Perform a sorted insertion of the given ciphersuite into this list. This list must already be sorted according to the criteria given below. If the suite is already contained in this list the call is ignored.

Ciphersuites are sorted by cryptographic strength, the strongest come first. We define a ciphersuite to be stronger than another by the following ordered criteria.

  1. key length
  2. export key size limit
  3. MAC algorithm SHA over MD5
  4. RSA and DHE key exchange are prefered over DH with fixed parameters
  5. DH_anon and RSA_WITH_NULL are handled separately as they do not offer the full security of the other ciphersuites. All other ciphersuites are defined to be stronger than DH_anon except RSA_WITH_NULL which are weaker.
For ciphersuites that are equally strong by this definition the resulting ordering is undefined.

insertSorted

public void insertSorted(CipherSuite[] suites)
Perform a sorted insertion of the ciphersuites from the given array into this list. This list must already be sorted, they array need not.

sort

public void sort()
Sort the ciphersuites by strength. For the criteria see insertSorted().

ensureAvailable

public void ensureAvailable()
Make sure this list only contains ciphersuites that can actually be used. This method disables all ciphersuites for which CipherSuite.isAvailable() returns false.
See Also:
CipherSuite.isAvailable()

intersectWith

public void intersectWith(CipherSuiteList other)
Compute the intersection of this list and another list. This object is modified to only contain ciphersuites enabled in both this and other.

clone

public java.lang.Object clone()
Return a clone of this ciphersuite list.
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Return a string representation of this list.
Overrides:
toString in class java.lang.Object