本文整理汇总了Java中org.bouncycastle.jce.provider.BouncyCastleProvider.getPublicKey方法的典型用法代码示例。如果您正苦于以下问题:Java BouncyCastleProvider.getPublicKey方法的具体用法?Java BouncyCastleProvider.getPublicKey怎么用?Java BouncyCastleProvider.getPublicKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.jce.provider.BouncyCastleProvider
的用法示例。
在下文中一共展示了BouncyCastleProvider.getPublicKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineGeneratePublic
import org.bouncycastle.jce.provider.BouncyCastleProvider; //导入方法依赖的package包/类
protected PublicKey engineGeneratePublic(
KeySpec keySpec)
throws InvalidKeySpecException
{
if (keySpec instanceof X509EncodedKeySpec)
{
try
{
SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(((X509EncodedKeySpec)keySpec).getEncoded());
PublicKey key = BouncyCastleProvider.getPublicKey(info);
if (key != null)
{
return key;
}
throw new InvalidKeySpecException("no factory found for OID: " + info.getAlgorithm().getAlgorithm());
}
catch (Exception e)
{
throw new InvalidKeySpecException(e.toString());
}
}
throw new InvalidKeySpecException("Unknown KeySpec type: " + keySpec.getClass().getName());
}
示例2: engineInitVerify
import org.bouncycastle.jce.provider.BouncyCastleProvider; //导入方法依赖的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: getPublicKey
import org.bouncycastle.jce.provider.BouncyCastleProvider; //导入方法依赖的package包/类
public PublicKey getPublicKey()
{
try
{
return BouncyCastleProvider.getPublicKey(c.getSubjectPublicKeyInfo());
}
catch (IOException e)
{
return null; // should never happen...
}
}
示例4: engineInitVerify
import org.bouncycastle.jce.provider.BouncyCastleProvider; //导入方法依赖的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);
}