01: package org.bouncycastle.jce;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.DERObjectIdentifier;
06: import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
07: import org.bouncycastle.crypto.params.ECDomainParameters;
08: import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
09:
10: /**
11: * a table of locally supported named curves.
12: */
13: public class ECGOST3410NamedCurveTable {
14: /**
15: * return a parameter spec representing the passed in named
16: * curve. The routine returns null if the curve is not present.
17: *
18: * @param name the name of the curve requested
19: * @return a parameter spec for the curve, null if it is not available.
20: */
21: public static ECNamedCurveParameterSpec getParameterSpec(String name) {
22: ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(name);
23: if (ecP == null) {
24: try {
25: ecP = ECGOST3410NamedCurves
26: .getByOID(new DERObjectIdentifier(name));
27: } catch (IllegalArgumentException e) {
28: return null; // not an oid.
29: }
30: }
31:
32: if (ecP == null) {
33: return null;
34: }
35:
36: return new ECNamedCurveParameterSpec(name, ecP.getCurve(), ecP
37: .getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
38: }
39:
40: /**
41: * return an enumeration of the names of the available curves.
42: *
43: * @return an enumeration of the names of the available curves.
44: */
45: public static Enumeration getNames() {
46: return ECGOST3410NamedCurves.getNames();
47: }
48: }
|