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


Java CMSEnvelopedDataGenerator.addKeyTransRecipient方法代码示例

本文整理汇总了Java中org.bouncycastle.cms.CMSEnvelopedDataGenerator.addKeyTransRecipient方法的典型用法代码示例。如果您正苦于以下问题:Java CMSEnvelopedDataGenerator.addKeyTransRecipient方法的具体用法?Java CMSEnvelopedDataGenerator.addKeyTransRecipient怎么用?Java CMSEnvelopedDataGenerator.addKeyTransRecipient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.cms.CMSEnvelopedDataGenerator的用法示例。


在下文中一共展示了CMSEnvelopedDataGenerator.addKeyTransRecipient方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testKeyTransODES

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransODES()
    throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            "1.3.14.3.2.7", "BC");

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(), "1.3.14.3.2.7");
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), "BC");

        assertEquals(true, Arrays.equals(data, recData));
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:34,代码来源:EnvelopedDataTest.java

示例2: testKeyTransSmallAES

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransSmallAES()
    throws Exception
{
    byte[]          data     = new byte[] { 0, 1, 2, 3 };

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                          new CMSProcessableByteArray(data),
                          CMSEnvelopedDataGenerator.AES128_CBC, "BC");

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(),
                               CMSEnvelopedDataGenerator.AES128_CBC);
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), "BC");
        assertEquals(true, Arrays.equals(data, recData));
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:34,代码来源:EnvelopedDataTest.java

示例3: testKeyTransODES

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransODES()
    throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            "1.3.14.3.2.7", BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(), "1.3.14.3.2.7");
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);

        assertEquals(true, Arrays.equals(data, recData));
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:34,代码来源:EnvelopedDataTest.java

示例4: testKeyTransSmallAES

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransSmallAES()
    throws Exception
{
    byte[]          data     = new byte[] { 0, 1, 2, 3 };

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                          new CMSProcessableByteArray(data),
                          CMSEnvelopedDataGenerator.AES128_CBC, BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(),
                               CMSEnvelopedDataGenerator.AES128_CBC);
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);
        assertEquals(true, Arrays.equals(data, recData));
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:34,代码来源:EnvelopedDataTest.java

示例5: testKeyTrans128RC4

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTrans128RC4()
    throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            "1.2.840.113549.3.4", 128, BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(), "1.2.840.113549.3.4");
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);

        assertEquals(true, Arrays.equals(data, recData));
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:34,代码来源:EnvelopedDataTest.java

示例6: testKeyTransCAST5SunJCE

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransCAST5SunJCE()
    throws Exception
{
    if (Security.getProvider("SunJCE") == null)
    {
        return;
    }
    
    String version = System.getProperty("java.version");
    if (version.startsWith("1.4") || version.startsWith("1.3"))
    {
        return;
    }
    
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            CMSEnvelopedDataGenerator.CAST5_CBC, "SunJCE");
    RecipientInformationStore  recipients = ed.getRecipientInfos();
    
    assertEquals(ed.getEncryptionAlgOID(), CMSEnvelopedDataGenerator.CAST5_CBC);

    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();
    
    while (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());
        
        byte[] recData = recipient.getContent(_reciKP.getPrivate(), "SunJCE");

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:45,代码来源:EnvelopedDataTest.java

示例7: testKeyTrans

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
private void testKeyTrans(String algorithm)
    throws Exception
{
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(keyCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            algorithm, "SunJCE");

    RecipientInformationStore recipients = ed.getRecipientInfos();


    assertEquals(ed.getEncryptionAlgOID(), algorithm);

    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

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

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

        byte[] recData = recipient.getContent(keyPair.getPrivate(), "SunJCE");

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:36,代码来源:SunProviderTest.java

示例8: testKeyTrans

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
private void testKeyTrans(String algorithm)
    throws Exception
{
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(keyCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            algorithm, (String)null);

    RecipientInformationStore recipients = ed.getRecipientInfos();


    assertEquals(ed.getEncryptionAlgOID(), algorithm);

    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

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

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

        byte[] recData = recipient.getContent(keyPair.getPrivate(), (String)null);

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:36,代码来源:NullProviderTest.java

示例9: testKeyTransRC4

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransRC4()
    throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            "1.2.840.113549.3.4", BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(), "1.2.840.113549.3.4");
    
    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

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

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:EnvelopedDataTest.java

示例10: testKeyTransRC4

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTransRC4()
    throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            "1.2.840.113549.3.4", "BC");

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(), "1.2.840.113549.3.4");
    
    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

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

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), "BC");

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:EnvelopedDataTest.java

示例11: testKeyTrans

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
public void testKeyTrans()
    throws Exception
{
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            CMSEnvelopedDataGenerator.DES_EDE3_CBC, BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();


    assertEquals(ed.getEncryptionAlgOID(), CMSEnvelopedDataGenerator.DES_EDE3_CBC);
    
    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

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

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());
        
        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:36,代码来源:EnvelopedDataTest.java

示例12: tryKeyTrans

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
private void tryKeyTrans(String generatorOID, DERObjectIdentifier checkOID, Class asn1Params)
    throws Exception
{
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            generatorOID, BC);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(checkOID.getId(), ed.getEncryptionAlgOID());

    if (asn1Params != null)
    {
        ASN1InputStream aIn = new ASN1InputStream(ed.getEncryptionAlgParams());

        assertTrue(asn1Params.isAssignableFrom(aIn.readObject().getClass()));
    }

    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

    if (!it.hasNext())
    {
        fail("no recipients found");
    }

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

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), BC);

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:47,代码来源:EnvelopedDataTest.java

示例13: tryKeyTrans

import org.bouncycastle.cms.CMSEnvelopedDataGenerator; //导入方法依赖的package包/类
private void tryKeyTrans(String generatorOID, DERObjectIdentifier checkOID, Class asn1Params)
    throws Exception
{
    byte[]          data     = "WallaWallaWashington".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addKeyTransRecipient(_reciCert);

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            generatorOID, "BC");

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(checkOID.getId(), ed.getEncryptionAlgOID());

    if (asn1Params != null)
    {
        ASN1InputStream aIn = new ASN1InputStream(ed.getEncryptionAlgParams());

        assertTrue(asn1Params.isAssignableFrom(aIn.readObject().getClass()));
    }

    Collection  c = recipients.getRecipients();

    assertEquals(1, c.size());

    Iterator    it = c.iterator();

    if (!it.hasNext())
    {
        fail("no recipients found");
    }

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

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

        byte[] recData = recipient.getContent(_reciKP.getPrivate(), "BC");

        assertEquals(true, Arrays.equals(data, recData));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:47,代码来源:EnvelopedDataTest.java


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