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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Asn1.CryptoPro
{
public class ECGost3410ParamSetParameters
: Asn1Encodable
{
public static ECGost3410ParamSetParameters GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is ECGost3410ParamSetParameters ecGost3410ParamSetParameters)
return ecGost3410ParamSetParameters;
#pragma warning disable CS0618 // Type or member is obsolete
return new ECGost3410ParamSetParameters(Asn1Sequence.GetInstance(obj));
#pragma warning restore CS0618 // Type or member is obsolete
}
public static ECGost3410ParamSetParameters GetInstance(Asn1TaggedObject obj, bool explicitly)
{
#pragma warning disable CS0618 // Type or member is obsolete
return new ECGost3410ParamSetParameters(Asn1Sequence.GetInstance(obj, explicitly));
#pragma warning restore CS0618 // Type or member is obsolete
}
public static ECGost3410ParamSetParameters GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
#pragma warning disable CS0618 // Type or member is obsolete
return new ECGost3410ParamSetParameters(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
#pragma warning restore CS0618 // Type or member is obsolete
}
private readonly DerInteger m_a, m_b, m_p, m_q, m_x, m_y;
[Obsolete("Use 'GetInstance' instead")]
public ECGost3410ParamSetParameters(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 6)
throw new ArgumentException("Bad sequence size: " + count, nameof(seq));
m_a = DerInteger.GetInstance(seq[0]);
m_b = DerInteger.GetInstance(seq[1]);
m_p = DerInteger.GetInstance(seq[2]);
m_q = DerInteger.GetInstance(seq[3]);
m_x = DerInteger.GetInstance(seq[4]);
m_y = DerInteger.GetInstance(seq[5]);
}
public ECGost3410ParamSetParameters(BigInteger a, BigInteger b, BigInteger p, BigInteger q, int x,
BigInteger y)
{
m_a = new DerInteger(a);
m_b = new DerInteger(b);
m_p = new DerInteger(p);
m_q = new DerInteger(q);
m_x = new DerInteger(x);
m_y = new DerInteger(y);
}
public BigInteger A => m_a.PositiveValue;
public BigInteger B => m_b.PositiveValue;
public BigInteger P => m_p.PositiveValue;
public BigInteger Q => m_q.PositiveValue;
int X => m_x.IntPositiveValueExact;
public BigInteger Y => m_y.PositiveValue;
public override Asn1Object ToAsn1Object() => new DerSequence(m_a, m_b, m_p, m_q, m_x, m_y);
}
}
|