1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.crypto.params;
2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
3c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstromimport org.bouncycastle.util.Arrays;
4c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
5b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic class DSAValidationParameters
6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{
7a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    private int usageIndex;
8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    private byte[]  seed;
9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    private int     counter;
10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public DSAValidationParameters(
12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        byte[]  seed,
13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        int     counter)
14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
15a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        this(seed, counter, -1);
16a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    }
17a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom
18a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    public DSAValidationParameters(
19a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        byte[]  seed,
20a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        int     counter,
21a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        int     usageIndex)
22a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    {
23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        this.seed = seed;
24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        this.counter = counter;
25a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        this.usageIndex = usageIndex;
26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
27b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public int getCounter()
29b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return counter;
31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
32b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public byte[] getSeed()
34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        return seed;
36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
38a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    public int getUsageIndex()
39a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    {
40a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom        return usageIndex;
41a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom    }
42a198e1ecc615e26a167d0f2dca9fa7e5fc62de10Brian Carlstrom
43c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    public int hashCode()
44c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    {
45c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        return counter ^ Arrays.hashCode(seed);
46c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom    }
47c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom
48b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public boolean equals(
49b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        Object o)
50b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    {
51b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (!(o instanceof DSAValidationParameters))
52b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
53b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return false;
54b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
55b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
56b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        DSAValidationParameters  other = (DSAValidationParameters)o;
57b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
58b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        if (other.counter != this.counter)
59b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        {
60b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam            return false;
61b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        }
62b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
63c37f4a04ef89e73a39a59f3c5a179af8c8ab5974Brian Carlstrom        return Arrays.areEqual(this.seed, other.seed);
64b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    }
65b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam}
66