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


Java RecipientInfo类代码示例

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


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

示例1: readRecipientInfo

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
private static void readRecipientInfo(
    List infos, RecipientInfo info, AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Encodable recipInfo = info.getInfo();
    if (recipInfo instanceof KeyTransRecipientInfo)
    {
        infos.add(new KeyTransRecipientInformation(
            (KeyTransRecipientInfo)recipInfo, messageAlgorithm, secureReadable, additionalData));
    }
    else if (recipInfo instanceof KEKRecipientInfo)
    {
        infos.add(new KEKRecipientInformation(
            (KEKRecipientInfo)recipInfo, messageAlgorithm, secureReadable, additionalData));
    }
    else if (recipInfo instanceof KeyAgreeRecipientInfo)
    {
        KeyAgreeRecipientInformation.readRecipientInfo(infos,
            (KeyAgreeRecipientInfo)recipInfo, messageAlgorithm, secureReadable, additionalData);
    }
    else if (recipInfo instanceof PasswordRecipientInfo)
    {
        infos.add(new PasswordRecipientInformation(
            (PasswordRecipientInfo)recipInfo, messageAlgorithm, secureReadable, additionalData));
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:CMSEnvelopedHelper.java

示例2: buildRecipientInformationStore

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
static RecipientInformationStore buildRecipientInformationStore(
    ASN1Set recipientInfos, AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    List infos = new ArrayList();
    for (int i = 0; i != recipientInfos.size(); i++)
    {
        RecipientInfo info = RecipientInfo.getInstance(recipientInfos.getObjectAt(i));

        readRecipientInfo(infos, info, messageAlgorithm, secureReadable, additionalData);
    }
    return new RecipientInformationStore(infos);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:13,代码来源:CMSEnvelopedHelper.java

示例3: generate

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
public final RecipientInfo generate(GenericKey contentEncryptionKey)
    throws CMSException
{
    try
    {
        ASN1OctetString encryptedKey = new DEROctetString(wrapper.generateWrappedKey(contentEncryptionKey));

        return new RecipientInfo(new KEKRecipientInfo(kekIdentifier, wrapper.getAlgorithmIdentifier(), encryptedKey));
    }
    catch (OperatorException e)
    {
        throw new CMSException("exception wrapping content key: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:KEKRecipientInfoGenerator.java

示例4: generate

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
public RecipientInfo generate(GenericKey contentEncryptionKey)
    throws CMSException
{
    OriginatorIdentifierOrKey originator = new OriginatorIdentifierOrKey(
            createOriginatorPublicKey(originatorKeyInfo));

    ASN1EncodableVector params = new ASN1EncodableVector();
    params.add(keyEncryptionOID);
    params.add(DERNull.INSTANCE);
    AlgorithmIdentifier keyEncAlg = new AlgorithmIdentifier(keyEncryptionOID, DERNull.INSTANCE);
    AlgorithmIdentifier keyAgreeAlg = new AlgorithmIdentifier(keyAgreementOID, keyEncAlg);

    ASN1Sequence recipients = generateRecipientEncryptedKeys(keyAgreeAlg, keyEncAlg, contentEncryptionKey);
    ASN1Encodable userKeyingMaterial = getUserKeyingMaterial(keyAgreeAlg);

    if (userKeyingMaterial != null)
    {
        try
        {
            return new RecipientInfo(new KeyAgreeRecipientInfo(originator, new DEROctetString(userKeyingMaterial),
                keyAgreeAlg, recipients));
        }
        catch (IOException e)
        {
            throw new CMSException("unable to encode userKeyingMaterial: " + e.getMessage(), e);
        }
    }
    else
    {
        return new RecipientInfo(new KeyAgreeRecipientInfo(originator, null,
            keyAgreeAlg, recipients));
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:KeyAgreeRecipientInfoGenerator.java

示例5: createDERForRecipient

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert) 
    throws IOException,  
           GeneralSecurityException 
{
    
    String s = "1.2.840.113549.3.2";
    
    AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
    AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
    ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
    ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
    ASN1Primitive derobject = asn1inputstream.readObject();
    KeyGenerator keygenerator = KeyGenerator.getInstance(s);
    keygenerator.init(128);
    SecretKey secretkey = keygenerator.generateKey();
    Cipher cipher = Cipher.getInstance(s);
    cipher.init(1, secretkey, algorithmparameters);
    byte[] abyte1 = cipher.doFinal(in);
    DEROctetString deroctetstring = new DEROctetString(abyte1);
    KeyTransRecipientInfo keytransrecipientinfo = computeRecipientInfo(cert, secretkey.getEncoded());
    DERSet derset = new DERSet(new RecipientInfo(keytransrecipientinfo));
    AlgorithmIdentifier algorithmidentifier = new AlgorithmIdentifier(new ASN1ObjectIdentifier(s), derobject);
    EncryptedContentInfo encryptedcontentinfo = 
        new EncryptedContentInfo(PKCSObjectIdentifiers.data, algorithmidentifier, deroctetstring);
    EnvelopedData env = new EnvelopedData(null, derset, encryptedcontentinfo, (org.bouncycastle.asn1.ASN1Set) null);
    ContentInfo contentinfo = 
        new ContentInfo(PKCSObjectIdentifiers.envelopedData, env);
    return contentinfo.toASN1Primitive();        
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:PdfPublicKeySecurityHandler.java

示例6: generate

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
public RecipientInfo generate(GenericKey contentEncryptionKey)
    throws CMSException
{
    OriginatorIdentifierOrKey originator = new OriginatorIdentifierOrKey(
            createOriginatorPublicKey(originatorKeyInfo));

    AlgorithmIdentifier keyEncAlg;
    if (CMSUtils.isDES(keyEncryptionOID.getId()) || keyEncryptionOID.equals(PKCSObjectIdentifiers.id_alg_CMSRC2wrap))
    {
        keyEncAlg = new AlgorithmIdentifier(keyEncryptionOID, DERNull.INSTANCE);
    }
    else
    {
        keyEncAlg = new AlgorithmIdentifier(keyEncryptionOID);
    }

    AlgorithmIdentifier keyAgreeAlg = new AlgorithmIdentifier(keyAgreementOID, keyEncAlg);

    ASN1Sequence recipients = generateRecipientEncryptedKeys(keyAgreeAlg, keyEncAlg, contentEncryptionKey);
    byte[] userKeyingMaterial = getUserKeyingMaterial(keyAgreeAlg);

    if (userKeyingMaterial != null)
    {
        return new RecipientInfo(new KeyAgreeRecipientInfo(originator, new DEROctetString(userKeyingMaterial),
                keyAgreeAlg, recipients));

    }
    else
    {
        return new RecipientInfo(new KeyAgreeRecipientInfo(originator, null, keyAgreeAlg, recipients));
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:33,代码来源:KeyAgreeRecipientInfoGenerator.java

示例7: generate

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
public RecipientInfo generate(GenericKey contentEncryptionKey)
    throws CMSException
{
    byte[] iv = new byte[blockSize];     /// TODO: set IV size properly!

    if (random == null)
    {
        random = new SecureRandom();
    }
    
    random.nextBytes(iv);

    if (keyDerivationAlgorithm == null)
    {
        byte[] salt = new byte[20];

        random.nextBytes(salt);

        keyDerivationAlgorithm = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_PBKDF2, new PBKDF2Params(salt, 1024));
    }

    byte[] derivedKey = calculateDerivedKey(schemeID, keyDerivationAlgorithm, keySize);

    AlgorithmIdentifier kekAlgorithmId = new AlgorithmIdentifier(kekAlgorithm, new DEROctetString(iv));

    byte[] encryptedKeyBytes = generateEncryptedBytes(kekAlgorithmId, derivedKey, contentEncryptionKey);

    ASN1OctetString encryptedKey = new DEROctetString(encryptedKeyBytes);

    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(kekAlgorithm);
    v.add(new DEROctetString(iv));

    AlgorithmIdentifier keyEncryptionAlgorithm = new AlgorithmIdentifier(
        PKCSObjectIdentifiers.id_alg_PWRI_KEK, new DERSequence(v));

    return new RecipientInfo(new PasswordRecipientInfo(keyDerivationAlgorithm,
        keyEncryptionAlgorithm, encryptedKey));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:40,代码来源:PasswordRecipientInfoGenerator.java

示例8: generate

import org.bouncycastle.asn1.cms.RecipientInfo; //导入依赖的package包/类
RecipientInfo generate(GenericKey contentEncryptionKey)
throws CMSException;
 
开发者ID:Appdome,项目名称:ipack,代码行数:3,代码来源:RecipientInfoGenerator.java


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