KeyAgreeRecipientInfo
using Org.BouncyCastle.Asn1.X509;
namespace Org.BouncyCastle.Asn1.Cms
{
public class KeyAgreeRecipientInfo : Asn1Encodable
{
private DerInteger version;
private OriginatorIdentifierOrKey originator;
private Asn1OctetString ukm;
private AlgorithmIdentifier keyEncryptionAlgorithm;
private Asn1Sequence recipientEncryptedKeys;
public DerInteger Version => version;
public OriginatorIdentifierOrKey Originator => originator;
public Asn1OctetString UserKeyingMaterial => ukm;
public AlgorithmIdentifier KeyEncryptionAlgorithm => keyEncryptionAlgorithm;
public Asn1Sequence RecipientEncryptedKeys => recipientEncryptedKeys;
public static KeyAgreeRecipientInfo GetInstance(object obj)
{
if (obj == null)
return null;
KeyAgreeRecipientInfo keyAgreeRecipientInfo = obj as KeyAgreeRecipientInfo;
if (keyAgreeRecipientInfo != null)
return keyAgreeRecipientInfo;
return new KeyAgreeRecipientInfo(Asn1Sequence.GetInstance(obj));
}
public static KeyAgreeRecipientInfo GetInstance(Asn1TaggedObject obj, bool explicitly)
{
return new KeyAgreeRecipientInfo(Asn1Sequence.GetInstance(obj, explicitly));
}
public KeyAgreeRecipientInfo(OriginatorIdentifierOrKey originator, Asn1OctetString ukm, AlgorithmIdentifier keyEncryptionAlgorithm, Asn1Sequence recipientEncryptedKeys)
{
version = new DerInteger(3);
this.originator = originator;
this.ukm = ukm;
this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
this.recipientEncryptedKeys = recipientEncryptedKeys;
}
public KeyAgreeRecipientInfo(Asn1Sequence seq)
{
int num = 0;
version = (DerInteger)seq[num++];
originator = OriginatorIdentifierOrKey.GetInstance((Asn1TaggedObject)seq[num++], true);
Asn1TaggedObject asn1TaggedObject = seq[num] as Asn1TaggedObject;
if (asn1TaggedObject != null) {
ukm = Asn1OctetString.GetInstance(asn1TaggedObject, true);
num++;
}
keyEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[num++]);
recipientEncryptedKeys = (Asn1Sequence)seq[num++];
}
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector(version, new DerTaggedObject(true, 0, originator));
asn1EncodableVector.AddOptionalTagged(true, 1, ukm);
asn1EncodableVector.Add(keyEncryptionAlgorithm, recipientEncryptedKeys);
return new DerSequence(asn1EncodableVector);
}
}
}