• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RecipientInformation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RecipientInformation类属于org.bouncycastle.cms包,在下文中一共展示了RecipientInformation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decrypt

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
public void decrypt(X509Certificate cert, PrivateKey privateKey) throws SFRMException {
    try {
        SMIMEEnveloped m = new SMIMEEnveloped(bodyPart);

 RecipientId recId = new JceKeyTransRecipientId(cert);

 RecipientInformationStore  recipientsInfo = m.getRecipientInfos();	
 RecipientInformation       recipientInfo = recipientsInfo.get(recId);

        if (recipientInfo == null) {
            throw new SFRMMessageException("Invalid encrypted content");
        }

 JceKeyTransEnvelopedRecipient recipient = new JceKeyTransEnvelopedRecipient(privateKey);
 recipient.setProvider(SECURITY_PROVIDER);							
 
        this.bodyPart = new MimeBodyPart(new ByteArrayInputStream(recipientInfo.getContent(recipient)));
        this.setIsEncrypted(true);
	} catch (org.bouncycastle.cms.CMSException ex) {
		throw new SFRMException("Unable to decrypt body part", ex.getUnderlyingException());
    } catch (Exception e) {
        throw new SFRMException("Unable to decrypt body part", e);
    }
}
 
开发者ID:cecid,项目名称:hermes,代码行数:25,代码来源:SFRMMessage.java


示例2: decryptPart

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private MimeBodyPart decryptPart(MimeBodyPart part) throws Exception {

        SMIMEEnveloped smimeEnveloped = new SMIMEEnveloped(part);
        RecipientInformationStore recipients = smimeEnveloped.getRecipientInfos();
        RecipientInformation recipient = recipients.get(recId);

        if (null == recipient) {
            StringBuilder errorMessage = new StringBuilder();
            errorMessage.append("This email wasn't encrypted with \"" + recId.toString() + "\".\n");
            errorMessage.append("The encryption recId is: ");

            for (Object rec : recipients.getRecipients()) {
                if (rec instanceof RecipientInformation) {
                    RecipientId recipientId = ((RecipientInformation) rec).getRID();
                    errorMessage.append("\"" + recipientId.toString() + "\"\n");
                }
            }
            throw new Exception(errorMessage.toString());
        }

        return toMimeBodyPart(recipient.getContent(ks.getKey(decryptionKeyAlias, null), BOUNCY_CASTLE_PROVIDER));
    }
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:23,代码来源:GetMailMessage.java


示例3: decryptEnvelope

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
/**
 * Try to decrypt the provided envelope with the provided certificate 
 * and private key. 
 */
