请教高手,把所有分都给了!
这是一个ELGAMAL签名算法,这里有五个类,我想问下怎么能实现他们之间互相调用,还有就是在运行3和4时提示不是抽象的,并且未覆盖java.security.key中的抽象方法getencoded() public class ELGamalPublicKey/ELGamalPrivateKey.
在运行5的时候提示使用或覆盖了已过时的API,请高手帮我看看是怎么回事,谢谢各位了!!
1.
import java.math.BigInteger;
import java.security.*;
public class ElGamalKey
implements Key {
private BigInteger mP, mG;
protected ElGamalKey(BigInteger g, BigInteger p) {
mG = g;
mP = p;
}
protected BigInteger getG() { return mG; }
protected BigInteger getP() { return mP; }
public String getAlgorithm() { return "ElGamal "; }
public String getFormat() { return "NONE "; }
public byte[] getEncoded() { return null; }
}
2.
import java.math.BigInteger;
import java.security.*;
public class ElGamalKeyPairGenerator
extends KeyPairGeneratorSpi {
private int mStrength = 0;
private SecureRandom mSecureRandom = null;
// Strength is interpreted as the bit length of p.
public void initialize(int strength, SecureRandom random) {
mStrength = strength;
mSecureRandom = random;
}
public KeyPair generateKeyPair() {
if (mSecureRandom == null) {
mStrength = 1024;
mSecureRandom = new SecureRandom();
}
BigInteger p = new BigInteger(mStrength, 16, mSecureRandom);
BigInteger g = new BigInteger(mStrength - 1, mSecureRandom);
BigInteger x = new BigInteger(mStrength - 1, mSecureRandom);
BigInteger y = g.modPow(x, p);
ElGamalPublicKey publicKey = new ElGamalPublicKey(y, g, p);
ElGamalPrivateKey privateKey = new ElGamalPrivateKey(x, g, p);
return new KeyPair(publicKey, privateKey);
}
}
3.
import java.math.BigInteger;
import java.security.*;
public class ElGamalPrivateKey
extends ElGamalKey
implements PrivateKey {
private BigInteger mX;