org.bouncycastle.asn1.x9.X962Parameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk16 Show documentation
Show all versions of bcprov-jdk16 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. The package is organised
so that it contains a light-weight API suitable for use in any environment (including the newly released J2ME)
with the additional infrastructure to conform the algorithms to the JCE framework.
package org.bouncycastle.asn1.x9;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.DERObjectIdentifier;
public class X962Parameters
extends ASN1Encodable
implements ASN1Choice
{
private DERObject params = null;
public static X962Parameters getInstance(
Object obj)
{
if (obj == null || obj instanceof X962Parameters)
{
return (X962Parameters)obj;
}
if (obj instanceof DERObject)
{
return new X962Parameters((DERObject)obj);
}
throw new IllegalArgumentException("unknown object in getInstance()");
}
public static X962Parameters getInstance(
ASN1TaggedObject obj,
boolean explicit)
{
return getInstance(obj.getObject()); // must be explicitly tagged
}
public X962Parameters(
X9ECParameters ecParameters)
{
this.params = ecParameters.getDERObject();
}
public X962Parameters(
DERObjectIdentifier namedCurve)
{
this.params = namedCurve;
}
public X962Parameters(
DERObject obj)
{
this.params = obj;
}
public boolean isNamedCurve()
{
return (params instanceof DERObjectIdentifier);
}
public boolean isImplicitlyCA()
{
return (params instanceof ASN1Null);
}
public DERObject getParameters()
{
return params;
}
/**
* Produce an object suitable for an ASN1OutputStream.
*
* Parameters ::= CHOICE {
* ecParameters ECParameters,
* namedCurve CURVES.&id({CurveNames}),
* implicitlyCA NULL
* }
*
*/
public DERObject toASN1Object()
{
return params;
}
}