X9ECPoint.java revision e6bf3e8dfa2804891a82075cb469b736321b4827
1package org.bouncycastle.asn1.x9;
2
3import org.bouncycastle.asn1.ASN1Object;
4import org.bouncycastle.asn1.ASN1OctetString;
5import org.bouncycastle.asn1.ASN1Primitive;
6import org.bouncycastle.asn1.DEROctetString;
7import org.bouncycastle.math.ec.ECCurve;
8import org.bouncycastle.math.ec.ECPoint;
9
10/**
11 * class for describing an ECPoint as a DER object.
12 */
13public class X9ECPoint
14    extends ASN1Object
15{
16    ECPoint p;
17
18    public X9ECPoint(
19        ECPoint p)
20    {
21        this.p = p;
22    }
23
24    public X9ECPoint(
25        ECCurve          c,
26        ASN1OctetString  s)
27    {
28        this.p = c.decodePoint(s.getOctets());
29    }
30
31    public ECPoint getPoint()
32    {
33        return p;
34    }
35
36    /**
37     * Produce an object suitable for an ASN1OutputStream.
38     * <pre>
39     *  ECPoint ::= OCTET STRING
40     * </pre>
41     * <p>
42     * Octet string produced using ECPoint.getEncoded().
43     */
44    public ASN1Primitive toASN1Primitive()
45    {
46        return new DEROctetString(p.getEncoded());
47    }
48}
49