public static MimeBodyPart decryptEnvelope(SMIMEEnveloped enveloped, 
							Key key, X509Certificate cert)
	throws Exception
{
	 // look for our recipient identifier
    RecipientId recId = new RecipientId();
    recId.setSerialNumber(cert.getSerialNumber());
    recId.setIssuer(cert.getIssuerX500Principal().getEncoded());

    RecipientInformationStore recipients = enveloped.getRecipientInfos();
    RecipientInformation recipient = recipients.get(recId);

    // decryption step
	if (recipient != null)
		return SMIMEUtil.toMimeBodyPart(recipient.getContent(key, "BC"));
	else
		return null;
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:23,代码来源:SmimeUtilities.java


示例4: verifyData

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyData(
    ByteArrayOutputStream encodedStream,
    String                expectedOid,
    byte[]                expectedData)
    throws Exception
{
    CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(encodedStream.toByteArray());
    RecipientInformationStore  recipients = ep.getRecipientInfos();

    assertEquals(ep.getEncryptionAlgOID(), expectedOid);
    
    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();
    
    while (it.hasNext())
    {
        RecipientInformation   recipient = (RecipientInformation)it.next();

        assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());
        
        CMSTypedStream recData = recipient.getContentStream(_reciKP.getPrivate(), BC);
        
        assertEquals(true, Arrays.equals(expectedData, CMSTestUtil.streamToByteArray(recData.getContentStream())));
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:26,代码来源:EnvelopedDataStreamTest.java


示例5: verifyParserAlgorithm

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyParserAlgorithm(
    String algorithmOid,
    MimeBodyPart msg) 
    throws Exception
{
    SMIMEEnvelopedGenerator  gen = new SMIMEEnvelopedGenerator();
      
    gen.addKeyTransRecipient(_reciCert);
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //

    MimeBodyPart         mp = gen.generate(msg, algorithmOid, "BC");
    SMIMEEnvelopedParser m = new SMIMEEnvelopedParser(mp);
    RecipientId          recId = getRecipientId(_reciCert);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);

    MimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContent(_reciKP.getPrivate(), "BC"));

    verifyMessageBytes(msg, res);
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:26,代码来源:SMIMEEnvelopedTest.java


示例6: verifyData

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyData(
    ByteArrayOutputStream encodedStream,
    String                expectedOid,
    byte[]                expectedData)
    throws Exception
{
    CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(encodedStream.toByteArray());
    RecipientInformationStore  recipients = ep.getRecipientInfos();

    assertEquals(ep.getEncryptionAlgOID(), expectedOid);

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

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

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

        CMSTypedStream recData = recipient.getContentStream(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC));

        assertEquals(true, Arrays.equals(expectedData, CMSTestUtil.streamToByteArray(recData.getContentStream())));
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewEnvelopedDataStreamTest.java


示例7: verifyEnvelopedData

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyEnvelopedData(CMSEnvelopedData envelopedData, String symAlgorithmOID)
    throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException, CMSException
{
    byte[]              privKeyData = getRfc4134Data("BobPrivRSAEncrypt.pri");
    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privKeyData);
    KeyFactory keyFact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = keyFact.generatePrivate(keySpec);

    RecipientInformationStore recipients = envelopedData.getRecipientInfos();

    assertEquals(envelopedData.getEncryptionAlgOID(), symAlgorithmOID);

    Collection c = recipients.getRecipients();
    assertTrue(c.size() >= 1 && c.size() <= 2);

    Iterator it = c.iterator();
    verifyRecipient((RecipientInformation)it.next(), privKey);

    if (c.size() == 2)
    {
        RecipientInformation recInfo = (RecipientInformation)it.next();

        assertEquals(PKCSObjectIdentifiers.id_alg_CMSRC2wrap.getId(), recInfo.getKeyEncryptionAlgOID());
    }
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:26,代码来源:Rfc4134Test.java


示例8: verifyEnvelopedData

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyEnvelopedData(CMSEnvelopedDataParser envelopedParser, String symAlgorithmOID)
    throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException, CMSException
{
    byte[]              privKeyData = getRfc4134Data("BobPrivRSAEncrypt.pri");
    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privKeyData);
    KeyFactory keyFact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = keyFact.generatePrivate(keySpec);

    RecipientInformationStore recipients = envelopedParser.getRecipientInfos();

    assertEquals(envelopedParser.getEncryptionAlgOID(), symAlgorithmOID);

    Collection c = recipients.getRecipients();
    assertTrue(c.size() >= 1 && c.size() <= 2);

    Iterator it = c.iterator();
    verifyRecipient((RecipientInformation)it.next(), privKey);

    if (c.size() == 2)
    {
        RecipientInformation recInfo = (RecipientInformation)it.next();

        assertEquals(PKCSObjectIdentifiers.id_alg_CMSRC2wrap.getId(), recInfo.getKeyEncryptionAlgOID());
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:Rfc4134Test.java


示例9: verifyAlgorithm

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyAlgorithm(
    String algorithmOid,
    MimeBodyPart msg) 
    throws Exception
{
    SMIMEEnvelopedGenerator  gen = new SMIMEEnvelopedGenerator();
      
    gen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(_reciCert).setProvider(BC));
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //

    MimeBodyPart   mp = gen.generate(msg, new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(algorithmOid)).setProvider(BC).build());
    SMIMEEnveloped m = new SMIMEEnveloped(mp);
    RecipientId    recId = getRecipientId(_reciCert);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);

    MimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContent(new JceKeyTransEnvelopedRecipient(_reciKP.getPrivate()).setProvider(BC)));

    verifyMessageBytes(msg, res);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:26,代码来源:NewSMIMEEnvelopedTest.java


