当前位置: 首页>>代码示例>>Java>>正文


Java RSAKeyGenParameterSpec.getKeysize方法代码示例

本文整理汇总了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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:KeyPairGeneratorSpi.java

示例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();
}
 
开发者ID:google,项目名称:conscrypt,代码行数:17,代码来源:OpenSSLRSAKeyPairGenerator.java

示例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);
}
 
开发者ID:bullda,项目名称:DroidText,代码行数:18,代码来源:JDKKeyPairGenerator.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:RSAKeyPairGenerator.java

示例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");
}
 
开发者ID:vilie,项目名称:javify,代码行数:37,代码来源:RSAKeyPairGenerator.java

示例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");
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:37,代码来源:RSAKeyPairGenerator.java


注:本文中的java.security.spec.RSAKeyGenParameterSpec.getKeysize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。