summary refs log tree commit diff
path: root/crypto/src/asn1/ess/ContentIdentifier.cs
blob: 0520653f3c430239e4d07f6bb458086dd58b42f3 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;

namespace Org.BouncyCastle.Asn1.Ess
{
    public class ContentIdentifier
		: Asn1Encodable
	{
        public static ContentIdentifier GetInstance(object o)
        {
            if (o == null)
                return null;
            if (o is ContentIdentifier contentIdentifier)
                return contentIdentifier;
            return new ContentIdentifier(Asn1OctetString.GetInstance(o));
        }

        public static ContentIdentifier GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
        {
            return new ContentIdentifier(Asn1OctetString.GetInstance(taggedObject, declaredExplicit));
        }

        private readonly Asn1OctetString m_value;

        /**
		 * Create from OCTET STRING whose octets represent the identifier.
		 */
        public ContentIdentifier(Asn1OctetString value)
        {
            m_value = value ?? throw new ArgumentNullException(nameof(value));
        }

        /**
		 * Create from byte array representing the identifier.
		 */
        public ContentIdentifier(byte[] value)
			: this(new DerOctetString(value))
		{
		}

		public Asn1OctetString Value => m_value;

		/**
		 * The definition of ContentIdentifier is
		 * <pre>
		 * ContentIdentifier ::=  OCTET STRING
		 * </pre>
		 * id-aa-contentIdentifier OBJECT IDENTIFIER ::= { iso(1)
		 *  member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9)
		 *  smime(16) id-aa(2) 7 }
		 */
		public override Asn1Object ToAsn1Object() => m_value;
	}
}