public final class ECParameters extends AlgorithmParametersSpi
AlgorithmParameters.getInstance(String) methods.
Subsequently the new AlgorithmParameters object must be
initialized with a proper ECC parameter specification or a DER encoded byte
array, e.g.:
ECParameterSpec ecParamSpec = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("EC", "IAIK ECCelerate");
params.init(ecParamSpec);
respectively:
byte[] encodedECParams = ...;
AlgorithmParameters params = AlgorithmParameters.getInstance("EC", "IAIK ECCelerate");
params.init(encodedECParams);
For obtaining EC parameters in transparent representation from an opaque
ECParameterSpec object, the
AlgorithmParameters.getParameterSpec(Class) method can
be used; for obtaining the parameters as DER encoded ASN.1 object, use method
AlgorithmParameters.getEncoded():
ECParameterSpec ecParamSpec = (ECParameterSpec) params.getParameterSpec(ECParameterSpec.class);respectively
byte[] encodedECParams = params.getEncoded();
ECParameterSpec,
ECStandardizedParameterFactory,
AlgorithmParameters| Constructor and Description |
|---|
ECParameters()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineGetEncoded()
Returns the parameters as DER byte array.
|
protected byte[] |
engineGetEncoded(String format)
Returns the parameters as a DER byte array.
|
protected <T extends AlgorithmParameterSpec> |
engineGetParameterSpec(Class<T> paramSpec)
Returns the EC parameters as transparent parameter specification of the
given class type.
|
protected void |
engineInit(AlgorithmParameterSpec paramSpec)
Initializes this ECAlgorithmParameters from the given
ECParameterSpec. |
protected void |
engineInit(byte[] params)
Initializes this
ECParameters object from the given DER encoded
byte array. |
protected void |
engineInit(byte[] params,
String format)
Inits the parameters from an DER encoded byte array.
|
protected String |
engineToString()
Returns a String representation of this object.
|
static void |
setSetCurveNameForECGenParameterSpec(boolean setName)
Decides whether to set the curve name (instead of the OID String)
for the ECGenParameterSpec returned when calling
ecParameters.getParameterSpec(ECGenParameterSpec.class);. |
iaik.asn1.ASN1Object |
toASN1Object()
Gets an ASN.1 representation of this ECC algorithm parameters.
|
public static void setSetCurveNameForECGenParameterSpec(boolean setName)
ecParameters.getParameterSpec(ECGenParameterSpec.class);.
When creating an ECGenParameterSpec from ECParameters the ECGenParameterSpec
either may contain the standard name or the OID String of the curve
the parameters belong to. Up to version 6.01 ECCelerate tried to
generate an ECGenParameterSpec containing the curve name (if available).
However, since JSSE expects that the ECGenParameterSpec does contain the
OID String (rather than the curve name) method engineGetParameterSpec(Class)
engineGetParameterSpec(ECGenParameterSpec.class) now returns
an ECGenParameterSpec with the OID String. Otherwise the handshake may
fail (JDK 11.0.7) or ecdsa_sha1 may be used instead of ecdsa_secp256r1_sha256,
ecdsa_secp384r1_sha384 or ecdsa_secp521r1_sha512. If you want to get
an ECGenParameterSpec containing the curve name you may call
setSetCurveNameForECGenParameterSpec(true);:
ECParameters.setSetCurveNameForECGenParameterSpec(true);
...
ECParameterSpec ecParamSpec = ...;
AlgorithmParameters ecParams = AlgorithmParameters.getInstance("EC");
parameters.init(ecParamSpec);
ECGenParameterSpec ecGenSpec = .getParameterSpec(ECGenParameterSpec.class);
String curveName = ecGenSpec.getName();
Alternatively (if there is no need for provide independence) you may use the
ECParameterSpec ecParamSpec = ...; String curveName = ECStandardizedParameterFactory.getName(ecParamSpec);
setName - whether engineGetParameterSpec(Class)
shall return an ECGenParameterSpec with the curve name
or the curve oid string (default)protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
ECParameterSpec.engineInit in class AlgorithmParametersSpiparamSpec - the parameter specification, which has to be a
ECParameterSpecInvalidParameterSpecException - if the given parameter specification is not a or is an invalid
ECParameterSpecprotected void engineInit(byte[] params)
throws IOException
ECParameters object from the given DER encoded
byte array.engineInit in class AlgorithmParametersSpiparams - the DER encoded byte arrayIOException - if an error occurs when decoding the given byte arrayprotected void engineInit(byte[] params,
String format)
throws IOException
engineInit(byte[]) for initializing this
ECCAlgorithmParameters object from the given DER encoded byte array,
regardless of what is specified in the format string.
engineInit in class AlgorithmParametersSpiparams - the DER encoded byte arrayformat - the encoding format; ignoredIOException - if an error occurs when decoding the given byte arrayprotected <T extends AlgorithmParameterSpec> T engineGetParameterSpec(Class<T> paramSpec) throws InvalidParameterSpecException
engineGetParameterSpec in class AlgorithmParametersSpiparamSpec - the desired parameter specification class (ECParameterSpec
)ECParameterSpecInvalidParameterSpecException - if the parameters cannot be converted to the desired parameter
specificationprotected byte[] engineGetEncoded()
throws IOException
engineGetEncoded in class AlgorithmParametersSpiIOException - if an encoding error occursprotected byte[] engineGetEncoded(String format) throws IOException
Format is ignored. Only DER encoding is supported. This method only calls
engineGetEncoded(), regardless of what is
specified in the format string.
engineGetEncoded in class AlgorithmParametersSpiformat - the encoding format; ignoredIOException - if an encoding error occursprotected String engineToString()
engineToString in class AlgorithmParametersSpipublic iaik.asn1.ASN1Object toASN1Object()
ASN1ObjectCopyright © 2011–2022 Stiftung SIC. All rights reserved.