org.bouncycastle.jcajce.spec.ECDomainParameterSpec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips Show documentation
Show all versions of bc-fips Show documentation
The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.
package org.bouncycastle.jcajce.spec;
import java.security.spec.ECParameterSpec;
import org.bouncycastle.crypto.asymmetric.ECDomainParameters;
import org.bouncycastle.crypto.asymmetric.NamedECDomainParameters;
/**
* Extension class for ECParameterSpec that wraps a ECDomainParameters object or an ECParameterSpec
*/
public class ECDomainParameterSpec
extends ECParameterSpec
{
private ECDomainParameters parameters;
/**
* Base constructor - wrap an ECDomainParameters.
*
* @param parameters the EC domain parameters to be wrapped.
*/
public ECDomainParameterSpec(
ECDomainParameters parameters)
{
this(parameters, ECUtil.convertToSpec(parameters));
}
/**
* Conversion constructor - wrap an ECParameterSpec
*
* @param parameterSpec the EC domain parameter spec to be wrapped.
*/
public ECDomainParameterSpec(
ECParameterSpec parameterSpec)
{
this(ECUtil.convertFromSpec(parameterSpec), parameterSpec);
}
/**
* Return the ECDomainParameters object we carry.
*
* @return the internal ECDomainParameters.
*/
public ECDomainParameters getDomainParameters()
{
return parameters;
}
private ECDomainParameterSpec(ECDomainParameters parameters, ECParameterSpec ecParameterSpec)
{
super(ecParameterSpec.getCurve(), ecParameterSpec.getGenerator(), ecParameterSpec.getOrder(), ecParameterSpec.getCofactor());
this.parameters = parameters;
}
public boolean equals(Object o)
{
if (o instanceof ECDomainParameterSpec)
{
ECDomainParameterSpec other = (ECDomainParameterSpec)o;
return this.parameters.equals(other.parameters);
}
return false;
}
public int hashCode()
{
return this.parameters.hashCode();
}
public String toString()
{
if (this.parameters instanceof NamedECDomainParameters)
{
return ((NamedECDomainParameters)this.parameters).getID().getId();
}
else
{
return super.toString();
}
}
}