示例10: verifyAlgorithm

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyAlgorithm(
    String algorithmOid,
    MimeBodyPart msg) 
    throws Exception
{
    SMIMEEnvelopedGenerator  gen = new SMIMEEnvelopedGenerator();
      
    gen.addKeyTransRecipient(_reciCert);
     
    //
    // generate a MimeBodyPart object which encapsulates the content
    // we want encrypted.
    //

    MimeBodyPart   mp = gen.generate(msg, algorithmOid, "BC");
    SMIMEEnveloped m = new SMIMEEnveloped(mp);
    RecipientId    recId = getRecipientId(_reciCert);

    RecipientInformationStore  recipients = m.getRecipientInfos();
    RecipientInformation       recipient = recipients.get(recId);

    MimeBodyPart    res = SMIMEUtil.toMimeBodyPart(recipient.getContent(_reciKP.getPrivate(), "BC"));

    verifyMessageBytes(msg, res);
}
 
开发者ID:mlundblad,项目名称:bc-java,代码行数:26,代码来源:SMIMEEnvelopedTest.java


示例11: testKeyTransLight128RC4

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void testKeyTransLight128RC4()
        throws Exception
{
    byte[]          data     = "WallaWallaBouncyCastle".getBytes();

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addRecipientInfoGenerator(new BcRSAKeyTransRecipientInfoGenerator(_reciCert));

    CMSEnvelopedData ed = edGen.generate(
        new CMSProcessableByteArray(data),
        new BcCMSContentEncryptorBuilder(NISTObjectIdentifiers.id_aes128_CBC).build());

    RecipientInformationStore recipients = ed.getRecipientInfos();

    if (!ed.getEncryptionAlgOID().equals(NISTObjectIdentifiers.id_aes128_CBC.getId()))
    {
        fail("enc oid mismatch");
    }

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

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

        byte[] recData = recipient.getContent(new BcRSAKeyTransEnvelopedRecipient((AsymmetricKeyParameter)_reciKP.getPrivate()));

        if (!Arrays.areEqual(data, recData))
        {
            fail("decryption failed");
        }
    }
    else
    {
        fail("no recipient found");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:40,代码来源:BcEnvelopedDataTest.java


示例12: testKeyTransSmallAES

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

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addRecipientInfoGenerator(new BcRSAKeyTransRecipientInfoGenerator(new JcaX509CertificateHolder(_reciCert)));

    CMSEnvelopedData ed = edGen.generate(
                          new CMSProcessableByteArray(data),
                          new BcCMSContentEncryptorBuilder(CMSAlgorithm.AES128_CBC).build());

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals(ed.getEncryptionAlgOID(),
                               CMSAlgorithm.AES128_CBC.getId());

    Collection c = recipients.getRecipients();
    Iterator it = c.iterator();

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

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


示例13: testRFC4134ex5_1

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
public void testRFC4134ex5_1()
    throws Exception
{
    byte[] data = Hex.decode("5468697320697320736f6d652073616d706c6520636f6e74656e742e");

    KeyFactory kFact = KeyFactory.getInstance("RSA", BC);
    Key key = kFact.generatePrivate(new PKCS8EncodedKeySpec(bobPrivRsaEncrypt));

    CMSEnvelopedData ed = new CMSEnvelopedData(rfc4134ex5_1);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals("1.2.840.113549.3.7", ed.getEncryptionAlgOID());

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

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

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

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


示例14: verifyECKeyAgreeVectors

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyECKeyAgreeVectors(PrivateKey privKey, String wrapAlg, byte[] message)
    throws CMSException, GeneralSecurityException
{
    byte[] data = Hex.decode("504b492d4320434d5320456e76656c6f706564446174612053616d706c65");

    CMSEnvelopedData ed = new CMSEnvelopedData(message);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    Collection c = recipients.getRecipients();
    Iterator it = c.iterator();

    assertEquals(wrapAlg, ed.getEncryptionAlgOID());

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

        assertEquals("1.3.133.16.840.63.0.2", recipient.getKeyEncryptionAlgOID());

        byte[] recData = recipient.getContent(new JceKeyAgreeEnvelopedRecipient(privKey).setProvider(BC));

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


示例15: testKeyTrans128RC4

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

    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    edGen.addRecipientInfoGenerator(new BcRSAKeyTransRecipientInfoGenerator(new JcaX509CertificateHolder(_reciCert)));

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

    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(new BcRSAKeyTransEnvelopedRecipient(PrivateKeyFactory.createKey(PrivateKeyInfo.getInstance(_reciKP.getPrivate().getEncoded()))));

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


示例16: verifyRecipient

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyRecipient(RecipientInformation recipient, PrivateKey privKey)
    throws CMSException, NoSuchProviderException
{
    assertEquals(recipient.getKeyEncryptionAlgOID(), PKCSObjectIdentifiers.rsaEncryption.getId());

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

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


示例17: tryKekAlgorithm

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void tryKekAlgorithm(BcSymmetricKeyWrapper kekWrapper, BcSymmetricKeyUnwrapper kekUnwrapper, ASN1ObjectIdentifier algOid)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
{
    byte[]    data = "WallaWallaWashington".getBytes();
    CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

    byte[]  kekId = new byte[] { 1, 2, 3, 4, 5 };

    edGen.addRecipientInfoGenerator(new BcKEKRecipientInfoGenerator(kekId, kekWrapper));

    CMSEnvelopedData ed = edGen.generate(
                            new CMSProcessableByteArray(data),
                            new BcCMSContentEncryptorBuilder(CMSAlgorithm.DES_EDE3_CBC).build());

    RecipientInformationStore recipients = ed.getRecipientInfos();

    Collection c = recipients.getRecipients();
    Iterator it = c.iterator();

    assertEquals(ed.getEncryptionAlgOID(), CMSAlgorithm.DES_EDE3_CBC.getId());

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

        assertEquals(algOid.getId(), recipient.getKeyEncryptionAlgOID());

        byte[] recData = recipient.getContent(new BcKEKEnvelopedRecipient(kekUnwrapper));

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


示例18: testRFC4134ex5_2

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
public void testRFC4134ex5_2()
    throws Exception
{
    byte[] data = Hex.decode("5468697320697320736f6d652073616d706c6520636f6e74656e742e");

    KeyFactory kFact = KeyFactory.getInstance("RSA", "BC");
    Key key = kFact.generatePrivate(new PKCS8EncodedKeySpec(bobPrivRsaEncrypt));

    CMSEnvelopedData ed = new CMSEnvelopedData(rfc4134ex5_2);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    assertEquals("1.2.840.113549.3.2", ed.getEncryptionAlgOID());

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    if (it.hasNext())
    {
        while (it.hasNext())
        {
            RecipientInformation   recipient = (RecipientInformation)it.next();
            byte[] recData;

            if (recipient instanceof KeyTransRecipientInformation)
            {
                recData = recipient.getContent(key, "BC");

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


示例19: verifyECMQVKeyAgreeVectors

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyECMQVKeyAgreeVectors(PrivateKey privKey, String wrapAlg, byte[] message)
    throws CMSException, GeneralSecurityException
{
    byte[] data = Hex.decode("504b492d4320434d5320456e76656c6f706564446174612053616d706c65");

    CMSEnvelopedData ed = new CMSEnvelopedData(message);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    Collection c = recipients.getRecipients();
    Iterator it = c.iterator();

    assertEquals(wrapAlg, ed.getEncryptionAlgOID());

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

        assertEquals("1.3.133.16.840.63.0.16", recipient.getKeyEncryptionAlgOID());

        byte[] recData = recipient.getContent(new JceKeyAgreeEnvelopedRecipient(privKey).setProvider(BC));

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


示例20: verifyECKeyAgreeVectors

import org.bouncycastle.cms.RecipientInformation; //导入依赖的package包/类
private void verifyECKeyAgreeVectors(PrivateKey privKey, String wrapAlg, byte[] message)
    throws CMSException, GeneralSecurityException
{
    byte[] data = Hex.decode("504b492d4320434d5320456e76656c6f706564446174612053616d706c65");

    CMSEnvelopedData ed = new CMSEnvelopedData(message);

    RecipientInformationStore  recipients = ed.getRecipientInfos();

    Collection  c = recipients.getRecipients();
    Iterator    it = c.iterator();

    assertEquals(wrapAlg, ed.getEncryptionAlgOID());

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

        assertEquals("1.3.133.16.840.63.0.2", recipient.getKeyEncryptionAlgOID());

        byte[] recData = recipient.getContent(new JceKeyAgreeEnvelopedRecipient(privKey).setProvider(BC));

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Repository类代码示例发布时间:2022-05-22
下一篇:
Java DoubleEditor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap