本文整理汇总了Java中org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil类的典型用法代码示例。如果您正苦于以下问题:Java ECUtil类的具体用法?Java ECUtil怎么用?Java ECUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ECUtil类属于org.bouncycastle.jcajce.provider.asymmetric.util包,在下文中一共展示了ECUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineInitSign
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitSign(
PrivateKey privateKey)
throws InvalidKeyException
{
CipherParameters param = null;
if (privateKey instanceof ECKey)
{
param = ECUtil.generatePrivateKeyParameter(privateKey);
}
digest = new GOST3411Digest(DEFAULT_SBOX);
if (appRandom != null)
{
signer.init(true, new ParametersWithRandom(param, appRandom));
}
else
{
signer.init(true, param);
}
}
示例2: engineInitVerify
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitVerify(
PublicKey publicKey)
throws InvalidKeyException
{
CipherParameters param;
if (publicKey instanceof ECPublicKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else if (publicKey instanceof GOST3410Key)
{
param = GOST3410Util.generatePublicKeyParameter(publicKey);
}
else
{
try
{
byte[] bytes = publicKey.getEncoded();
publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
if (publicKey instanceof ECPublicKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else
{
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
catch (Exception e)
{
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
digest.reset();
signer.init(false, param);
}
示例3: engineInitSign
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitSign(
PrivateKey privateKey)
throws InvalidKeyException
{
CipherParameters param;
if (privateKey instanceof ECKey)
{
param = ECUtil.generatePrivateKeyParameter(privateKey);
}
else
{
param = GOST3410Util.generatePrivateKeyParameter(privateKey);
}
digest.reset();
if (random != null)
{
signer.init(true, new ParametersWithRandom(param, random));
}
else
{
signer.init(true, param);
}
}
示例4: engineInitSign
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitSign(
PrivateKey privateKey)
throws InvalidKeyException
{
CipherParameters param = ECUtil.generatePrivateKeyParameter(privateKey);
digest.reset();
if (appRandom != null)
{
signer.init(true, new ParametersWithRandom(param, appRandom));
}
else
{
signer.init(true, param);
}
}
示例5: engineInitSign
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitSign(
PrivateKey privateKey)
throws InvalidKeyException
{
CipherParameters param;
if (privateKey instanceof ECKey)
{
param = ECUtil.generatePrivateKeyParameter(privateKey);
}
else
{
param = GOST3410Util.generatePrivateKeyParameter(privateKey);
}
digest.reset();
if (appRandom != null)
{
signer.init(true, new ParametersWithRandom(param, appRandom));
}
else
{
signer.init(true, param);
}
}
示例6: calculateECKAShS
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
/**
* Implement the ECKA algorithm (EG variant) in order to calculate the ShS (shared secret) from the provided
* static and ephemeral keys from the same curve.
* @param privateKey the private key to use for the ShS calculation.
* @param publicKey the public key to use for the ShS calculation.
* @return the calculated shared secret.
*/
public static byte[] calculateECKAShS(PrivateKey privateKey, PublicKey publicKey) {
try {
ECKABasicAgreement basicAgreement = new ECKABasicAgreement();
basicAgreement.init(ECUtil.generatePrivateKeyParameter(privateKey));
return basicAgreement.calculatePoint(ECUtil.generatePublicKeyParameter(publicKey)).getEncoded();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
return null;
}
示例7: engineInitVerify
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitVerify(
PublicKey publicKey)
throws InvalidKeyException
{
CipherParameters param;
if (publicKey instanceof ECPublicKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else
{
try
{
byte[] bytes = publicKey.getEncoded();
publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
if (publicKey instanceof ECPublicKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else
{
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
catch (Exception e)
{
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
digest = new GOST3411Digest(expandSbox(((BCDSTU4145PublicKey)publicKey).getSbox()));
signer.init(false, param);
}
示例8: engineInitVerify
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitVerify(PublicKey publicKey)
throws InvalidKeyException
{
CipherParameters param = ECUtil.generatePublicKeyParameter(publicKey);
digest.reset();
signer.init(false, param);
}
示例9: generatePublicKeyParameter
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey key)
throws InvalidKeyException {
ParamUtil.requireNonNull("key", key);
if (key instanceof RSAPublicKey) {
RSAPublicKey rsaKey = (RSAPublicKey) key;
return new RSAKeyParameters(false, rsaKey.getModulus(), rsaKey.getPublicExponent());
} else if (key instanceof ECPublicKey) {
return ECUtil.generatePublicKeyParameter(key);
} else if (key instanceof DSAPublicKey) {
return DSAUtil.generatePublicKeyParameter(key);
} else {
throw new InvalidKeyException("unknown key " + key.getClass().getName());
}
}
示例10: getDomainParametersFromName
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
static X9ECParameters getDomainParametersFromName(String curveName)
{
X9ECParameters domainParameters;
try
{
if (curveName.charAt(0) >= '0' && curveName.charAt(0) <= '2')
{
ASN1ObjectIdentifier oidID = new ASN1ObjectIdentifier(curveName);
domainParameters = ECUtil.getNamedCurveByOid(oidID);
}
else
{
if (curveName.indexOf(' ') > 0)
{
curveName = curveName.substring(curveName.indexOf(' ') + 1);
domainParameters = ECUtil.getNamedCurveByName(curveName);
}
else
{
domainParameters = ECUtil.getNamedCurveByName(curveName);
}
}
}
catch (IllegalArgumentException ex)
{
domainParameters = ECUtil.getNamedCurveByName(curveName);
}
return domainParameters;
}
示例11: engineInitVerify
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入依赖的package包/类
protected void engineInitVerify(
PublicKey publicKey)
throws InvalidKeyException
{
CipherParameters param;
if (publicKey instanceof ECPublicKey)
{
param = ECUtil.generatePublicKeyParameter(publicKey);
}
else if (publicKey instanceof GOST3410Key)
{
param = GOST3410Util.generatePublicKeyParameter(publicKey);
}
else
{
try
{
byte[] bytes = publicKey.getEncoded();
publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
param = ECUtil.generatePublicKeyParameter(publicKey);
}
catch (Exception e)
{
throw new InvalidKeyException("can't recognise key type in DSA based signer");
}
}
digest.reset();
signer.init(false, param);
}