?? elgamalkeypairgenerator.java
字號:
package org.bouncycastle.crypto.generators;import java.math.BigInteger;import org.bouncycastle.crypto.AsymmetricCipherKeyPair;import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;import org.bouncycastle.crypto.KeyGenerationParameters;import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;import org.bouncycastle.crypto.params.ElGamalParameters;import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;/** * a ElGamal key pair generator. * <p> * This generates keys consistent for use with ElGamal as described in * page 164 of "Handbook of Applied Cryptography". */public class ElGamalKeyPairGenerator implements AsymmetricCipherKeyPairGenerator{ private ElGamalKeyGenerationParameters param; public void init( KeyGenerationParameters param) { this.param = (ElGamalKeyGenerationParameters)param; } public AsymmetricCipherKeyPair generateKeyPair() { BigInteger p, g, x, y; int qLength = param.getStrength() - 1; ElGamalParameters elParams = param.getParameters(); p = elParams.getP(); g = elParams.getG(); // // calculate the private key // x = new BigInteger(qLength, param.getRandom()); // // calculate the public key. // y = g.modPow(x, p); return new AsymmetricCipherKeyPair( new ElGamalPublicKeyParameters(y, elParams), new ElGamalPrivateKeyParameters(x, elParams)); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -