本文整理汇总了Java中org.bouncycastle.asn1.x9.ECNamedCurveTable.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java ECNamedCurveTable.getByName方法的具体用法?Java ECNamedCurveTable.getByName怎么用?Java ECNamedCurveTable.getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x9.ECNamedCurveTable
的用法示例。
在下文中一共展示了ECNamedCurveTable.getByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例6: 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);
}
}
}
示例7: 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());
}
示例8: 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;
}
示例9: 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);
}
}
示例10: handle
import org.bouncycastle.asn1.x9.ECNamedCurveTable; //导入方法依赖的package包/类
public MessageReply handle(final KeyPairGenerateMessage message)
{
// TODO: sort out the reply messages
try
{
switch (((Type)message.getType()))
{
case GENERATE:
final NamedKeyGenParams ecKeyGenParams = (NamedKeyGenParams)NamedKeyGenParams.getInstance(message.getPayload());
final List<String> involvedPeers = ecKeyGenParams.getNodesToUse();
X9ECParameters params = CustomNamedCurves.getByName(ecKeyGenParams.getDomainParameters());
if (params == null)
{
params = ECNamedCurveTable.getByName(ecKeyGenParams.getDomainParameters());
}
paramsMap.put(ecKeyGenParams.getKeyID(), new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed()));
sharedHMap.init(ecKeyGenParams.getKeyID(), involvedPeers.size());
BigInteger h = generateH(params.getN(), new SecureRandom()); // TODO: provide randomness?
ECPoint[] messages = new ECPoint[involvedPeers.size()];
for (int i = 0; i != messages.length; i++)
{
messages[i] = params.getG().multiply(h);
}
nodeContext.execute(new SendHTask(message.getAlgorithm(), ecKeyGenParams.getKeyID(), involvedPeers, messages));
final List<String> peerList = ecKeyGenParams.getNodesToUse();
ECNewDKGGenerator generator = (ECNewDKGGenerator)nodeContext.getKeyPairGenerator(ecKeyGenParams.getAlgorithm());
ECCommittedSecretShareMessage[] comMessages = generator.generateThresholdKey(
ecKeyGenParams.getKeyID(), paramsMap.get(ecKeyGenParams.getKeyID()), peerList.size(),
ecKeyGenParams.getThreshold(), sharedHMap.getShare(ecKeyGenParams.getKeyID()).getValue().normalize());
nodeContext.execute(new SendShareTask(generator, message.getAlgorithm(), ecKeyGenParams.getKeyID(), peerList, comMessages));
return new MessageReply(MessageReply.Type.OKAY);
case STORE_H:
StoreMessage storeMessage = StoreMessage.getInstance(message.getPayload());
ShareMessage shareMessage = ShareMessage.getInstance(storeMessage.getSecretShareMessage());
nodeContext.execute(new StoreHTask(storeMessage.getID(), shareMessage));
return new MessageReply(MessageReply.Type.OKAY);
case STORE:
StoreMessage sssMessage = StoreMessage.getInstance(message.getPayload());
// we may not have been asked to generate our share yet, if this is the case we need to queue up our share requests
// till we can validate them.
generator = (ECNewDKGGenerator)nodeContext.getKeyPairGenerator(message.getAlgorithm());
nodeContext.execute(new StoreShareTask(generator, sssMessage.getID(), sssMessage.getSecretShareMessage()));
return new MessageReply(MessageReply.Type.OKAY);
default:
return new MessageReply(MessageReply.Type.ERROR, new DERUTF8String("Unknown command in NodeKeyGenerationService."));
}
}
catch (Exception e)
{
nodeContext.getEventNotifier().notify(EventNotifier.Level.ERROR, "NodeKeyGenerationService failure: " + e.getMessage(), e);
return new MessageReply(MessageReply.Type.ERROR, new DERUTF8String("NodeKeyGenerationService failure: " + e.getMessage()));
}
}