public class SupportedEllipticCurves extends Extension implements java.lang.Cloneable
SupportedEllipticCurves
(elliptic_curves) TLS extension as specified by RFC 4492, 8422.
Note that RFC 7919, RFC 8446 replace the
A
RFC 4492 also specified
On the server side this constructor may be used to indicate
support for the SupportedEllipticCurves
(elliptic_curves) extension by the SupportedGroups
(supported_groups) extension to extend it about support for
finite field based Diffie-Hellman (DH) key exchange. Although this
SupportedEllipticCurves
class can still be used for backwards
compatibility to former iSaSiLk versions it is recommended to use
the
SupportedGroups
implementation instead of it.
SupportedEllipticCurves
extension might be sent
by the client within an extended ClientHello
message
to tell the server which curves are supported by the client when
using an ECC based cipher suite. The server uses the information
sent by the client to select an ECC cipher suite in accordance with
the elliptic curves supported by the client. The server itself does
not send a SupportedEllipticCurves
extension.
TLS defines the SupportedEllipticCurves
extension as
list of named elliptic curves (see RFC 4492):
enum {
sect163k1 (1), sect163r1 (2), sect163r2 (3),
sect193r1 (4), sect193r2 (5), sect233k1 (6),
sect233r1 (7), sect239k1 (8), sect283k1 (9),
sect283r1 (10), sect409k1 (11), sect409r1 (12),
sect571k1 (13), sect571r1 (14), secp160k1 (15),
secp160r1 (16), secp160r2 (17), secp192k1 (18),
secp192r1 (19), secp224k1 (20), secp224r1 (21),
secp256k1 (22), secp256r1 (23), secp384r1 (24),
secp521r1 (25),
reserved (0xFE00..0xFEFF),
arbitrary_explicit_prime_curves(0xFF01),
arbitrary_explicit_char2_curves(0xFF02),
(0xFFFF)
} NamedCurve;
struct {
NamedCurve elliptic_curve_list<1..2^16-1>
} EllipticCurveList;
The client shall send the list of supported elliptic curves in its preference order.
arbitrary explicit prime curves
and aArbitrary explicit char2 curves
, but they are
deprecated by RFC 8422 and therefore shall not be used anymore. RFC 8422 also deprecates
any named curve other than secp256r1 (23), secp384r1 (24), secp521r1 (25) from above and
adds support the x25519 and x448 curves:
enum {
deprecated(1..22),
secp256r1 (23), secp384r1 (24), secp521r1 (25),
x25519(29), x448(30),
reserved (0xFE00..0xFEFF),
deprecated(0xFF01..0xFF02),
(0xFFFF)
} NamedCurve;
In addition to the elliptic curves listed above, iSaSiLk supports the following
Brainpool curves from RFC 7027:
enum {
brainpoolP256r1(26),
brainpoolP384r1(27),
brainpoolP512r1(28)
} NamedCurve;
On the client side, when you create a SupportedEllipticCurves
extension object you may explicitly
specify the named curves 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 curves
NamedCurve[] ecList = { SupportedEllipticCurves.NC_PRIME_SECP192R1,
SupportedEllipticCurves.NC_PRIME_SECP256R1 };
// create SupportedEllipticCurves extension
SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves(ecList);
// add to ExtensionList
ExtensionList extensions = new ExtensionList();
...
extensions.addExtension(supportedEllipticCurves);
...
// set extensions for the SSLClientContext configuration:
SSLClientContext clientContext = new SSLClientContext();
...
clientContext.setExtensions(extensions);
...
Or you may use the default
constructor
which creates a SupportedEllipticCurves
extension containing
-- if cryptographically supported -- secp256r1
,
secp384r1
, secp521r1
and x25519
(in that order) as default elliptic
curve list:
// create SupportedEllipticCurves extension
SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves();
// add to ExtensionList
ExtensionList extensions = new ExtensionList();
...
extensions.addExtension(supportedEllipticCurves);
...
// set extensions for the SSLClientContext configuration:
SSLClientContext clientContext = new SSLClientContext();
...
clientContext.setExtensions(extensions);
...
The
flag of a client-side critical
SupportedEllipticCurves
extension does
not have any meaning because the server is not allowed to respond with
a SupportedEllipticCurves
extension.
SupportedEllipticCurves
extension
only (the server itself never sends a SupportedEllipticCurves
extension):
// create SupportedEllipticCurves extension
SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves();
// add to ExtensionList
ExtensionList extensions = new ExtensionList();
...
extensions.addExtension(supportedEllipticCurves);
...
// set extensions for the SSLServerContext configuration:
SSLServerContext serverContext = new SSLServerContext();
...
serverContext.setExtensions(extensions);
...
It is also possible to explicitly
specify the named curves to be supported on the server side. In this case the
server side curve list will be merged with the curve list received from the client.
When having specified to ignore
the
preference order of the client list the curves are merged in a way to prefer the
curve list order of the server. If no common curve can be found the client curve list
is taken, except for when having marked this extension as being
. In this case the
handshake will be aborted if client and server cannot agree on another (non-ECC) suite.
When using the critical
default
constructor to create the
a SupportedEllipticCurves extension on the server side the critical
flag
has no meaning.
Extension
,
ExtensionList
,
SupportedGroups
Modifier and Type | Class and Description |
---|---|
static class |
SupportedEllipticCurves.NamedCurve
TLS NamedCurve.
|
Modifier and Type | Field and Description |
---|---|
static SupportedEllipticCurves.NamedCurve |
NC_ARBITRARY_EXPLICIT_CHAR2
Deprecated.
shall not be used anymore according to RFC 8422
|
static SupportedEllipticCurves.NamedCurve |
NC_ARBITRARY_EXPLICIT_PRIME
Deprecated.
shall not be used anymore according to RFC 8422
|
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT163K1
Named binary curve
sect163k1 (NIST K-163 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT163R1
Named binary curve
sect163r1 . |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT163R2
Named binary curve
sect163r2 (NIST B-163 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT193R1
Named binary curve
sect193r1 . |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT193R2
Named binary curve
sect193r2 . |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT233K1
Named binary curve
sect233k1 (NIST K-233 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT233R1
Named binary curve
sect233r1 (NIST B-233 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT239K1
Named binary curve
sect239k1 . |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT283K1
Named binary curve
sect283k1 (NIST K-283 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT283R1
Named binary curve
sect283r1 (NIST B-283 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT409K1
Named binary curve
sect409k1 (NIST K-409 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT409R1
Named binary curve
sect409r1 (NIST B-409 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT571K1
Named binary curve
sect571k1 (NIST K-571 ). |
static SupportedEllipticCurves.NamedCurve |
NC_CHAR2_SECT571R1
Named binary curve
sect571r1 (NIST B-571 ). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_BRAINPOOLP256R1
Named prime Brainpool curve
brainpoolP256r1 (RFC 7027). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_BRAINPOOLP384R1
Named prime Brainpool curve
brainpoolP384r1 (RFC 7027). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_BRAINPOOLP512R1
Named prime Brainpool curve
brainpoolP521r1 (RFC 7027). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP160K1
Named prime curve
secp160k1 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP160R1
Named prime curve
secp160r1 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP160R2
Named prime curve
secp160r2 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP192K1
Named prime curve
secp192k1 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP192R1
Named prime curve
secp192r1 (NIST P-192 , ANSI X9.62 prime192v1 ). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP224K1
Named prime curve
secp224k1 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP224R1
Named prime curve
secp224r1 (NIST P-224 ). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP256K1
Named prime curve
secp256k1 . |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP256R1
Named prime curve
secp256r1 (NIST P-256 , ANSI X9.62 prime256v1 ). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP384R1
Named prime curve
secp384r1 (NIST P-384 ). |
static SupportedEllipticCurves.NamedCurve |
NC_PRIME_SECP521R1
Named prime curve
secp521r1 (NIST P-521 ). |
static SupportedEllipticCurves.NamedCurve |
NC_X25519
Named prime curve
x25519 (RFC 7748 ). |
static SupportedEllipticCurves.NamedCurve |
NC_X448
Named prime curve
x448 (RFC 7748 ). |
static ExtensionType |
TYPE
The type (10) of the elliptic_curves extension.
|
Constructor and Description |
---|
SupportedEllipticCurves()
Default Constructor.
|
SupportedEllipticCurves(SupportedEllipticCurves.NamedCurve[] ellipticCurveList)
Creates a SupportedEllipticCurves extension from the given elliptic
curve list.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this SupportedEllipticCurves extension object.
|
static SupportedEllipticCurves.NamedCurve[] |
getAllRegisteredNamedCurves()
Gets all registered named curves.
|
SupportedEllipticCurves.NamedCurve |
getCurve(int id)
Checks whether the elliptic curve with the given id is included in this
SupportedEllipticCurves extension.
|
SupportedEllipticCurves.NamedCurve[] |
getEllipticCurveList()
Gets the list of supported curves included in this SupportedEllipticCurves extension.
|
static SupportedEllipticCurves.NamedCurve |
getRegisteredCurveByID(int id)
Gets the registered NamedCurve with the given id.
|
static SupportedEllipticCurves.NamedCurve |
getRegisteredCurveByName(java.lang.String name)
Gets the registered NamedCurve with the given name.
|
static SupportedEllipticCurves.NamedCurve |
getRegisteredCurveByOID(java.lang.String oid)
Gets the registered NamedCurve with the given oid.
|
void |
setIgnorePeerPreferenceOrder(boolean ignore)
Whether to ignore the preference order of the curve list
sent by the peer (client) when selecting a curve for the current
session.
|
java.lang.String |
toString()
Gets a String representation of this SupportedEllipticCurves object.
|
getAllowedProtocolVersions, getExtensionType, getName, getType, setCritical
public static final ExtensionType TYPE
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT163K1
sect163k1
(NIST K-163
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT163R1
sect163r1
.
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT163R2
sect163r2
(NIST B-163
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT193R1
sect193r1
.
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT193R2
sect193r2
.
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT233K1
sect233k1
(NIST K-233
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT233R1
sect233r1
(NIST B-233
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT239K1
sect239k1
.
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT283K1
sect283k1
(NIST K-283
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT283R1
sect283r1
(NIST B-283
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT409K1
sect409k1
(NIST K-409
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT409R1
sect409r1
(NIST B-409
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT571K1
sect571k1
(NIST K-571
).
public static final SupportedEllipticCurves.NamedCurve NC_CHAR2_SECT571R1
sect571r1
(NIST B-571
).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP160K1
secp160k1
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP160R1
secp160r1
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP160R2
secp160r2
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP192K1
secp192k1
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP192R1
secp192r1
(NIST P-192
, ANSI X9.62 prime192v1
).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP224K1
secp224k1
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP224R1
secp224r1
(NIST P-224
).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP256K1
secp256k1
.
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP256R1
secp256r1
(NIST P-256
, ANSI X9.62 prime256v1
).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP384R1
secp384r1
(NIST P-384
).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_SECP521R1
secp521r1
(NIST P-521
).
public static final SupportedEllipticCurves.NamedCurve NC_X25519
x25519
(RFC 7748
).
public static final SupportedEllipticCurves.NamedCurve NC_X448
x448
(RFC 7748
).
public static final SupportedEllipticCurves.NamedCurve NC_ARBITRARY_EXPLICIT_PRIME
arbitrary_explicit_prime_curves
.
Indicates support for arbitrary prime curves (the curve parameters must be encoded
explicitly in ECParameters).
public static final SupportedEllipticCurves.NamedCurve NC_ARBITRARY_EXPLICIT_CHAR2
arbitrary_explicit_char2_curves
.
Indicates support for arbitrary characteristic-2 curves (the curve parameters
must be encoded explicitly in ECParameters).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_BRAINPOOLP256R1
brainpoolP256r1
(RFC 7027).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_BRAINPOOLP384R1
brainpoolP384r1
(RFC 7027).
public static final SupportedEllipticCurves.NamedCurve NC_PRIME_BRAINPOOLP512R1
brainpoolP521r1
(RFC 7027).
public SupportedEllipticCurves()
SupportedEllipticCurves
extension containing -- if cryptographically supported -- secp256r1
,
secp384r1
, secp521r1
and
x25519
(in that order) as default elliptic curve list.
// create SupportedEllipticCurves extension SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves(); // add to ExtensionList ExtensionList extensions = new ExtensionList(); ... extensions.addExtension(supportedEllipticCurves); ... // 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
SupportedEllipticCurves
extension
only (the server itself never sends a SupportedEllipticCurves
extension):
// create SupportedEllipticCurves extension SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves(); // add to ExtensionList ExtensionList extensions = new ExtensionList(); ... extensions.addExtension(supportedEllipticCurves); ... // set extensions for the SSLServerContext configuration: SSLServerContext serverContext = new SSLServerContext(); ... serverContext.setExtensions(extensions); ...
public SupportedEllipticCurves(SupportedEllipticCurves.NamedCurve[] ellipticCurveList)
secp192r1
(NIST P-192)
and secp256r1
(NIST P-256) and prefers secp192r1
will configure the SSLClientContext with the following SupportedEllipticCurves
extension:
// the list of supported elliptic curves NamedCurve[] ecList = { SupportedEllipticCurves.NC_PRIME_SECP192R1, SupportedEllipticCurves.NC_PRIME_SECP256R1 }; // create SupportedEllipticCurves extension SupportedEllipticCurves supportedEllipticCurves = new SupportedEllipticCurves(ecList); // add to ExtensionList ExtensionList extensions = new ExtensionList(); ... extensions.addExtension(supportedEllipticCurves); ... // set extensions for the SSLClientContext configuration: SSLClientContext clientContext = new SSLClientContext(); ... clientContext.setExtensions(extensions); ...
ellipticCurveList
- the list of supported elliptic curves in preference order
(the ellipticCurveList
array is not cloned or copied by this method)java.lang.IllegalArgumentException
- if the curve list is empty or any of the given curves
is not supported by the installed cryptographic
providerspublic static final SupportedEllipticCurves.NamedCurve getRegisteredCurveByName(java.lang.String name)
name
- the name of the curvenull
if no
curve with the given name is registeredpublic static final SupportedEllipticCurves.NamedCurve getRegisteredCurveByOID(java.lang.String oid)
oid
- the oid of the curvenull
if no
curve with the given oid is registeredpublic static final SupportedEllipticCurves.NamedCurve getRegisteredCurveByID(int id)
id
- the id of the curvenull
if no
curve with the given id is registeredpublic static final SupportedEllipticCurves.NamedCurve[] getAllRegisteredNamedCurves()
public SupportedEllipticCurves.NamedCurve[] getEllipticCurveList()
null
or empty if no curves are included in the list
(the returned array is not cloned or copied by this method)public SupportedEllipticCurves.NamedCurve getCurve(int id)
id
- the TLS id of the curve to be checkednull
if the curve with the given id is not includedpublic void setIgnorePeerPreferenceOrder(boolean ignore)
ignore
- whether to ignore the peer (client) curve list preference
order when selecting the curve for the current
sessionpublic java.lang.Object clone()