summary refs log tree commit diff
path: root/crypto/src/asn1/cms/EncryptedContentInfoParser.cs
blob: 42f72164a7de8960c10d21dac032a5609512bed0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;

using Org.BouncyCastle.Asn1.X509;

namespace Org.BouncyCastle.Asn1.Cms
{
	/**
	* <pre>
	* EncryptedContentInfo ::= SEQUENCE {
	*     contentType ContentType,
	*     contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
	*     encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
	* }
	* </pre>
	*/
	public class EncryptedContentInfoParser
	{
		private readonly DerObjectIdentifier m_contentType;
		private readonly AlgorithmIdentifier m_contentEncryptionAlgorithm;
		private readonly Asn1TaggedObjectParser	m_encryptedContent;

		public EncryptedContentInfoParser(Asn1SequenceParser seq)
		{
			m_contentType = (DerObjectIdentifier)seq.ReadObject();
			m_contentEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq.ReadObject().ToAsn1Object());
			m_encryptedContent = (Asn1TaggedObjectParser)seq.ReadObject();
		}

		public DerObjectIdentifier ContentType => m_contentType;

		public AlgorithmIdentifier ContentEncryptionAlgorithm => m_contentEncryptionAlgorithm;

		public IAsn1Convertible GetEncryptedContent(int tag)
		{
			return Asn1Utilities.ParseContextBaseUniversal(m_encryptedContent, 0, false, tag);
		}
	}
}