Examples of RSAKeyGenParameterSpec


Examples of java.security.spec.RSAKeyGenParameterSpec

    /**
     * Test for <code>getKeySize()</code> method<br>
     * Assertion: returns key size value
     */
    public final void testGetKeysize() {
        RSAKeyGenParameterSpec rkgps =
            new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
        assertEquals(512, rkgps.getKeysize());
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    /**
     * 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());
    }
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

     * Assertion: constructs <code>RSAKeyGenParameterSpec</code>
     * object using valid parameters
     */
    public final void testRSAKeyGenParameterSpec() {
        AlgorithmParameterSpec aps =
            new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
        assertTrue(aps instanceof RSAKeyGenParameterSpec);
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    /**
     * Test for <code>getKeySize()</code> method<br>
     * Assertion: returns key size value
     */
    public final void testGetKeysize() {
        RSAKeyGenParameterSpec rkgps =
            new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L));
        assertEquals(512, rkgps.getKeysize());
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

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

Examples of java.security.spec.RSAKeyGenParameterSpec

     * c: rsa_generate
     */
    private static void rsaGenerate(PKeyRSA rsa, int keysize, BigInteger exp) throws RaiseException {
        try {
            KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
            gen.initialize(new RSAKeyGenParameterSpec(keysize, exp), new SecureRandom());
            KeyPair pair = gen.generateKeyPair();
            rsa.privKey = (RSAPrivateCrtKey) (pair.getPrivate());
            rsa.pubKey = (RSAPublicKey) (pair.getPublic());
        } catch (Exception e) {
            throw newRSAError(rsa.getRuntime(), e.getMessage());
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

    }

    private KeyPair generateKeyPair(int size) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
        SecureRandom random = new SecureRandom();
        keyPairGenerator.initialize(new RSAKeyGenParameterSpec(size,
                RSAKeyGenParameterSpec.F4), random);
        KeyPair keyPair = keyPairGenerator.generateKeyPair();
        return keyPair;
    }
View Full Code Here

Examples of java.security.spec.RSAKeyGenParameterSpec

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

Examples of java.security.spec.RSAKeyGenParameterSpec

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();
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.