當前位置: 首頁>>代碼示例>>Java>>正文


Java JceKeyAgreeEnvelopedRecipient類代碼示例

本文整理匯總了Java中org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient的典型用法代碼示例。如果您正苦於以下問題:Java JceKeyAgreeEnvelopedRecipient類的具體用法?Java JceKeyAgreeEnvelopedRecipient怎麽用?Java JceKeyAgreeEnvelopedRecipient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JceKeyAgreeEnvelopedRecipient類屬於org.bouncycastle.cms.jcajce包,在下文中一共展示了JceKeyAgreeEnvelopedRecipient類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyECKeyAgreeVectors

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的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:credentials,項目名稱:irma_future_id,代碼行數:30,代碼來源:BcEnvelopedDataTest.java

示例2: verifyECMQVKeyAgreeVectors

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的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

示例3: confirmDataReceived

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的package包/類
private static void confirmDataReceived(RecipientInformationStore recipients,
    byte[] expectedData, X509Certificate reciCert, PrivateKey reciPrivKey, String provider)
    throws CMSException, NoSuchProviderException, CertificateEncodingException, IOException
{
    RecipientId rid = new JceKeyAgreeRecipientId(reciCert);

    RecipientInformation recipient = recipients.get(rid);
    assertNotNull(recipient);

    byte[] actualData = recipient.getContent(new JceKeyAgreeEnvelopedRecipient(reciPrivKey).setProvider(provider));
    assertEquals(true, Arrays.equals(expectedData, actualData));
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:13,代碼來源:NewEnvelopedDataTest.java

示例4: verifyECKeyAgreeVectors

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的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:credentials,項目名稱:irma_future_id,代碼行數:30,代碼來源:NewEnvelopedDataTest.java

示例5: verifyECMQVKeyAgreeVectors

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的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,代碼來源:NewEnvelopedDataTest.java

示例6: testECKeyAgree

import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; //導入依賴的package包/類
public void testECKeyAgree()
    throws Exception
{
    byte[] data = Hex.decode("504b492d4320434d5320456e76656c6f706564446174612053616d706c65");

    CMSEnvelopedDataStreamGenerator edGen = new CMSEnvelopedDataStreamGenerator();

    JceKeyAgreeRecipientInfoGenerator recipientGenerator = new JceKeyAgreeRecipientInfoGenerator(CMSAlgorithm.ECDH_SHA1KDF, _origEcKP.getPrivate(), _origEcKP.getPublic(), CMSAlgorithm.AES128_WRAP).setProvider(BC);

    recipientGenerator.addRecipient(_reciEcCert);

    edGen.addRecipientInfoGenerator(recipientGenerator);
    
    ByteArrayOutputStream  bOut = new ByteArrayOutputStream();

    OutputStream out = edGen.open(
                            bOut,
                            new JceCMSContentEncryptorBuilder(CMSAlgorithm.AES128_CBC).setProvider(BC).build());
    out.write(data);

    out.close();

    CMSEnvelopedDataParser     ep = new CMSEnvelopedDataParser(bOut.toByteArray());

    RecipientInformationStore  recipients = ep.getRecipientInfos();

    assertEquals(ep.getEncryptionAlgOID(), CMSEnvelopedDataGenerator.AES128_CBC);

    RecipientId                recSel = new JceKeyAgreeRecipientId(_reciEcCert);

    RecipientInformation       recipient = recipients.get(recSel);

    CMSTypedStream recData = recipient.getContentStream(new JceKeyAgreeEnvelopedRecipient(_reciEcKP.getPrivate()).setProvider(BC));

    assertEquals(true, Arrays.equals(data, CMSTestUtil.streamToByteArray(recData.getContentStream())));

    ep.close();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:39,代碼來源:NewEnvelopedDataStreamTest.java


注:本文中的org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。