Examples of translateKey()


Examples of java.security.KeyFactory.translateKey()

            ks = KeyStore.getInstance(KS_TYPE, provider);
            ks.load(null, tokenPwd);
        }

        KeyFactory kf = KeyFactory.getInstance("RSA", provider);
        PrivateKey pkSession = (PrivateKey)kf.translateKey(pk3);
        System.out.println("pkSession = " + pkSession);
        ks.setKeyEntry("pkSession", pkSession, null, chain3);

        KeyStore.PrivateKeyEntry pke =
                (KeyStore.PrivateKeyEntry)ks.getEntry("pkSession", null);
View Full Code Here

Examples of java.security.KeyFactory.translateKey()

        try {
            pkBinding.setKeyAlgorithm(_keyAlgorithm);
            pkBinding.setKeyIdentifier(_keyIdentifier);
           
            KeyFactory factory = KeyFactory.getInstance(_privateKey.getAlgorithm());
            pkBinding.setPrivateKey((PrivateKey)factory.translateKey(_privateKey));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
       
        return pkBinding;
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        {
            skF = SecretKeyFactory.getInstance("DESede", "BC");

            try
            {
                skF.translateKey(null);
               
                fail("failed exception test - no exception thrown");
            }
            catch (InvalidKeyException e)
            {
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

            skf = SecretKeyFactory.getInstance(secretKey.getAlgorithm(), provider);


          // Since the key may be a series of bytes generated by an arbitary means
          // we need to translate it into a key suitable for the algorithm.
          secretKey = skf.translateKey(new SecretKeySpec(secretKey.getEncoded(), secretKey.getAlgorithm()));

          // ECB mode does not require IV
          if (mode == CipherFactory.ENCRYPT )
          {
            if ((algorithm.indexOf("/ECB") > -1))
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        {
            skF = SecretKeyFactory.getInstance("DESede", "BC");

            try
            {
                skF.translateKey(null);
               
                fail("failed exception test - no exception thrown");
            }
            catch (InvalidKeyException e)
            {
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        assertEquals("Incorrect algorithm", secKF.getAlgorithm(),
                defaultAlgorithm);
        assertEquals("Incorrect provider", secKF.getProvider(), defaultProvider);
        assertNull("Incorrect result", secKF.generateSecret(null));
        assertNull("Incorrect result", secKF.getKeySpec(null, null));
        assertNull("Incorrect result", secKF.translateKey(null));
        secKF = new mySecretKeyFactory(null, null, null);
        assertNull("Algorithm must be null", secKF.getAlgorithm());
        assertNull("Provider must be null", secKF.getProvider());
        try {
            secKF.translateKey(null);
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        assertNull("Incorrect result", secKF.translateKey(null));
        secKF = new mySecretKeyFactory(null, null, null);
        assertNull("Algorithm must be null", secKF.getAlgorithm());
        assertNull("Provider must be null", secKF.getProvider());
        try {
            secKF.translateKey(null);
            fail("NullPointerException must be thrown");
        } catch (NullPointerException e) {           
        }
    }
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        {
            skF = SecretKeyFactory.getInstance("DESede", "BC");

            try
            {
                skF.translateKey(null);
               
                fail("failed exception test - no exception thrown");
            }
            catch (InvalidKeyException e)
            {
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

        {
            skF = SecretKeyFactory.getInstance("DESede", "BC");

            try
            {
                skF.translateKey(null);
               
                fail("failed exception test - no exception thrown");
            }
            catch (InvalidKeyException e)
            {
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.translateKey()

            skf = SecretKeyFactory.getInstance(secretKey.getAlgorithm(), provider);


          // Since the key may be a series of bytes generated by an arbitary means
          // we need to translate it into a key suitable for the algorithm.
          secretKey = skf.translateKey(new SecretKeySpec(secretKey.getEncoded(), secretKey.getAlgorithm()));

          // ECB mode does not require IV
          if (mode == CipherFactory.ENCRYPT )
          {
            if ((algorithm.indexOf("/ECB") > -1))
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.