本文整理匯總了Java中java.security.spec.RSAKeyGenParameterSpec.getKeysize方法的典型用法代碼示例。如果您正苦於以下問題:Java RSAKeyGenParameterSpec.getKeysize方法的具體用法?Java RSAKeyGenParameterSpec.getKeysize怎麽用?Java RSAKeyGenParameterSpec.getKeysize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.spec.RSAKeyGenParameterSpec
的用法示例。
在下文中一共展示了RSAKeyGenParameterSpec.getKeysize方法的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");
}