Search in sources :

Example 1 with RecipientKeyIdentifier

use of com.github.zhenwei.pkix.util.asn1.cms.RecipientKeyIdentifier in project LinLong-Java by zhenwei1108.

the class JceKeyAgreeRecipientInfoGenerator method addRecipient.

/**
 * Add a recipient identified by the passed in subjectKeyID and the for the passed in public key.
 *
 * @param subjectKeyID identifier actual recipient will use to match the private key.
 * @param publicKey    the public key for encrypting the secret key.
 * @return the current instance.
 * @throws CertificateEncodingException
 */
public JceKeyAgreeRecipientInfoGenerator addRecipient(byte[] subjectKeyID, PublicKey publicKey) throws CertificateEncodingException {
    recipientIDs.add(new KeyAgreeRecipientIdentifier(new RecipientKeyIdentifier(subjectKeyID)));
    recipientKeys.add(publicKey);
    return this;
}
Also used : RecipientKeyIdentifier(com.github.zhenwei.pkix.util.asn1.cms.RecipientKeyIdentifier) KeyAgreeRecipientIdentifier(com.github.zhenwei.pkix.util.asn1.cms.KeyAgreeRecipientIdentifier)

Example 2 with RecipientKeyIdentifier

use of com.github.zhenwei.pkix.util.asn1.cms.RecipientKeyIdentifier in project LinLong-Java by zhenwei1108.

the class KeyAgreeRecipientInformation method readRecipientInfo.

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));
    }
}
Also used : IssuerAndSerialNumber(com.github.zhenwei.pkix.util.asn1.cms.IssuerAndSerialNumber) ASN1Sequence(com.github.zhenwei.core.asn1.ASN1Sequence) RecipientEncryptedKey(com.github.zhenwei.pkix.util.asn1.cms.RecipientEncryptedKey) RecipientKeyIdentifier(com.github.zhenwei.pkix.util.asn1.cms.RecipientKeyIdentifier) KeyAgreeRecipientIdentifier(com.github.zhenwei.pkix.util.asn1.cms.KeyAgreeRecipientIdentifier)

Aggregations

KeyAgreeRecipientIdentifier (com.github.zhenwei.pkix.util.asn1.cms.KeyAgreeRecipientIdentifier)2 RecipientKeyIdentifier (com.github.zhenwei.pkix.util.asn1.cms.RecipientKeyIdentifier)2 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)1 IssuerAndSerialNumber (com.github.zhenwei.pkix.util.asn1.cms.IssuerAndSerialNumber)1 RecipientEncryptedKey (com.github.zhenwei.pkix.util.asn1.cms.RecipientEncryptedKey)1