本文整理汇总了Java中org.bouncycastle.operator.OutputEncryptor.getAlgorithmIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java OutputEncryptor.getAlgorithmIdentifier方法的具体用法?Java OutputEncryptor.getAlgorithmIdentifier怎么用?Java OutputEncryptor.getAlgorithmIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.operator.OutputEncryptor
的用法示例。
在下文中一共展示了OutputEncryptor.getAlgorithmIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.bouncycastle.operator.OutputEncryptor; //导入方法依赖的package包/类
public PKCS8EncryptedPrivateKeyInfo build(
OutputEncryptor encryptor)
{
try
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
OutputStream cOut = encryptor.getOutputStream(bOut);
cOut.write(privateKeyInfo.getEncoded());
cOut.close();
return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray()));
}
catch (IOException e)
{
throw new IllegalStateException("cannot encode privateKeyInfo");
}
}
示例2: generate
import org.bouncycastle.operator.OutputEncryptor; //导入方法依赖的package包/类
private PemObject generate(PrivateKeyInfo key, OutputEncryptor encryptor)
throws PemGenerationException
{
try
{
byte[] keyData = key.getEncoded();
if (encryptor == null)
{
return new PemObject("PRIVATE KEY", keyData);
}
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
OutputStream cOut = encryptor.getOutputStream(bOut);
cOut.write(key.getEncoded());
cOut.close();
EncryptedPrivateKeyInfo info = new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray());
return new PemObject("ENCRYPTED PRIVATE KEY", info.getEncoded());
}
catch (IOException e)
{
throw new PemGenerationException("unable to process encoded key data: " + e.getMessage(), e);
}
}
示例3: open
import org.bouncycastle.operator.OutputEncryptor; //导入方法依赖的package包/类
protected OutputStream open(
ASN1ObjectIdentifier dataType,
OutputStream out,
ASN1EncodableVector recipientInfos,
OutputEncryptor encryptor)
throws IOException
{
//
// ContentInfo
//
BERSequenceGenerator cGen = new BERSequenceGenerator(out);
cGen.addObject(CMSObjectIdentifiers.envelopedData);
//
// Encrypted Data
//
BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);
envGen.addObject(getVersion());
if (originatorInfo != null)
{
envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
}
if (_berEncodeRecipientSet)
{
envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
}
else
{
envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
}
BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());
eiGen.addObject(dataType);
AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();
eiGen.getRawOutputStream().write(encAlgId.getEncoded());
OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
eiGen.getRawOutputStream(), 0, false, _bufferSize);
OutputStream cOut = encryptor.getOutputStream(octetStream);
return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}