本文整理汇总了Java中org.bouncycastle.asn1.x9.ECNamedCurveTable类的典型用法代码示例。如果您正苦于以下问题:Java ECNamedCurveTable类的具体用法?Java ECNamedCurveTable怎么用?Java ECNamedCurveTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ECNamedCurveTable类属于org.bouncycastle.asn1.x9包,在下文中一共展示了ECNamedCurveTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParametersForNamedCurve
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
String curveName = getNameOfNamedCurve(namedCurve);
if (curveName == null)
{
return null;
}
// Parameters are lazily created the first time a particular curve is accessed
X9ECParameters ecP = CustomNamedCurves.getByName(curveName);
if (ecP == null)
{
ecP = ECNamedCurveTable.getByName(curveName);
if (ecP == null)
{
return null;
}
}
// It's a bit inefficient to do this conversion every time
return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
示例2: main
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
public static void main(String[] args)
{
SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames()));
names.addAll(enumToList(CustomNamedCurves.getNames()));
Iterator it = names.iterator();
while (it.hasNext())
{
String name = (String)it.next();
X9ECParameters x9 = CustomNamedCurves.getByName(name);
if (x9 == null)
{
x9 = ECNamedCurveTable.getByName(name);
}
if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve()))
{
System.out.print(name + ":");
implPrintNonZeroTraceBits(x9);
}
}
}
示例3: discoverEndomorphisms
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
private static void discoverEndomorphisms(String curveName)
{
X9ECParameters x9 = ECNamedCurveTable.getByName(curveName);
if (x9 == null)
{
System.err.println("Unknown curve: " + curveName);
return;
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve '" + curveName + "' has a 'GLV Type B' endomorphism with these parameters:");
printGLVTypeBParameters(x9);
}
}
}
示例4: main
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
public static void main(String[] args)
{
SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames()));
names.addAll(enumToList(CustomNamedCurves.getNames()));
Iterator it = names.iterator();
while (it.hasNext())
{
String name = (String)it.next();
X9ECParameters x9 = CustomNamedCurves.getByName(name);
if (x9 == null)
{
x9 = ECNamedCurveTable.getByName(name);
}
if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve()))
{
System.out.print(name + ":");
implPrintRootZ(x9);
}
}
}
示例5: engineInit
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
@Override
protected void engineInit(byte[] bytes, String format)
throws IOException
{
if (isASN1FormatString(format))
{
X962Parameters params = X962Parameters.getInstance(bytes);
ECCurve curve = EC5Util.getCurve(BouncyCastleProvider.CONFIGURATION, params);
if (params.isNamedCurve())
{
curveName = ECNamedCurveTable.getName(ASN1ObjectIdentifier.getInstance(params.getParameters()));
}
ecParameterSpec = EC5Util.convertToSpec(params, curve);
}
else
{
throw new IOException("Unknown encoded parameters format in AlgorithmParameters object: " + format);
}
}
示例6: getNamedCurveOid
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
public static ASN1ObjectIdentifier getNamedCurveOid(
ECParameterSpec ecParameterSpec)
{
for (Enumeration names = ECNamedCurveTable.getNames(); names.hasMoreElements();)
{
String name = (String)names.nextElement();
X9ECParameters params = ECNamedCurveTable.getByName(name);
if (params.getN().equals(ecParameterSpec.getN())
&& params.getH().equals(ecParameterSpec.getH())
&& params.getCurve().equals(ecParameterSpec.getCurve())
&& params.getG().equals(ecParameterSpec.getG()))
{
return org.bouncycastle.asn1.x9.ECNamedCurveTable.getOID(name);
}
}
return null;
}
示例7: discoverEndomorphism
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
private static void discoverEndomorphism(String curveName)
{
X9ECParameters x9 = ECNamedCurveTable.getByName(curveName);
if (x9 == null)
{
System.err.println("Unknown curve: " + curveName);
return;
}
ECCurve c = x9.getCurve();
if (ECAlgorithms.isFpCurve(c))
{
BigInteger characteristic = c.getField().getCharacteristic();
if (c.getA().isZero() && characteristic.mod(ECConstants.THREE).equals(ECConstants.ONE))
{
System.out.println("Curve '" + curveName + "' has a 'GLV Type B' endomorphism with these parameters: ");
printGLVTypeBParameters(x9);
}
}
}
示例8: create
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
private static RFC6637 create(
String curveName,
Supplier<Digest> digestFactory,
Supplier<Wrapper> wrapperFactory,
int publicKeyAlgID,
int symAlgID,
int symAlgIDLength,
int kdfHashID) {
try {
ASN1ObjectIdentifier oid = ECNamedCurveTable.getOID(curveName);
RFC6637KDF kdf = new RFC6637KDF(
digestFactory,
oid,
(byte) publicKeyAlgID,
(byte) symAlgID,
(byte) kdfHashID);
return new RFC6637(wrapperFactory, curveName, symAlgIDLength, kdf);
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
示例9: decodePoint
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
private static ECPoint decodePoint(
BigInteger encodedPoint,
ASN1ObjectIdentifier oid)
throws IOException
{
X9ECParameters curve = ECNamedCurveTable.getByOID(oid);
if (curve == null)
{
throw new IOException(oid.getId() + " does not match any known curve.");
}
if (!(curve.getCurve() instanceof ECCurve.Fp))
{
throw new IOException("Only FPCurves are supported.");
}
return curve.getCurve().decodePoint(encodedPoint.toByteArray());
}
示例10: getParametersForNamedCurve
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
String curveName = getNameOfNamedCurve(namedCurve);
if (curveName == null)
{
return null;
}
// Lazily created the first time a particular curve is accessed
X9ECParameters ecP = ECNamedCurveTable.getByName(curveName);
if (ecP == null)
{
return null;
}
// It's a bit inefficient to do this conversion every time
return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
示例11: getX9Parameters
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
static X9ECParameters getX9Parameters(ASN1ObjectIdentifier curveOID)
{
X9ECParameters x9 = CustomNamedCurves.getByOID(curveOID);
if (x9 == null)
{
x9 = ECNamedCurveTable.getByOID(curveOID);
}
return x9;
}
示例12: setSecurityLevel
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
/**
* Security Level determines the elliptic curve used in key generation
*
* @param securityLevel currently 256 or 384
* @throws InvalidArgumentException
*/
void setSecurityLevel(final int securityLevel) throws InvalidArgumentException {
logger.trace(format("setSecurityLevel to %d", securityLevel));
if (securityCurveMapping.isEmpty()) {
throw new InvalidArgumentException("Security curve mapping has no entries.");
}
if (!securityCurveMapping.containsKey(securityLevel)) {
StringBuilder sb = new StringBuilder();
String sp = "";
for (int x : securityCurveMapping.keySet()) {
sb.append(sp).append(x);
sp = ", ";
}
throw new InvalidArgumentException(format("Illegal security level: %d. Valid values are: %s", securityLevel, sb.toString()));
}
String lcurveName = securityCurveMapping.get(securityLevel);
logger.debug(format("Mapped curve strength %d to %s", securityLevel, lcurveName));
X9ECParameters params = ECNamedCurveTable.getByName(lcurveName);
//Check if can match curve name to requested strength.
if (params == null) {
InvalidArgumentException invalidArgumentException = new InvalidArgumentException(
format("Curve %s defined for security strength %d was not found.", curveName, securityLevel));
logger.error(invalidArgumentException);
throw invalidArgumentException;
}
curveName = lcurveName;
this.securityLevel = securityLevel;
}
示例13: ecdsaSignToBytes
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
/**
* Sign data with the specified elliptic curve private key.
*
* @param privateKey elliptic curve private key.
* @param data data to sign
* @return the signed data.
* @throws CryptoException
*/
private byte[] ecdsaSignToBytes(ECPrivateKey privateKey, byte[] data) throws CryptoException {
try {
X9ECParameters params = ECNamedCurveTable.getByName(curveName);
BigInteger curveN = params.getN();
Signature sig = SECURITY_PROVIDER == null ? Signature.getInstance(DEFAULT_SIGNATURE_ALGORITHM) :
Signature.getInstance(DEFAULT_SIGNATURE_ALGORITHM, SECURITY_PROVIDER);
sig.initSign(privateKey);
sig.update(data);
byte[] signature = sig.sign();
BigInteger[] sigs = decodeECDSASignature(signature);
sigs = preventMalleability(sigs, curveN);
ByteArrayOutputStream s = new ByteArrayOutputStream();
DERSequenceGenerator seq = new DERSequenceGenerator(s);
seq.addObject(new ASN1Integer(sigs[0]));
seq.addObject(new ASN1Integer(sigs[1]));
seq.close();
return s.toByteArray();
} catch (Exception e) {
throw new CryptoException("Could not sign the message using private key", e);
}
}
示例14: createNamedCurveSpec
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
protected ECNamedCurveSpec createNamedCurveSpec(String curveName)
throws InvalidAlgorithmParameterException
{
// NOTE: Don't bother with custom curves here as the curve will be converted to JCE type shortly
X9ECParameters p = ECUtils.getDomainParametersFromName(curveName);
if (p == null)
{
try
{
// Check whether it's actually an OID string (SunJSSE ServerHandshaker setupEphemeralECDHKeys bug)
p = ECNamedCurveTable.getByOID(new ASN1ObjectIdentifier(curveName));
if (p == null)
{
throw new InvalidAlgorithmParameterException("unknown curve OID: " + curveName);
}
}
catch (IllegalArgumentException ex)
{
throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
}
}
// Work-around for JDK bug -- it won't look up named curves properly if seed is present
byte[] seed = null; //p.getSeed();
return new ECNamedCurveSpec(curveName, p.getCurve(), p.getG(), p.getN(), p.getH(), seed);
}
示例15: decodePoint
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入依赖的package包/类
ECPoint decodePoint(byte[] data) {
ECCurve curve = ECNamedCurveTable.getByName(curveName).getCurve();
int compactExportSize = (curve.getFieldSize() + 7) / 8;
return data.length == compactExportSize
? ECPointsCompact.decodeFPPoint(curve, data) // Compact keys support, non RFC6636 compliant.
: curve.decodePoint(data);
}