本文整理汇总了Java中java.security.spec.RSAKeyGenParameterSpec.getPublicExponent方法的典型用法代码示例。如果您正苦于以下问题:Java RSAKeyGenParameterSpec.getPublicExponent方法的具体用法?Java RSAKeyGenParameterSpec.getPublicExponent怎么用?Java RSAKeyGenParameterSpec.getPublicExponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.spec.RSAKeyGenParameterSpec
的用法示例。
在下文中一共展示了RSAKeyGenParameterSpec.getPublicExponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
public void initialize(
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidAlgorithmParameterException
{
if (!(params instanceof RSAKeyGenParameterSpec))
{
throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
}
RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
param = new RSAKeyGenerationParameters(
rsaParams.getPublicExponent(),
random, rsaParams.getKeysize(), defaultTests);
engine.init(param);
}
示例2: initialize
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
if (!(params instanceof RSAKeyGenParameterSpec)) {
throw new InvalidAlgorithmParameterException("Only RSAKeyGenParameterSpec supported");
}
RSAKeyGenParameterSpec spec = (RSAKeyGenParameterSpec) params;
final BigInteger publicExponent = spec.getPublicExponent();
if (publicExponent != null) {
this.publicExponent = publicExponent.toByteArray();
}
this.modulusBits = spec.getKeysize();
}
示例3: initialize
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
public void initialize(
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidAlgorithmParameterException
{
if (!(params instanceof RSAKeyGenParameterSpec))
{
throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
}
RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
param = new RSAKeyGenerationParameters(
rsaParams.getPublicExponent(),
random, rsaParams.getKeysize(), defaultTests);
engine.init(param);
}
示例4: initialize
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
if (params instanceof RSAKeyGenParameterSpec == false) {
throw new InvalidAlgorithmParameterException
("Params must be instance of RSAKeyGenParameterSpec");
}
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec)params;
int tmpKeySize = rsaSpec.getKeysize();
BigInteger tmpPublicExponent = rsaSpec.getPublicExponent();
if (tmpPublicExponent == null) {
tmpPublicExponent = RSAKeyGenParameterSpec.F4;
} else {
if (tmpPublicExponent.compareTo(RSAKeyGenParameterSpec.F0) < 0) {
throw new InvalidAlgorithmParameterException
("Public exponent must be 3 or larger");
}
if (tmpPublicExponent.bitLength() > tmpKeySize) {
throw new InvalidAlgorithmParameterException
("Public exponent must be smaller than key size");
}
}
// do not allow unreasonably large key sizes, probably user error
try {
RSAKeyFactory.checkKeyLengths(tmpKeySize, tmpPublicExponent,
512, 64 * 1024);
} catch (InvalidKeyException e) {
throw new InvalidAlgorithmParameterException(
"Invalid key sizes", e);
}
this.keySize = tmpKeySize;
this.publicExponent = tmpPublicExponent;
this.random = random;
}
示例5: setup
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
/**
* Configures this instance.
*
* @param attributes the map of name/value pairs to use.
* @exception IllegalArgumentException if the designated MODULUS_LENGTH value
* is less than 1024.
*/
public void setup(Map attributes)
{
if (Configuration.DEBUG)
log.entering(this.getClass().getName(), "setup", attributes);
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
// are we given a set of RSA params or we shall use our own?
RSAKeyGenParameterSpec params = (RSAKeyGenParameterSpec) attributes.get(RSA_PARAMETERS);
// find out the modulus length
if (params != null)
{
L = params.getKeysize();
e = params.getPublicExponent();
}
else
{
Integer l = (Integer) attributes.get(MODULUS_LENGTH);
L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue());
}
if (L < 1024)
throw new IllegalArgumentException(MODULUS_LENGTH);
// what is the preferred encoding format
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
: formatID.intValue();
if (Configuration.DEBUG)
log.exiting(this.getClass().getName(), "setup");
}
示例6: setup
import java.security.spec.RSAKeyGenParameterSpec; //导入方法依赖的package包/类
/**
* Configures this instance.
*
* @param attributes the map of name/value pairs to use.
* @exception IllegalArgumentException if the designated MODULUS_LENGTH value
* is less than 1024.
*/
public void setup(Map attributes)
{
if (Configuration.DEBUG)
log.entering(this.getClass().getName(), "setup", attributes);
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
// are we given a set of RSA params or we shall use our own?
RSAKeyGenParameterSpec params = (RSAKeyGenParameterSpec) attributes.get(RSA_PARAMETERS);
// find out the modulus length
if (params != null)
{
L = params.getKeysize();
e = params.getPublicExponent();
}
else
{
Integer l = (Integer) attributes.get(MODULUS_LENGTH);
L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue());
}
if (L < 1024)
throw new IllegalArgumentException(MODULUS_LENGTH);
// what is the preferred encoding format
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
: formatID.intValue();
if (Configuration.DEBUG)
log.exiting(this.getClass().getName(), "setup");
}