CmsAuthEnvelopedData
class CmsAuthEnvelopedData
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Cms;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto.Parameters;
using System.IO;
namespace Org.BouncyCastle.Cms
{
internal class CmsAuthEnvelopedData
{
private class AuthEnvelopedSecureReadable : CmsSecureReadable
{
private readonly CmsAuthEnvelopedData m_parent;
public AlgorithmIdentifier Algorithm => m_parent.ContentEncryptionAlgorithm;
public object CryptoObject => null;
internal AuthEnvelopedSecureReadable(CmsAuthEnvelopedData parent)
{
m_parent = parent;
}
public CmsReadable GetReadable(KeyParameter key)
{
throw new CmsException("AuthEnveloped data decryption not yet implemented");
}
}
private readonly ContentInfo m_contentInfo;
private readonly AuthEnvelopedData m_authEnvelopedData;
private readonly RecipientInformationStore m_recipientInfoStore;
public AuthEnvelopedData AuthEnvelopedData => m_authEnvelopedData;
public AlgorithmIdentifier ContentEncryptionAlgorithm => AuthEnvelopedData.AuthEncryptedContentInfo.ContentEncryptionAlgorithm;
public CmsAuthEnvelopedData(byte[] authEnvData)
: this(CmsUtilities.ReadContentInfo(authEnvData))
{
}
public CmsAuthEnvelopedData(Stream authEnvData)
: this(CmsUtilities.ReadContentInfo(authEnvData))
{
}
public CmsAuthEnvelopedData(ContentInfo contentInfo)
{
m_contentInfo = contentInfo;
m_authEnvelopedData = AuthEnvelopedData.GetInstance(contentInfo.Content);
Asn1Set recipientInfos = m_authEnvelopedData.RecipientInfos;
CmsSecureReadable secureReadable = new AuthEnvelopedSecureReadable(this);
m_recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
}
public Org.BouncyCastle.Asn1.Cms.AttributeTable GetAuthAttrs()
{
Asn1Set authAttrs = AuthEnvelopedData.AuthAttrs;
if (authAttrs == null)
return null;
return authAttrs.ToAttributeTable();
}
public Org.BouncyCastle.Asn1.Cms.AttributeTable GetUnauthAttrs()
{
Asn1Set unauthAttrs = AuthEnvelopedData.UnauthAttrs;
if (unauthAttrs == null)
return null;
return unauthAttrs.ToAttributeTable();
}
}
}