Java 类org.bouncycastle.asn1.cms.KeyAgreeRecipientInfo 实例源码

项目:ipack    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:gwt-crypto    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:Aki-SSL    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:irma_future_id    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:irma_future_id    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:irma_future_id    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:irma_future_id    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:bc-java    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:bc-java    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:bc-java    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:bc-java    文件:CMSEnvelopedHelper.java   
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));
    }
}
项目:ipack    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:ipack    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:ipack    文件:KeyAgreeRecipientInfoGenerator.java   
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));
    }
}
项目:gwt-crypto    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:gwt-crypto    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:gwt-crypto    文件:KeyAgreeRecipientInfoGenerator.java   
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));
    }
}
项目:Aki-SSL    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:Aki-SSL    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:Aki-SSL    文件:KeyAgreeRecipientInfoGenerator.java   
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));
    }
}
项目:irma_future_id    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:irma_future_id    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:irma_future_id    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:irma_future_id    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:irma_future_id    文件:KeyAgreeRecipientInfoGenerator.java   
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));
    }
}
项目:bc-java    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:bc-java    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:bc-java    文件:KeyAgreeRecipientInformation.java   
static void readRecipientInfo(List infos, KeyAgreeRecipientInfo info,
    AlgorithmIdentifier messageAlgorithm, CMSSecureReadable secureReadable, AuthAttributesProvider additionalData)
{
    ASN1Sequence s = info.getRecipientEncryptedKeys();

    for (int i = 0; i < s.size(); ++i)
    {
        RecipientEncryptedKey id = RecipientEncryptedKey.getInstance(
            s.getObjectAt(i));

        RecipientId rid;

        KeyAgreeRecipientIdentifier karid = id.getIdentifier();
        IssuerAndSerialNumber iAndSN = karid.getIssuerAndSerialNumber();

        if (iAndSN != null)
        {
            rid = new KeyAgreeRecipientId(iAndSN.getName(), iAndSN.getSerialNumber().getValue());
        }
        else
        {
            RecipientKeyIdentifier rKeyID = karid.getRKeyID();

            // Note: 'date' and 'other' fields of RecipientKeyIdentifier appear to be only informational

            rid = new KeyAgreeRecipientId(rKeyID.getSubjectKeyIdentifier().getOctets());
        }

        infos.add(new KeyAgreeRecipientInformation(info, rid, id.getEncryptedKey(), messageAlgorithm,
            secureReadable, additionalData));
    }
}
项目:bc-java    文件:KeyAgreeRecipientInformation.java   
KeyAgreeRecipientInformation(
    KeyAgreeRecipientInfo   info,
    RecipientId             rid,
    ASN1OctetString         encryptedKey,
    AlgorithmIdentifier     messageAlgorithm,
    CMSSecureReadable       secureReadable,
    AuthAttributesProvider  additionalData)
{
    super(info.getKeyEncryptionAlgorithm(), messageAlgorithm, secureReadable, additionalData);

    this.info = info;
    this.rid = rid;
    this.encryptedKey = encryptedKey;
}
项目:bc-java    文件:KeyAgreeRecipientInfoGenerator.java   
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));
    }
}