本文整理汇总了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");
}
}
示例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");
}
}
示例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));
}
示例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");
}
}
示例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");
}
}
示例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();
}