summary refs log tree commit diff
path: root/crypto/src/asn1/pkcs/EncryptionScheme.cs
blob: 9834e15237b7ff8172534b43c9b62ccb188d25c0 (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
using Org.BouncyCastle.Asn1.X509;

namespace Org.BouncyCastle.Asn1.Pkcs
{
    // TODO[api] This is not supposed to be a separate type; remove and use AlgorithmIdentifier
    public class EncryptionScheme
        : AlgorithmIdentifier
    {
        public new static EncryptionScheme GetInstance(object obj)
        {
            if (obj == null)
                return null;
            if (obj is EncryptionScheme encryptionScheme)
                return encryptionScheme;
            return new EncryptionScheme(Asn1Sequence.GetInstance(obj));
        }

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

        public EncryptionScheme(
            DerObjectIdentifier	objectID)
            : base(objectID)
        {
        }

        public EncryptionScheme(
            DerObjectIdentifier	objectID,
            Asn1Encodable		parameters)
			: base(objectID, parameters)
		{
		}

		internal EncryptionScheme(
			Asn1Sequence seq)
			: this((DerObjectIdentifier)seq[0], seq[1])
        {
        }

		public Asn1Object Asn1Object
		{
			get { return Parameters.ToAsn1Object(); }
		}

		public override Asn1Object ToAsn1Object()
        {
            return new DerSequence(Algorithm, Parameters);
        }
    }
}