本文整理汇总了Java中org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters.getPublicExponent方法的典型用法代码示例。如果您正苦于以下问题:Java RSAPrivateCrtKeyParameters.getPublicExponent方法的具体用法?Java RSAPrivateCrtKeyParameters.getPublicExponent怎么用?Java RSAPrivateCrtKeyParameters.getPublicExponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters
的用法示例。
在下文中一共展示了RSAPrivateCrtKeyParameters.getPublicExponent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JCERSAPrivateCrtKey
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* construct a private key from it's org.bouncycastle.crypto equivalent.
*
* @param key the parameters object representing the private key.
*/
JCERSAPrivateCrtKey(
RSAPrivateCrtKeyParameters key)
{
super(key);
this.publicExponent = key.getPublicExponent();
this.primeP = key.getP();
this.primeQ = key.getQ();
this.primeExponentP = key.getDP();
this.primeExponentQ = key.getDQ();
this.crtCoefficient = key.getQInv();
}
示例2: BCRSAPrivateCrtKey
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* construct a private key from it's org.bouncycastle.crypto equivalent.
*
* @param key the parameters object representing the private key.
*/
BCRSAPrivateCrtKey(
RSAPrivateCrtKeyParameters key)
{
super(key);
this.publicExponent = key.getPublicExponent();
this.primeP = key.getP();
this.primeQ = key.getQ();
this.primeExponentP = key.getDP();
this.primeExponentQ = key.getDQ();
this.crtCoefficient = key.getQInv();
}
示例3: toRSAPrivateKey
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
public static RSAPrivateKey toRSAPrivateKey(RSAPrivateCrtKeyParameters k) throws Exception
{
// hope this is correct
return new RSAPrivateKey
(
k.getModulus(),
k.getPublicExponent(),
k.getExponent(),
k.getP(),
k.getQ(),
k.getDP(),
k.getDQ(),
k.getQInv()
);
}
示例4: TempJCERSAPrivateCrtKey
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* construct a private key from it's org.bouncycastle.crypto equivalent.
*
* @param key the parameters object representing the private key.
*/
TempJCERSAPrivateCrtKey(
RSAPrivateCrtKeyParameters key)
{
super(key);
this.publicExponent = key.getPublicExponent();
this.primeP = key.getP();
this.primeQ = key.getQ();
this.primeExponentP = key.getDP();
this.primeExponentQ = key.getDQ();
this.crtCoefficient = key.getQInv();
}
示例5: processBlock
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* Process a single block using the basic RSA algorithm.
*
* @param in the input array.
* @param inOff the offset into the input buffer where the data starts.
* @param inLen the length of the data to be processed.
* @return the result of the RSA process.
* @exception DataLengthException the input block is too large.
*/
public byte[] processBlock(
byte[] in,
int inOff,
int inLen)
{
if (key == null)
{
throw new IllegalStateException("RSA engine not initialised");
}
BigInteger input = core.convertInput(in, inOff, inLen);
BigInteger result;
if (key instanceof RSAPrivateCrtKeyParameters)
{
RSAPrivateCrtKeyParameters k = (RSAPrivateCrtKeyParameters)key;
BigInteger e = k.getPublicExponent();
if (e != null) // can't do blinding without a public exponent
{
BigInteger m = k.getModulus();
BigInteger r = BigIntegers.createRandomInRange(ONE, m.subtract(ONE), random);
BigInteger blindedInput = r.modPow(e, m).multiply(input).mod(m);
BigInteger blindedResult = core.processBlock(blindedInput);
BigInteger rInv = r.modInverse(m);
result = blindedResult.multiply(rInv).mod(m);
}
else
{
result = core.processBlock(input);
}
}
else
{
result = core.processBlock(input);
}
return core.convertOutput(result);
}
示例6: processBlock
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* Process a single block using the basic RSA algorithm.
*
* @param in the input array.
* @param inOff the offset into the input buffer where the data starts.
* @param inLen the length of the data to be processed.
* @return the result of the RSA process.
* @exception DataLengthException the input block is too large.
*/
public byte[] processBlock(
byte[] in,
int inOff,
int inLen)
{
if (key == null)
{
throw new IllegalStateException("RSA engine not initialised");
}
BigInteger input = core.convertInput(in, inOff, inLen);
BigInteger result;
if (key instanceof RSAPrivateCrtKeyParameters)
{
RSAPrivateCrtKeyParameters k = (RSAPrivateCrtKeyParameters)key;
BigInteger e = k.getPublicExponent();
if (e != null) // can't do blinding without a public exponent
{
BigInteger m = k.getModulus();
BigInteger r = BigIntegers.createRandomInRange(ONE, m.subtract(ONE), random);
BigInteger blindedInput = r.modPow(e, m).multiply(input).mod(m);
BigInteger blindedResult = core.processBlock(blindedInput);
BigInteger rInv = r.modInverse(m);
result = blindedResult.multiply(rInv).mod(m);
// defence against Arjen Lenstra’s CRT attack
if (!input.equals(result.modPow(e, m)))
{
throw new IllegalStateException("RSA engine faulty decryption/signing detected");
}
}
else
{
result = core.processBlock(input);
}
}
else
{
result = core.processBlock(input);
}
return core.convertOutput(result);
}
示例7: getKeySpec
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
private static RSAPrivateCrtKeySpec getKeySpec(RSAPrivateCrtKeyParameters privateKeyParameters) {
return new RSAPrivateCrtKeySpec(privateKeyParameters.getModulus(),
privateKeyParameters.getPublicExponent(), privateKeyParameters.getExponent(),
privateKeyParameters.getP(), privateKeyParameters.getQ(),
privateKeyParameters.getDP(), privateKeyParameters.getDQ(), privateKeyParameters.getQInv());
}
示例8: processBlock
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; //导入方法依赖的package包/类
/**
* Process a single block using the basic RSA algorithm.
*
* @param in the input array.
* @param inOff the offset into the input buffer where the data starts.
* @param inLen the length of the data to be processed.
* @return the result of the RSA process.
* @exception DataLengthException the input block is too large.
*/
@Override
public byte[] processBlock(final byte[] in, final int inOff, final int inLen) {
if (key == null) {
throw new IllegalStateException("RSA engine not initialised");
}
BigInteger input = core.convertInput(in, inOff, inLen);
BigInteger result;
if (key instanceof RSAPrivateCrtKeyParameters) {
RSAPrivateCrtKeyParameters k = (RSAPrivateCrtKeyParameters)key;
BigInteger e = k.getPublicExponent();
// can't do blinding without a public exponent
if (e != null) {
BigInteger m = k.getModulus();
BigInteger r = BigIntegers.createRandomInRange(ONE, m.subtract(ONE), random);
// This is a modification to use the GMP native library method
BigInteger blindedModPow = Gmp.modPowSecure(r, e, m);
BigInteger blindedInput = blindedModPow.multiply(input).mod(m);
BigInteger blindedResult = core.processBlock(blindedInput);
// This is a modification to use the GMP native library method
BigInteger rInv = Gmp.modInverse(r, m);
result = blindedResult.multiply(rInv).mod(m);
// defence against Arjen Lenstra’s CRT attack
// This is a modification to use the GMP native library method
if (!input.equals(Gmp.modPowInsecure(result, e, m))) {
throw new IllegalStateException("RSA engine faulty decryption/signing detected");
}
} else {
result = core.processBlock(input);
}
} else {
result = core.processBlock(input);
}
return core.convertOutput(result);
}