Home | History | Annotate | Download | only in sec
      1 package org.bouncycastle.math.ec.custom.sec;
      2 
      3 import java.math.BigInteger;
      4 
      5 import org.bouncycastle.math.ec.ECCurve;
      6 import org.bouncycastle.math.ec.ECFieldElement;
      7 import org.bouncycastle.math.ec.ECPoint;
      8 import org.bouncycastle.util.encoders.Hex;
      9 
     10 public class SecP384R1Curve extends ECCurve.AbstractFp
     11 {
     12     public static final BigInteger q = new BigInteger(1,
     13         Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF"));
     14 
     15     private static final int SecP384R1_DEFAULT_COORDS = COORD_JACOBIAN;
     16 
     17     protected SecP384R1Point infinity;
     18 
     19     public SecP384R1Curve()
     20     {
     21         super(q);
     22 
     23         this.infinity = new SecP384R1Point(this, null, null);
     24 
     25         this.a = fromBigInteger(new BigInteger(1,
     26             Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")));
     27         this.b = fromBigInteger(new BigInteger(1,
     28             Hex.decode("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")));
     29         this.order = new BigInteger(1, Hex.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973"));
     30         this.cofactor = BigInteger.valueOf(1);
     31 
     32         this.coord = SecP384R1_DEFAULT_COORDS;
     33     }
     34 
     35     protected ECCurve cloneCurve()
     36     {
     37         return new SecP384R1Curve();
     38     }
     39 
     40     public boolean supportsCoordinateSystem(int coord)
     41     {
     42         switch (coord)
     43         {
     44         case COORD_JACOBIAN:
     45             return true;
     46         default:
     47             return false;
     48         }
     49     }
     50 
     51     public BigInteger getQ()
     52     {
     53         return q;
     54     }
     55 
     56     public int getFieldSize()
     57     {
     58         return q.bitLength();
     59     }
     60 
     61     public ECFieldElement fromBigInteger(BigInteger x)
     62     {
     63         return new SecP384R1FieldElement(x);
     64     }
     65 
     66     protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression)
     67     {
     68         return new SecP384R1Point(this, x, y, withCompression);
     69     }
     70 
     71     protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression)
     72     {
     73         return new SecP384R1Point(this, x, y, zs, withCompression);
     74     }
     75 
     76     public ECPoint getInfinity()
     77     {
     78         return infinity;
     79     }
     80 }
     81