iaik.security.ssl
Class SupportedGroups

java.lang.Object
  extended by iaik.security.ssl.Extension
      extended by iaik.security.ssl.SupportedEllipticCurves
          extended by iaik.security.ssl.SupportedGroups
All Implemented Interfaces:
java.lang.Cloneable

public class SupportedGroups
extends SupportedEllipticCurves
implements java.lang.Cloneable

This class implements the SupportedGroups (supported_groups) TLS extension as specified by RFC 7919, RFC 8446.

The SupportedGroups (supported_groups) extension replaces the SupportedEllipticCurves (elliptic_curves) extension to extend it about support for finite field based Diffie-Hellman (DH) key exchange. Although the [@link SupportedEllipticCurves SupportedEllipticCurves} class can still be used for backwards compatibility to former iSaSiLk versions it is recommended to use this SupportedGroups implementation instead of it.

A SupportedGroups extension might be sent by the client within an extended ClientHello message to tell the server which groups are supported by the client when using an ECDHE or DHE based cipher suite. The server uses the information sent by the client to select an ECC/DHE cipher suite in accordance with the ECDHE/FFDHE groups supported by the client. The server itself generally does not send a SupportedGroups extension.
TLS defines the SupportedGroups extension as list of named groups (see RFC 7919):

 enum {

      Elliptic Curve Groups (ECDHE) 
      secp256r1(0x0017), secp384r1(0x0018), secp521r1(0x0019),
      x25519(0x001D), x448(0x001E),

      // Finite Field Groups (DHE) 
      ffdhe2048(0x0100), ffdhe3072(0x0101), ffdhe4096(0x0102),
      ffdhe6144(0x0103), ffdhe8192(0x0104),

      // Reserved Code Points 
      ffdhe_private_use(0x01FC..0x01FF),
      ecdhe_private_use(0xFE00..0xFEFF),
      (0xFFFF)
 } NamedGroup;

 struct {
     NamedGroup named_group_list<2..2^16-1>;
 } NamedGroupList;
 
The client shall send the list of supported groups in its preference order.

In addition to the elliptic groups listed above, iSaSiLk supports the following Brainpool groups from RFC 7027:

      enum {
           brainpoolP256r1(26),
           brainpoolP384r1(27),
           brainpoolP512r1(28)
      } NamedGroup;
 

On the client side, when you create a SupportedGroups extension object you may explicitly specify the named groups to be included in preference order, e.g. (if you want to use secp192r1 (NIST P-192) and secp256r1 (NIST P-256) and prefer secp192r1):

 // the list of supported elliptic groups
 NamedGroup[] ecList = { SupportedGroups.NC_PRIME_SECP192R1,
                         SupportedGroups.NC_PRIME_SECP256R1 };
 // create SupportedGroups extension                                 
 SupportedGroups supportedGroups = new SupportedGroups(ecList);
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLClientContext configuration:
 SSLClientContext clientContext = new SSLClientContext();
 ...
 clientContext.setExtensions(extensions);
 ...
 
Or you may use the default constructor which creates a SupportedGroups extension containing -- if cryptographically supported -- secp256r1, secp384r1, secp521r1 and x25519 as default elliptic group list and ffdhe2048 and ffdhe3072 as default FFDHE group list (in that order):
 // create SupportedGroups extension
 SupportedGroups supportedGroups = new SupportedGroups();
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLClientContext configuration:
 SSLClientContext clientContext = new SSLClientContext();
 ...
 clientContext.setExtensions(extensions);
 ...
 
If the critical flag of a client-side SupportedGroups extension is set to true the handshake will be aborted with an insufficient_security alert if the server DHE key exchange message contains parameters (p, g) that do not comply with any of the FFDHE parameters offered in the ClientHello SupportedGroups extension.

On the server side the default constructor may be used to indicate support for the SupportedGroups extension (the server itself generally does not send a SupportedGroups extension):

 // create SupportedGroups extension
 SupportedGroups supportedGroups = new SupportedGroups();
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLServerContext configuration:
 SSLServerContext serverContext = new SSLServerContext();
 ...
 serverContext.setExtensions(extensions);
 ...
 
It is also possible to explicitly specify the named groups to be supported on the server side. In this case the server side group list will be merged with the group list received from the client. When having specified to ignore the preference order of the client list the groups are merged in a way to prefer the group list order of the server. If no common group can be found the client group list is taken, except for when having marked this extension as being critical. In this case the handshake will be aborted if client and server cannot agree on another (non-ECC/DHE) suite. When using the default constructor to create the a SupportedGroups extension on the server side the critical flag has no meaning.

Version:
File Revision 38
See Also:
Extension, ExtensionList

Nested Class Summary
static class SupportedGroups.NamedFFDHEGroup
          TLS NamedFFDHEGroup.
 
Nested classes/interfaces inherited from class iaik.security.ssl.SupportedEllipticCurves
SupportedEllipticCurves.NamedCurve
 
Field Summary
static SupportedGroups.NamedFFDHEGroup FFDHE_2048
          Named FFDHE group ffdhe2048 (RFC 7919).
static SupportedGroups.NamedFFDHEGroup FFDHE_3072
          Named FFDHE group ffdhe3072 (RFC 7919).
static SupportedGroups.NamedFFDHEGroup FFDHE_4096
          Named FFDHE group ffdhe4096 (RFC 7919).
static SupportedGroups.NamedFFDHEGroup FFDHE_6144
          Named FFDHE group ffdhe6144 (RFC 7919).
static SupportedGroups.NamedFFDHEGroup FFDHE_8192
          Named FFDHE group ffdhe8192 (RFC 7919).
 
Fields inherited from class iaik.security.ssl.SupportedEllipticCurves
NC_ARBITRARY_EXPLICIT_CHAR2, NC_ARBITRARY_EXPLICIT_PRIME, NC_CHAR2_SECT163K1, NC_CHAR2_SECT163R1, NC_CHAR2_SECT163R2, NC_CHAR2_SECT193R1, NC_CHAR2_SECT193R2, NC_CHAR2_SECT233K1, NC_CHAR2_SECT233R1, NC_CHAR2_SECT239K1, NC_CHAR2_SECT283K1, NC_CHAR2_SECT283R1, NC_CHAR2_SECT409K1, NC_CHAR2_SECT409R1, NC_CHAR2_SECT571K1, NC_CHAR2_SECT571R1, NC_PRIME_BRAINPOOLP256R1, NC_PRIME_BRAINPOOLP384R1, NC_PRIME_BRAINPOOLP512R1, NC_PRIME_SECP160K1, NC_PRIME_SECP160R1, NC_PRIME_SECP160R2, NC_PRIME_SECP192K1, NC_PRIME_SECP192R1, NC_PRIME_SECP224K1, NC_PRIME_SECP224R1, NC_PRIME_SECP256K1, NC_PRIME_SECP256R1, NC_PRIME_SECP384R1, NC_PRIME_SECP521R1, NC_X25519, NC_X448, TYPE
 
Constructor Summary
SupportedGroups()
          Default Constructor.
SupportedGroups(NamedGroup[] namedGroupList)
          Creates a SupportedGroups extension from the given group list.
SupportedGroups(NamedGroup[] namedGroupList, boolean autoRemoveNotSupportedGroups)
          Creates a SupportedGroups extension from the given group list.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this SupportedGroups extension object.
 NamedGroup getGroup(int id)
          Checks whether the group with the given id is included in this SupportedGroups extension.
 SupportedGroups.NamedFFDHEGroup[] getNamedFFDHEGroupList()
          Gets the list of FFDHE groups included in this SupportedGroups extension.
 NamedGroup[] getNamedGroupList()
          Gets the list of supported groups included in this SupportedGroups extension.
 java.lang.String toString()
          Gets a String representation of this SupportedGroups object.
 
Methods inherited from class iaik.security.ssl.SupportedEllipticCurves
getAllRegisteredNamedCurves, getCurve, getEllipticCurveList, getRegisteredCurveByID, getRegisteredCurveByName, getRegisteredCurveByOID, setIgnorePeerPreferenceOrder
 
Methods inherited from class iaik.security.ssl.Extension
getAllowedProtocolVersions, getExtensionType, getName, getType, setCritical
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FFDHE_2048

public static final SupportedGroups.NamedFFDHEGroup FFDHE_2048
Named FFDHE group ffdhe2048 (RFC 7919).


FFDHE_3072

public static final SupportedGroups.NamedFFDHEGroup FFDHE_3072
Named FFDHE group ffdhe3072 (RFC 7919).


FFDHE_4096

public static final SupportedGroups.NamedFFDHEGroup FFDHE_4096
Named FFDHE group ffdhe4096 (RFC 7919).


FFDHE_6144

public static final SupportedGroups.NamedFFDHEGroup FFDHE_6144
Named FFDHE group ffdhe6144 (RFC 7919).


FFDHE_8192

public static final SupportedGroups.NamedFFDHEGroup FFDHE_8192
Named FFDHE group ffdhe8192 (RFC 7919).

Constructor Detail

SupportedGroups

public SupportedGroups()
Default Constructor. Creates a new SupportedGroups extension containing -- if cryptographically supported -- secp256r1, secp384r1, secp521r1 and x25519as default elliptic group list and ffdhe2048 and ffdhe3072 as default FFDHE group list (in that order).
This constructor may be used on the client side if the client wants to use ECC or DHE cipher suites with any of the four elliptic groups secp256r1, secp384r1, secp521r1 or x25519 or finite field DHE groups ffdhe2048 or ffdhe3072:
 // create SupportedGroups extension
 SupportedGroups supportedGroups = new SupportedGroups();
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLClientContext configuration:
 SSLClientContext clientContext = new SSLClientContext();
 ...
 clientContext.setExtensions(extensions);
 ...
 
