Examples of RSAKeyGenParameterSpec


Examples of java.security.spec.RSAKeyGenParameterSpec

      assertThat(AsymmetricAlgorithm.RSA.toInteger()).isEqualTo(PublicKeyAlgorithmTags.RSA_GENERAL);
    }

    @Test
    public void itHasADefaultSizeOf2048Bits() throws Exception {
      final RSAKeyGenParameterSpec spec = (RSAKeyGenParameterSpec) AsymmetricAlgorithm.RSA.getAlgorithmParameterSpec();
      assertThat(spec.getKeysize()).isEqualTo(2048);
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    int strength = keyLength.value();
    BigInteger publicExp = new BigInteger("10001", 16); // Fermat F4, largest known fermat prime

    try {
      JDKKeyPairGenerator gen = new JDKKeyPairGenerator.RSA();
      RSAKeyGenParameterSpec params = new RSAKeyGenParameterSpec(strength, publicExp);
      gen.initialize(params, new SecureRandom());
      return gen.generateKeyPair();
    } catch (InvalidAlgorithmParameterException e) {
      logger.error("Exception whil RSA key pair generation:", e);
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    }

    static KeyPair generateKeyPair() throws Exception {
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
        SecureRandom random = new SecureRandom();
        keyPairGenerator.initialize(new RSAKeyGenParameterSpec(1024,
                RSAKeyGenParameterSpec.F4), random);
        KeyPair keyPair = keyPairGenerator.generateKeyPair();
        return keyPair;
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

        {
            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);
        }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

  }

  private void loadRSAKeys() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
  {
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
    RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(512, RSAKeyGenParameterSpec.F4);
    keyGen.initialize(spec);

    _keyPairs = new KeyPair[KEYS_SIZE];
    for(int i = 0; i < KEYS_SIZE; i++)
    {
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    _keyPairs = new ScrambledKeyPair[10];
    KeyPairGenerator keygen = null;

    keygen = KeyPairGenerator.getInstance("RSA");
    RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(1024, RSAKeyGenParameterSpec.F4);
    keygen.initialize(spec);

    //generate the initial set of keys
    for(int i = 0; i < 10; i++)
    {
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

        {
            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);
        }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    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());
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

        {
            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);
        }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

            {
                OutputHandler.felog.info("Generating RSA key pair...");

                keyFolder.mkdirs();
                KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
                RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4);
                keygen.initialize(spec);
                keyPair = keygen.generateKeyPair();
                privateKey = keyPair.getPrivate();
                publicKey = keyPair.getPublic();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.