Package java.security.spec

Examples of java.security.spec.KeySpec


        KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
        KeyPair keys = keyGen.generateKeyPair();
        if (keepalive != null) {
          keepalive.interrupt();
        }
        KeySpec publicKeySpec = fact.getKeySpec(keys.getPublic(),
            getPublicKeySpecClass(keyfactAlgs[i]));
        PublicKey publicKey = fact.generatePublic(publicKeySpec);
        boolean samePublic = Arrays.equals(keys.getPublic()
            .getEncoded(), publicKey.getEncoded());
        assertTrue(
View Full Code Here


        KeepAlive keepalive = createKeepAlive(keyfactAlgs[i]);
        KeyPair keys = keyGen.generateKeyPair();
        if (keepalive != null) {
          keepalive.interrupt();
        }
        KeySpec privateKeySpec = fact.getKeySpec(keys.getPrivate(),
            getPrivateKeySpecClass(keyfactAlgs[i]));
        KeySpec publicKeySpec = fact.getKeySpec(keys.getPublic(),
            getPublicKeySpecClass(keyfactAlgs[i]));
        PrivateKey privateKey = fact.generatePrivate(privateKeySpec);
        PublicKey publicKey = fact.generatePublic(publicKeySpec);
        boolean samePublic = Arrays.equals(keys.getPublic()
            .getEncoded(), publicKey.getEncoded());
        boolean samePrivate = Arrays.equals(keys.getPrivate()
            .getEncoded(), privateKey.getEncoded());
        assertTrue(
            "generatePrivate generated different key for algorithm "
                + keyfactAlgs[i], samePrivate);
        assertTrue(
            "generatePublic generated different key for algorithm "
                + keyfactAlgs[i], samePublic);
        KeySpec encodedSpec = fact.getKeySpec(keys.getPublic(),
            X509EncodedKeySpec.class);
        assertTrue("improper key spec for encoded public key",
            encodedSpec.getClass().equals(X509EncodedKeySpec.class));
        encodedSpec = fact.getKeySpec(keys.getPrivate(),
            PKCS8EncodedKeySpec.class);
        assertTrue("improper key spec for encoded private key",
            encodedSpec.getClass()
                .equals(PKCS8EncodedKeySpec.class));
      } catch (NoSuchAlgorithmException e) {
        fail("getInstance did not find algorithm " + keyfactAlgs[i]);
      } catch (NoSuchProviderException e) {
        fail("getInstance did not find provider " + providerName);
View Full Code Here

     * Test #1 for <code>RSAPrivateCrtKeySpec</code> constructor
     * Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAPrivateCrtKeySpec01() {
        KeySpec ks = new RSAPrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
View Full Code Here

     * Test #2 for <code>RSAPrivateCrtKeySpec</code> constructor
     * Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAPrivateCrtKeySpec02() {
        KeySpec ks = new RSAPrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
View Full Code Here

     * Test #1 for <code>RSAPublicKeySpec</code> constructor
     * Assertion: Constructs <code>RSAPublicKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAPublicKeySpec01() {
        KeySpec ks =
            new RSAPublicKeySpec(BigInteger.valueOf(1234567890L),
                                 BigInteger.valueOf(3L));
       
        assertTrue(ks instanceof RSAPublicKeySpec);
    }
View Full Code Here

     * Test #2 for <code>RSAPublicKeySpec</code> constructor
     * Assertion: Constructs <code>RSAPublicKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAPublicKeySpec02() {
        KeySpec ks =
            new RSAPublicKeySpec(null, null);

        assertTrue(ks instanceof RSAPublicKeySpec);
    }
View Full Code Here

    /**
     * Test for <code>DSAPublicKeySpec</code> ctor
     */
    public final void testDSAPublicKeySpec() {
        KeySpec ks = new DSAPublicKeySpec(
                new BigInteger("1"), // y
                new BigInteger("2"), // p
                new BigInteger("3"), // q
                new BigInteger("4"));// g
       
View Full Code Here

    /**
     * Test for constructor
     */
    public final void testDSAPrivateKeySpec() {
        KeySpec ks = new DSAPrivateKeySpec(
                new BigInteger("1"),
                new BigInteger("2"),
                new BigInteger("3"),
                new BigInteger("4"));
       
View Full Code Here

     * Test for <code>RSAPrivateKeySpec(BigInteger,BigInteger)</code> ctor
     * Assertion: constructs <code>RSAPrivateKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAPrivateKeySpec() {
        KeySpec ks = new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L),
                                           BigInteger.valueOf(3L));
        assertTrue(ks instanceof RSAPrivateKeySpec);
    }
View Full Code Here

     * </code> ctor<br>
     * Assertion: constructs <code>RSAMultiPrimePrivateCrtKeySpec</code>
     * object using valid parameters
     */
    public final void testRSAMultiPrimePrivateCrtKeySpec01() {
        KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
View Full Code Here

TOP

Related Classes of java.security.spec.KeySpec

Copyright © 2018 www.massapicom. 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.