/** * return a X9ECParameters object representing the passed in named * curve. The routine returns null if the curve is not present. * * @param name the name of the curve requested * @return an X9ECParameters object or null if the curve is not available. */ public static X9ECParameters getByName( String name) { X9ECParameters ecP = X962NamedCurves.getByName(name); if (ecP == null) { ecP = SECNamedCurves.getByName(name); } if (ecP == null) { ecP = TeleTrusTNamedCurves.getByName(name); } if (ecP == null) { ecP = NISTNamedCurves.getByName(name); } return ecP; }
public static ASN1ObjectIdentifier getNamedCurveOid( String name) { ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name); if (oid == null) { oid = SECNamedCurves.getOID(name); if (oid == null) { oid = NISTNamedCurves.getOID(name); } if (oid == null) { oid = TeleTrusTNamedCurves.getOID(name); } if (oid == null) { oid = ECGOST3410NamedCurves.getOID(name); } } return oid; }
public static X9ECParameters getNamedCurveByOid( ASN1ObjectIdentifier oid) { X9ECParameters params = X962NamedCurves.getByOID(oid); if (params == null) { params = SECNamedCurves.getByOID(oid); if (params == null) { params = NISTNamedCurves.getByOID(oid); } if (params == null) { params = TeleTrusTNamedCurves.getByOID(oid); } } return params; }
public static String getCurveName( ASN1ObjectIdentifier oid) { String name = X962NamedCurves.getName(oid); if (name == null) { name = SECNamedCurves.getName(oid); if (name == null) { name = NISTNamedCurves.getName(oid); } if (name == null) { name = TeleTrusTNamedCurves.getName(oid); } if (name == null) { name = ECGOST3410NamedCurves.getName(oid); } } return name; }
public static X9ECParameters getNamedCurveByOid( ASN1ObjectIdentifier oid) { X9ECParameters params = CustomNamedCurves.getByOID(oid); if (params == null) { params = X962NamedCurves.getByOID(oid); if (params == null) { params = SECNamedCurves.getByOID(oid); } if (params == null) { params = NISTNamedCurves.getByOID(oid); } if (params == null) { params = TeleTrusTNamedCurves.getByOID(oid); } } return params; }
public static X9ECParameters getNamedCurveByName( String curveName) { X9ECParameters params = CustomNamedCurves.getByName(curveName); if (params == null) { params = X962NamedCurves.getByName(curveName); if (params == null) { params = SECNamedCurves.getByName(curveName); } if (params == null) { params = NISTNamedCurves.getByName(curveName); } if (params == null) { params = TeleTrusTNamedCurves.getByName(curveName); } } return params; }
/** * 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) { ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name); if (oid == null) { oid = SECNamedCurves.getOID(name); } if (oid == null) { oid = TeleTrusTNamedCurves.getOID(name); } if (oid == null) { oid = NISTNamedCurves.getOID(name); } return oid; }
@Test public void curveTest() { final X9ECParameters curve = NISTNamedCurves.getByName("P-384"); final ECDomainParameters domainParameters = new ECDomainParameters( curve.getCurve(), curve.getG(), curve.getN()); final SecureRandom random = new SecureRandom(); final ECKeyPairGenerator gen = new ECKeyPairGenerator(); gen.init(new ECKeyGenerationParameters(domainParameters, random)); final AsymmetricCipherKeyPair senderPair = gen.generateKeyPair(); final AsymmetricCipherKeyPair receiverPair = gen.generateKeyPair(); final ECDHBasicAgreement senderAgreement = new ECDHBasicAgreement(); senderAgreement.init(senderPair.getPrivate()); final BigInteger senderResult = senderAgreement.calculateAgreement( receiverPair.getPublic()); final ECDHBasicAgreement receiverAgreement = new ECDHBasicAgreement(); receiverAgreement.init(receiverPair.getPrivate()); final BigInteger receiverResult = receiverAgreement.calculateAgreement( senderPair.getPublic()); assertEquals(senderResult, receiverResult); //System.out.println(receiverResult); }
@Test public void curveTest() { final X9ECParameters curve = NISTNamedCurves.getByName("P-384"); final ECDomainParameters domainParameters = new ECDomainParameters( curve.getCurve(), curve.getG(), curve.getN()); final SecureRandom random = new SecureRandom(); final ECKeyPairGenerator gen = new ECKeyPairGenerator(); gen.init(new ECKeyGenerationParameters(domainParameters, random)); final AsymmetricCipherKeyPair senderPair = gen.generateKeyPair(); final ECDSASigner signer = new ECDSASigner(); signer.init(true, senderPair.getPrivate()); final byte[] message = "The magic words are squeamish ossifrage".getBytes( Constants.ASCII); final SHA384Digest digester = new SHA384Digest(); digester.update(message, 0, message.length); final byte[] digest = new byte[digester.getDigestSize()]; digester.doFinal(digest, 0); final BigInteger[] signature = signer.generateSignature(digest); final ECDSASigner verifier = new ECDSASigner(); verifier.init(false, senderPair.getPublic()); assertTrue(verifier.verifySignature(digest, signature[0], signature[1])); }
/** * return an enumeration of the names of the available curves. * * @return an enumeration of the names of the available curves. */ public static Enumeration getNames() { Vector v = new Vector(); addEnumeration(v, X962NamedCurves.getNames()); addEnumeration(v, SECNamedCurves.getNames()); addEnumeration(v, NISTNamedCurves.getNames()); addEnumeration(v, TeleTrusTNamedCurves.getNames()); return v.elements(); }
/** * return a X9ECParameters object representing the passed in named * curve. The routine returns null if the curve is not present. * * @param name the name of the curve requested * @return an X9ECParameters object or null if the curve is not available. */ public static X9ECParameters getByName( String name) { X9ECParameters ecP = X962NamedCurves.getByName(name); if (ecP == null) { ecP = SECNamedCurves.getByName(name); } if (ecP == null) { ecP = NISTNamedCurves.getByName(name); } if (ecP == null) { ecP = TeleTrusTNamedCurves.getByName(name); } if (ecP == null) { ecP = ANSSINamedCurves.getByName(name); } return ecP; }
/** * 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) { ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name); if (oid == null) { oid = SECNamedCurves.getOID(name); } if (oid == null) { oid = NISTNamedCurves.getOID(name); } if (oid == null) { oid = TeleTrusTNamedCurves.getOID(name); } if (oid == null) { oid = ANSSINamedCurves.getOID(name); } return oid; }
/** * return a X9ECParameters object representing the passed in named * curve. * * @param oid the object id of the curve requested * @return a standard name for the curve. */ public static String getName( ASN1ObjectIdentifier oid) { String name = NISTNamedCurves.getName(oid); if (name == null) { name = SECNamedCurves.getName(oid); } if (name == null) { name = TeleTrusTNamedCurves.getName(oid); } if (name == null) { name = X962NamedCurves.getName(oid); } if (name == null) { name = ECGOST3410NamedCurves.getName(oid); } return name; }
/** * return an enumeration of the names of the available curves. * * @return an enumeration of the names of the available curves. */ public static Enumeration getNames() { Vector v = new Vector(); addEnumeration(v, X962NamedCurves.getNames()); addEnumeration(v, SECNamedCurves.getNames()); addEnumeration(v, NISTNamedCurves.getNames()); addEnumeration(v, TeleTrusTNamedCurves.getNames()); addEnumeration(v, ANSSINamedCurves.getNames()); return v.elements(); }
private static ASN1ObjectIdentifier lookupOidByName(String name) { ASN1ObjectIdentifier oid = X962NamedCurves.getOID(name); if (oid == null) { oid = SECNamedCurves.getOID(name); if (oid == null) { oid = NISTNamedCurves.getOID(name); } if (oid == null) { oid = TeleTrusTNamedCurves.getOID(name); } if (oid == null) { oid = ECGOST3410NamedCurves.getOID(name); } if (oid == null) { oid = ANSSINamedCurves.getOID(name); } } return oid; }