当前位置: 首页>>代码示例>>Java>>正文


Java OutputEncryptor.getAlgorithmIdentifier方法代码示例

本文整理汇总了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");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:PKCS8EncryptedPrivateKeyInfoBuilder.java

示例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);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:PKCS8Generator.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:51,代码来源:CMSEnvelopedDataStreamGenerator.java


注:本文中的org.bouncycastle.operator.OutputEncryptor.getAlgorithmIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。