Java 8 RSAKeyGenParameterSpec - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RSAKeyGenParameterSpec class.

This code example shows how to use the following methods:getKeysize, getPublicExponent
                throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
            } 
            RSAKeyGenParameterSpec     rsaParams = (RSAKeyGenParameterSpec)params;
 
            param = new RSAKeyGenerationParameters(
                            rsaParams.getPublicExponent(),
                            random, rsaParams.getKeysize(), defaultTests);
 
            engine.init(param);
        } 
 
        public KeyPair generateKeyPair()
        { 
            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            RSAKeyParameters            pub = (RSAKeyParameters)pair.getPublic();
            RSAPrivateCrtKeyParameters  priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
            return new KeyPair(new JCERSAPublicKey(pub),
                               new JCERSAPrivateCrtKey(priv));
        } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getKeysize, getPublicExponent
            throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
        } 
        RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
 
        param = new RSAKeyGenerationParameters(
            rsaParams.getPublicExponent(),
            random, rsaParams.getKeysize(), defaultTests);
 
        engine.init(param);
    } 
 
    public KeyPair generateKeyPair()
    { 
        AsymmetricCipherKeyPair pair = engine.generateKeyPair();
        RSAKeyParameters pub = (RSAKeyParameters)pair.getPublic();
        RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
        return new KeyPair(new BCRSAPublicKey(pub),
            new BCRSAPrivateCrtKey(priv));
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getKeysize, getPublicExponent
            throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
        } 
        RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
 
        param = new RSAKeyGenerationParameters(
            rsaParams.getPublicExponent(),
            random, rsaParams.getKeysize(), defaultTests);
 
        engine.init(param);
    } 
 
    public KeyPair generateKeyPair()
    { 
        AsymmetricCipherKeyPair pair = engine.generateKeyPair();
        RSAKeyParameters pub = (RSAKeyParameters)pair.getPublic();
        RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
        return new KeyPair(new BCRSAPublicKey(pub),
            new BCRSAPrivateCrtKey(priv));
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPublicExponent
     * Test for <code>getPublicExponent()</code> method<br> 
     * Assertion: returns public exponent value 
     */ 
    public final void testGetPublicExponent() { 
        RSAKeyGenParameterSpec rkgps =
            new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
        assertEquals(0, rkgps.getPublicExponent().intValue());
    } 
     
    /** 
     * Test for <code>F0</code> field<br> 
     * Assertion: the public exponent value F0 = 3 
     */ 
    public final void testF0Value() { 
        assertEquals(3, RSAKeyGenParameterSpec.F0.intValue());
    } 
     
    /** 
     * Test for <code>F4</code> field<br> 
     * Assertion: the public exponent value F0 = 65537 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
public class GenerateRSAKeyPair { 
 
    public static void main(String[] args) throws Exception {
 
        RSAKeyGenParameterSpec rsaSpec =
        new RSAKeyGenParameterSpec (1024, RSAKeyGenParameterSpec.F4);
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign");
        kpg.initialize(rsaSpec);
 
        // test generateKeyPair 
        KeyPair kpair = kpg.generateKeyPair();
        if (kpair == null) {
            throw new Exception("no keypair generated");
        } 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    /** 
     *  Generate a spec 
     */ 
    private static RSAKeyGenParameterSpec genSpec(int size, BigInteger exp) {
        return new RSAKeyGenParameterSpec(size, exp);
    } 
 
    private static final BigInteger F4 = new NativeBigInteger(RSAKeyGenParameterSpec.F4);
 
    // standard specs 
    public static final RSAKeyGenParameterSpec F4_1024_SPEC = genSpec(1024, F4);
    public static final RSAKeyGenParameterSpec F4_2048_SPEC = genSpec(2048, F4);
    public static final RSAKeyGenParameterSpec F4_3072_SPEC = genSpec(3072, F4);
    public static final RSAKeyGenParameterSpec F4_4096_SPEC = genSpec(4096, F4);
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPublicExponent
     * Test for <code>getPublicExponent()</code> method<br> 
     * Assertion: returns public exponent value 
     */ 
    public final void testGetPublicExponent() { 
        RSAKeyGenParameterSpec rkgps =
            new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
        assertEquals(0, rkgps.getPublicExponent().intValue());
    } 
 
    /** 
     * Test for <code>F0</code> field<br> 
     * Assertion: the public exponent value F0 = 3 
     */ 
    public final void testF0Value() { 
        assertEquals(3, RSAKeyGenParameterSpec.F0.intValue());
    } 
 
    /** 
     * Test for <code>F4</code> field<br> 
     * Assertion: the public exponent value F0 = 65537 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getKeysize, getPublicExponent
This code example shows how to use the following methods:getKeysize, getPublicExponent
                throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
            } 
            RSAKeyGenParameterSpec     rsaParams = (RSAKeyGenParameterSpec)params;
 
            param = new RSAKeyGenerationParameters(
                            rsaParams.getPublicExponent(),
                            random, rsaParams.getKeysize(), defaultTests);
 
            engine.init(param);
        } 
 
        public KeyPair generateKeyPair()
        { 
            AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
            RSAKeyParameters            pub = (RSAKeyParameters)pair.getPublic();
            RSAPrivateCrtKeyParameters  priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
            return new KeyPair(new JCERSAPublicKey(pub),
                               new JCERSAPrivateCrtKey(priv));
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getKeysize, getPublicExponent
            throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
        } 
        RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
 
        param = new RSAKeyGenerationParameters(
            rsaParams.getPublicExponent(),
            random, rsaParams.getKeysize(), defaultTests);
 
        engine.init(param);
    } 
 
    public KeyPair generateKeyPair()
    { 
        AsymmetricCipherKeyPair pair = engine.generateKeyPair();
        RSAKeyParameters pub = (RSAKeyParameters)pair.getPublic();
        RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
        return new KeyPair(new BCRSAPublicKey(pub),
            new BCRSAPrivateCrtKey(priv));
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 RSAKeyGenParameterSpec Methods: