org.bouncycastle.jcajce.provider.ECUtil 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.provider;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPoint;
import org.bouncycastle.crypto.asymmetric.ECDomainParameters;
import org.bouncycastle.crypto.asymmetric.ECImplicitDomainParameters;
import org.bouncycastle.jcajce.spec.ECDomainParameterSpec;
import org.bouncycastle.jcajce.spec.ECImplicitDomainParameterSpec;
import org.bouncycastle.math.ec.ECCurve;
class ECUtil
{
public static ECParameterSpec convertToSpec(
ECDomainParameters domainParameters)
{
if (domainParameters instanceof ECImplicitDomainParameters)
{
return new ECImplicitDomainParameterSpec((ECImplicitDomainParameters)domainParameters);
}
return new ECDomainParameterSpec(domainParameters);
}
public static ECDomainParameters convertFromSpec(
ECParameterSpec ecSpec)
{
ECDomainParameters domainParameters;
if (ecSpec instanceof ECDomainParameterSpec)
{
domainParameters = ((ECDomainParameterSpec)ecSpec).getDomainParameters();
}
else
{
domainParameters = new ECDomainParameterSpec(ecSpec).getDomainParameters();
}
if (ecSpec instanceof ECImplicitDomainParameterSpec)
{
return new ECImplicitDomainParameters(domainParameters);
}
return domainParameters;
}
public static org.bouncycastle.math.ec.ECPoint convertPoint(
ECParameterSpec ecSpec,
ECPoint point)
{
return convertPoint(convertFromSpec(ecSpec).getCurve(), point);
}
public static org.bouncycastle.math.ec.ECPoint convertPoint(
ECCurve curve,
ECPoint point)
{
return curve.validatePoint(point.getAffineX(), point.getAffineY());
}
}