summary refs log tree commit diff
path: root/crypto/src/asn1/esf/OtherRevVals.cs
blob: 6459f06573f2fa57211e84096d767685f5e09d95 (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
54
55
56
57
58
59
60
61
62
using System;

namespace Org.BouncyCastle.Asn1.Esf
{
    /// <remarks>
    /// RFC 3126: 4.3.2 Revocation Values Attribute Definition
    /// <code>
    /// OtherRevVals ::= SEQUENCE 
    /// {
    ///		otherRevValType      OtherRevValType,
    ///		otherRevVals         ANY DEFINED BY otherRevValType
    /// }
    ///
    /// OtherRevValType ::= OBJECT IDENTIFIER
    /// </code>
    /// </remarks>
    public class OtherRevVals
		: Asn1Encodable
	{
        public static OtherRevVals GetInstance(object obj)
        {
			if (obj == null)
				return null;
            if (obj is OtherRevVals otherRevVals)
                return otherRevVals;
            return new OtherRevVals(Asn1Sequence.GetInstance(obj));
        }

        public static OtherRevVals GetInstance(Asn1TaggedObject obj, bool explicitly)
        {
            return new OtherRevVals(Asn1Sequence.GetInstance(obj, explicitly));
        }

        private readonly DerObjectIdentifier m_otherRevValType;
        private readonly Asn1Encodable m_otherRevVals;

        private OtherRevVals(Asn1Sequence seq)
		{
			int count = seq.Count;
			if (count != 2)
				throw new ArgumentException("Bad sequence size: " + count, nameof(seq));

			m_otherRevValType = DerObjectIdentifier.GetInstance(seq[0]);
			m_otherRevVals = seq[1];
		}

        public OtherRevVals(DerObjectIdentifier otherRevValType, Asn1Encodable otherRevVals)
        {
            m_otherRevValType = otherRevValType ?? throw new ArgumentNullException(nameof(otherRevValType));
            m_otherRevVals = otherRevVals ?? throw new ArgumentNullException(nameof(otherRevVals));
        }

		public DerObjectIdentifier OtherRevValType => m_otherRevValType;

		public Asn1Encodable OtherRevValsData => m_otherRevVals;

        [Obsolete("Use 'OtherRevValsData' instead")]
        public Asn1Object OtherRevValsObject => m_otherRevVals.ToAsn1Object();

		public override Asn1Object ToAsn1Object() => new DerSequence(m_otherRevValType, m_otherRevVals);
	}
}