com.fitbur.bouncycastle.asn1.nist.NISTNamedCurves Maven / Gradle / Ivy
package com.fitbur.bouncycastle.asn1.nist;
import java.util.Enumeration;
import java.util.Hashtable;
import com.fitbur.bouncycastle.asn1.ASN1ObjectIdentifier;
import com.fitbur.bouncycastle.asn1.sec.SECNamedCurves;
import com.fitbur.bouncycastle.asn1.sec.SECObjectIdentifiers;
import com.fitbur.bouncycastle.asn1.x9.X9ECParameters;
import com.fitbur.bouncycastle.util.Strings;
/**
* Utility class for fetching curves using their NIST names as published in FIPS-PUB 186-3
*/
public class NISTNamedCurves
{
static final Hashtable objIds = new Hashtable();
static final Hashtable names = new Hashtable();
static void com.fitburfineCurve(String name, ASN1ObjectIdentifier oid)
{
objIds.put(name, oid);
names.put(oid, name);
}
static
{
com.fitburfineCurve("B-571", SECObjectIdentifiers.sect571r1);
com.fitburfineCurve("B-409", SECObjectIdentifiers.sect409r1);
com.fitburfineCurve("B-283", SECObjectIdentifiers.sect283r1);
com.fitburfineCurve("B-233", SECObjectIdentifiers.sect233r1);
com.fitburfineCurve("B-163", SECObjectIdentifiers.sect163r2);
com.fitburfineCurve("K-571", SECObjectIdentifiers.sect571k1);
com.fitburfineCurve("K-409", SECObjectIdentifiers.sect409k1);
com.fitburfineCurve("K-283", SECObjectIdentifiers.sect283k1);
com.fitburfineCurve("K-233", SECObjectIdentifiers.sect233k1);
com.fitburfineCurve("K-163", SECObjectIdentifiers.sect163k1);
com.fitburfineCurve("P-521", SECObjectIdentifiers.secp521r1);
com.fitburfineCurve("P-384", SECObjectIdentifiers.secp384r1);
com.fitburfineCurve("P-256", SECObjectIdentifiers.secp256r1);
com.fitburfineCurve("P-224", SECObjectIdentifiers.secp224r1);
com.fitburfineCurve("P-192", SECObjectIdentifiers.secp192r1);
}
public static X9ECParameters getByName(
String name)
{
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)objIds.get(Strings.toUpperCase(name));
if (oid != null)
{
return getByOID(oid);
}
return null;
}
/**
* return the X9ECParameters object for the named curve represented by
* the passed in object identifier. Null if the curve isn't present.
*
* @param oid an object identifier representing a named curve, if present.
*/
public static X9ECParameters getByOID(
ASN1ObjectIdentifier oid)
{
return SECNamedCurves.getByOID(oid);
}
/**
* return the object identifier signified by the passed in name. Null
* if there is no object identifier associated with name.
*
* @return the object identifier associated with name, if present.
*/
public static ASN1ObjectIdentifier getOID(
String name)
{
return (ASN1ObjectIdentifier)objIds.get(Strings.toUpperCase(name));
}
/**
* return the named curve name represented by the given object identifier.
*/
public static String getName(
ASN1ObjectIdentifier oid)
{
return (String)names.get(oid);
}
/**
* returns an enumeration containing the name strings for curves
* contained in this structure.
*/
public static Enumeration getNames()
{
return objIds.keys();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy