1package org.bouncycastle.asn1.x9;
2
3import org.bouncycastle.asn1.ASN1Integer;
4import org.bouncycastle.asn1.ASN1Object;
5import org.bouncycastle.asn1.ASN1Primitive;
6import org.bouncycastle.asn1.ASN1TaggedObject;
7
8public class DHPublicKey
9    extends ASN1Object
10{
11    private ASN1Integer y;
12
13    public static DHPublicKey getInstance(ASN1TaggedObject obj, boolean explicit)
14    {
15        return getInstance(ASN1Integer.getInstance(obj, explicit));
16    }
17
18    public static DHPublicKey getInstance(Object obj)
19    {
20        if (obj == null || obj instanceof DHPublicKey)
21        {
22            return (DHPublicKey)obj;
23        }
24
25        if (obj instanceof ASN1Integer)
26        {
27            return new DHPublicKey((ASN1Integer)obj);
28        }
29
30        throw new IllegalArgumentException("Invalid DHPublicKey: " + obj.getClass().getName());
31    }
32
33    public DHPublicKey(ASN1Integer y)
34    {
35        if (y == null)
36        {
37            throw new IllegalArgumentException("'y' cannot be null");
38        }
39
40        this.y = y;
41    }
42
43    public ASN1Integer getY()
44    {
45        return this.y;
46    }
47
48    public ASN1Primitive toASN1Primitive()
49    {
50        return this.y;
51    }
52}
53