这是一个比较老的实现ELGamal签名算法的代码,运行时提示使用或覆盖了已过时的API,请高手帮我看看是怎么回事,谢谢各位了!!
这是一个比较老的实现ELGamal签名算法的代码,运行时提示使用或覆盖了已过时的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;
protected ElGamalPrivateKey(BigInteger x, BigInteger g, BigInteger p) {