Sto cercando di estendere la classe java.security.spec.EllipticCurve nella seguente maniera:
codice:
package java.security.spec;
import java.math.BigInteger;
public class MyEllipticCurve extends EllipticCurve {
public static final BigInteger FOUR=new BigInteger("4");
public static final BigInteger TW_FOUR=new BigInteger("27");
public MyEllipticCurve(ECField field, BigInteger a, BigInteger b,
byte[] seed) {
super(field, a, b, seed);
// TODO Auto-generated constructor stub
}
public MyEllipticCurve(ECField field, BigInteger a, BigInteger b) {
super(field, a, b);
// TODO Auto-generated constructor stub
}
public BigInteger getDelta(){
BigInteger first = getA().pow(3).multiply(FOUR);
BigInteger second = getB().pow(2).multiply(TW_FOUR);
BigInteger delta = first.add(second);
return delta;
}//getDelta
}
ma ho dei problemi per quanto riguarda la sua classe di test:
codice:
package esercizi;
import java.math.BigInteger;
import java.security.*;
import java.security.spec.ECFieldFp;
import java.security.spec.EllipticCurve;
import java.security.spec.MyEllipticCurve;
import algebra.BigIntegerMath;
public class EllipticCurveTest {
public static void main(String[] args) {
// TODO code application logic here
//lunghezza in bit del numero p del campo Z[p]
int byteLength = 8;
SecureRandom sr = new SecureRandom();
//numero di test
int numberBases = (int)(Math.random()*10)+1;
//numero da testare
BigInteger p=null;
//grandezza del numero
byte[] ba=null;
//genera un numero primo tramite test di Miller Rabin
do {
ba=new byte[byteLength];
sr.nextBytes(ba);
p=new BigInteger(1,ba);
} while (BigIntegerMath.primeProbability(p,numberBases,sr)==0);
//campo finito primo
ECFieldFp f = new ECFieldFp(p);
BigInteger a = BigInteger.ONE;
BigInteger b = BigInteger.valueOf(19L);
byte[] seed = new byte[24];
//rappresenta il primo test
MyEllipticCurve e = new MyEllipticCurve(f, a, b, seed);
//output della curva al primo test
System.out.println("E(Z["+p+"]) : Y^2 = X^3 + "+e.getA()+"X + "+e.getB());
System.out.println("delta = "+e.getDelta());
}
}
il cui output consiste nel seguente messaggio di errore:
codice:
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.security.spec
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at esercizi.EllipticCurveTest.main(EllipticCurveTest.java:40)