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


Java OutputEncryptor类代码示例

本文整理汇总了Java中org.bouncycastle.operator.OutputEncryptor的典型用法代码示例。如果您正苦于以下问题:Java OutputEncryptor类的具体用法?Java OutputEncryptor怎么用?Java OutputEncryptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OutputEncryptor类属于org.bouncycastle.operator包,在下文中一共展示了OutputEncryptor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addEncryptedData

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
private PKCS12PfxPduBuilder addEncryptedData(OutputEncryptor dataEncryptor, ASN1Sequence data)
    throws IOException
{
    CMSEncryptedDataGenerator envGen = new CMSEncryptedDataGenerator();

    try
    {
        dataVector.add(envGen.generate(new CMSProcessableByteArray(data.getEncoded()), dataEncryptor).toASN1Structure());
    }
    catch (CMSException e)
    {
        throw new PKCSIOException(e.getMessage(), e.getCause());
    }

    return this;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:PKCS12PfxPduBuilder.java

示例3: doOpen

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
private OutputStream doOpen(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    OutputEncryptor      encryptor)
    throws IOException, CMSException
{
    ASN1EncodableVector recipientInfos = new ASN1EncodableVector();
    GenericKey encKey = encryptor.getKey();
    Iterator it = recipientInfoGenerators.iterator();

    while (it.hasNext())
    {
        RecipientInfoGenerator recipient = (RecipientInfoGenerator)it.next();

        recipientInfos.add(recipient.generate(encKey));
    }

    return open(dataType, out, recipientInfos, encryptor);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:CMSEnvelopedDataStreamGenerator.java

示例4: encryptKey

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
private static byte[] encryptKey(KeyPair key, String resource, PasswordCallback newPassword) throws IOException {
	char[] passwordChars = newPassword.queryPassword(resource);

	if (passwordChars == null) {
		throw new PasswordRequiredException(resource);
	}

	byte[] encoded;

	try {
		PKCS8EncryptedPrivateKeyInfoBuilder encryptedPrivateKeyInfoBuilder = new PKCS8EncryptedPrivateKeyInfoBuilder(
				KeyHelper.encodePrivateKey(key.getPrivate()));
		OutputEncryptor encryptor = OUTPUT_ENCRYPTOR_BUILDER.build(passwordChars);

		encoded = encryptedPrivateKeyInfoBuilder.build(encryptor).getEncoded();
	} catch (OperatorCreationException e) {
		throw new CertProviderException(e);
	}
	return encoded;
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:21,代码来源:DERCertReaderWriter.java

示例5: make

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * if we get here we expect the Mime body part to be well defined.
 */
private MimeBodyPart make(
    MimeBodyPart    content,
    OutputEncryptor encryptor)
    throws SMIMEException
{
    try
    {
        MimeBodyPart data = new MimeBodyPart();

        data.setContent(new ContentEncryptor(content, encryptor), ENCRYPTED_CONTENT_TYPE);
        data.addHeader("Content-Type", ENCRYPTED_CONTENT_TYPE);
        data.addHeader("Content-Disposition", "attachment; filename=\"smime.p7m\"");
        data.addHeader("Content-Description", "S/MIME Encrypted Message");
        data.addHeader("Content-Transfer-Encoding", encoding);

        return data;
    }
    catch (MessagingException e)
    {
        throw new SMIMEException("exception putting multi-part together.", e);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:SMIMEEnvelopedGenerator.java

示例6: generate

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * generate an enveloped object that contains an SMIME Enveloped
 * object using the given provider from the contents of the passed in
 * message
 */
public MimeBodyPart generate(
    MimeMessage     message,
    OutputEncryptor  encryptor)
    throws SMIMEException
{
    try
    {
        message.saveChanges();      // make sure we're up to date.
    }
    catch (MessagingException e)
    {
        throw new SMIMEException("unable to save message", e);
    }

    return make(makeContentBodyPart(message), encryptor);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:22,代码来源:SMIMEEnvelopedGenerator.java

示例7: testHeaders

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
@Test
public void testHeaders()
        throws Exception {
    InternetHeaders ih = new InternetHeaders();
    ih.addHeader("Content-Type", "application/xml");

    MimeBodyPart _msg = new MimeBodyPart(ih, "<customer name=\"bill\"/>".getBytes());


    SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
    OutputEncryptor encryptor = new JceCMSContentEncryptorBuilder(CMSAlgorithm.DES_EDE3_CBC)
            .setProvider("BC")
            .build();

    RecipientInfoGenerator generator = new JceKeyTransRecipientInfoGenerator(cert);
    gen.addRecipientInfoGenerator(generator);

    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //

    MimeBodyPart mp = gen.generate(_msg, encryptor);

    output(mp);
}
 
开发者ID:gini,项目名称:jersey-smime,代码行数:27,代码来源:EnvelopedTest.java

示例8: build

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * Build the PKIArchiveControl using the passed in encryptor to encrypt its contents.
 *
 * @param contentEncryptor a suitable content encryptor.
 * @return a PKIArchiveControl object.
 * @throws CMSException in the event the build fails.
 */
public PKIArchiveControl build(OutputEncryptor contentEncryptor)
    throws CMSException
{
    CMSEnvelopedData envContent = envGen.generate(keyContent, contentEncryptor);

    EnvelopedData envD = EnvelopedData.getInstance(envContent.toASN1Structure().getContent());

    return new PKIArchiveControl(new PKIArchiveOptions(new EncryptedKey(envD)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:PKIArchiveControlBuilder.java

示例9: generate

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * generate an enveloped object that contains an CMS Enveloped Data
 * object using the given provider.
 *
 * @param content the content to be encrypted
 * @param contentEncryptor the symmetric key based encryptor to encrypt the content with.
 */
public CMSEnvelopedData generate(
    CMSTypedData content,
    OutputEncryptor contentEncryptor)
    throws CMSException
{
    return doGenerate(content, contentEncryptor);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:CMSEnvelopedDataGenerator.java

示例10: generate

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * generate an encrypted object that contains an CMS Encrypted Data structure.
 *
 * @param content the content to be encrypted
 * @param contentEncryptor the symmetric key based encryptor to encrypt the content with.
 */
public CMSEncryptedData generate(
    CMSTypedData content,
    OutputEncryptor contentEncryptor)
    throws CMSException
{
    return doGenerate(content, contentEncryptor);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:14,代码来源:CMSEncryptedDataGenerator.java

示例11: open

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
/**
 * generate an enveloped object that contains an CMS Enveloped Data
 * object using the given encryptor.
 */
public OutputStream open(
    OutputStream    out,
    OutputEncryptor encryptor)
    throws CMSException, IOException
{
    return doOpen(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), out, encryptor);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:CMSEnvelopedDataStreamGenerator.java

示例12: 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

示例13: build

import org.bouncycastle.operator.OutputEncryptor; //导入依赖的package包/类
public OutputEncryptor build(final char[] password)
{
    if (random == null)
    {
        random = new SecureRandom();
    }

    final byte[] salt = new byte[20];

    random.nextBytes(salt);

    final PKCS12PBEParams pbeParams = new PKCS12PBEParams(salt, iterationCount);

    CipherParameters params = PKCS12PBEUtils.createCipherParameters(algorithm, digest, engine.getBlockSize(), pbeParams, password);

    engine.init(true, params);

    return new OutputEncryptor()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return new AlgorithmIdentifier(algorithm, pbeParams);
        }

        public OutputStream getOutputStream(OutputStream out)
        {
            return new CipherOutputStream(out, engine);
        }

        public GenericKey getKey()
        {
            return new GenericKey(new AlgorithmIdentifier(algorithm, pbeParams), PKCS12ParametersGenerator.PKCS12PasswordToBytes(password));
        }
    };
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:36,代码来源:BcPKCS12PBEOutputEncryptorBuilder.java


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