On the server side this constructor may be used to indicate support for the SupportedGroups extension only (the server itself does not send a SupportedGroups extension):
 // create SupportedGroups extension
 SupportedGroups supportedGroups = new SupportedGroups();
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLServerContext configuration:
 SSLServerContext serverContext = new SSLServerContext();
 ...
 serverContext.setExtensions(extensions);
 ...
 


SupportedGroups

public SupportedGroups(NamedGroup[] namedGroupList)
Creates a SupportedGroups extension from the given group list.
This constructor may be used on the client side to specify which groups the client wants to use with ECC/DHE based cipher suites. The groups shall be listed in preference order. For instance, a client that wants to use the secp192r1 (NIST P-192) and secp256r1 (NIST P-256) ECC groups and prefers secp192r1 will configure the SSLClientContext with the following SupportedGroups extension:
 // the list of supported elliptic groups
 NamedGroup[] ecList = { SupportedGroups.NC_PRIME_SECP192R1,
                         SupportedGroups.NC_PRIME_SECP256R1 };
 // create SupportedGroups extension                                 
 SupportedGroups supportedGroups = new SupportedGroups(ecList);
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLClientContext configuration:
 SSLClientContext clientContext = new SSLClientContext();
 ...
 clientContext.setExtensions(extensions);
 ...
 

Parameters:
namedGroupList - the list of supported groups in preference order (the namedGroupList array is not cloned or copied by this method)
Throws:
java.lang.IllegalArgumentException - if the group list is empty or any of the given groups is not supported by the installed cryptographic providers

SupportedGroups

public SupportedGroups(NamedGroup[] namedGroupList,
                       boolean autoRemoveNotSupportedGroups)
Creates a SupportedGroups extension from the given group list.
This constructor may be used on the client side to specify which groups the client wants to use with ECC/DHE based cipher suites. The groups shall be listed in preference order. For instance, a client that wants to use the secp192r1 (NIST P-192) and secp256r1 (NIST P-256) ECC groups and prefers secp192r1 will configure the SSLClientContext with the following SupportedGroups extension:
 // the list of supported elliptic groups
 NamedGroup[] ecList = { SupportedGroups.NC_PRIME_SECP192R1,
                         SupportedGroups.NC_PRIME_SECP256R1 };
 // create SupportedGroups extension                                 
 SupportedGroups supportedGroups = new SupportedGroups(ecList);
 // add to ExtensionList
 ExtensionList extensions = new ExtensionList();
 ...
 extensions.addExtension(supportedGroups);
 ...
 // set extensions for the SSLClientContext configuration:
 SSLClientContext clientContext = new SSLClientContext();
 ...
 clientContext.setExtensions(extensions);
 ...
 

Parameters:
namedGroupList - the list of supported groups in preference order (the namedGroupList array is not cloned or copied by this method)
autoRemoveNotSupportedGroups - whether to automatically remove any not supported group (default: false, if any of the provided groups is not supported an IllegalArgumentException is thrown)
Throws:
java.lang.IllegalArgumentException - if the group list is empty or
autoRemoveNotSupportedGroups is set to false (default) and any of the given groups is not supported by the installed cryptographic providers or none of the provided groups is supported
Method Detail

getNamedGroupList

public NamedGroup[] getNamedGroupList()
Gets the list of supported groups included in this SupportedGroups extension.

Returns:
the list of supported groups (in preference order) as array of NamedGroup objects; the array maybe null or empty if no groups are included in the list (the returned array is not cloned or copied by this method)

getNamedFFDHEGroupList

public SupportedGroups.NamedFFDHEGroup[] getNamedFFDHEGroupList()
Gets the list of FFDHE groups included in this SupportedGroups extension.

Returns:
the list of FFDHE groups (in preference order) as array of NamedFFDHEGroup objects; the array maybe null or empty if no FFDHE groups are included in the list (the returned array is not cloned or copied by this method)

getGroup

public NamedGroup getGroup(int id)
Checks whether the group with the given id is included in this SupportedGroups extension.

Parameters:
id - the TLS id of the group to be checked
Returns:
the NamedGroup with the given id if it is included, or null if the group with the given id is not included

clone

public java.lang.Object clone()
Returns a clone of this SupportedGroups extension object.

Overrides:
clone in class SupportedEllipticCurves
Returns:
a clone of this SupportedGroups extension object

toString

public java.lang.String toString()
Gets a String representation of this SupportedGroups object.

Overrides:
toString in class SupportedEllipticCurves
Returns:
a String representation of the SupportedGroups object

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

iSaSiLk 6.0, (c) 2002 IAIK, (c) 2003 - 2015 SIC