summary refs log tree commit diff
path: root/crypto/src/asn1/x9/KeySpecificInfo.cs
blob: 8e5fb9ea754f6914fd2ffd28a13f4b204589e35b (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
namespace Org.BouncyCastle.Asn1.X9
{
    /**
     * ASN.1 def for Diffie-Hellman key exchange KeySpecificInfo structure. See
     * RFC 2631, or X9.42, for further details.
     */
    public class KeySpecificInfo
        : Asn1Encodable
    {
        private DerObjectIdentifier	algorithm;
        private Asn1OctetString		counter;

		public KeySpecificInfo(
            DerObjectIdentifier	algorithm,
            Asn1OctetString		counter)
        {
            this.algorithm = algorithm;
            this.counter = counter;
        }

		public KeySpecificInfo(Asn1Sequence seq)
        {
            var e = seq.GetEnumerator();

			e.MoveNext();
            algorithm = (DerObjectIdentifier)e.Current;
            e.MoveNext();
            counter = (Asn1OctetString)e.Current;
        }

		public DerObjectIdentifier Algorithm
        {
            get { return algorithm; }
        }

		public Asn1OctetString Counter
        {
            get { return counter; }
        }

		/**
         * Produce an object suitable for an Asn1OutputStream.
         * <pre>
         *  KeySpecificInfo ::= Sequence {
         *      algorithm OBJECT IDENTIFIER,
         *      counter OCTET STRING SIZE (4..4)
         *  }
         * </pre>
         */
        public override Asn1Object ToAsn1Object()
        {
			return new DerSequence(algorithm, counter);
        }
    }
}