Package javax.crypto.spec

Examples of javax.crypto.spec.DESedeKeySpec


            new XMLSecurityConstants.Action[]{XMLSecurityConstants.ENCRYPT};
        properties.setOutAction(actions);
       
        // Set the key up
        byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
        DESedeKeySpec keySpec = new DESedeKeySpec(bits192);
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
        SecretKey key = keyFactory.generateSecret(keySpec);
        properties.setEncryptionKey(key);
        properties.setEncryptionSymAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc");
       
View Full Code Here


            new XMLSecurityConstants.Action[]{XMLSecurityConstants.ENCRYPT};
        properties.setOutAction(actions);
       
        // Set the key up
        byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
        DESedeKeySpec keySpec = new DESedeKeySpec(bits192);
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
        SecretKey key = keyFactory.generateSecret(keySpec);
        properties.setEncryptionKey(key);
        properties.setEncryptionSymAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc");
       
View Full Code Here

    /**
     * Generate a secret key
     */
    private SecretKey generateDESSecretKey() throws Exception {
        byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
        DESedeKeySpec keySpec = new DESedeKeySpec(bits192);
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
        return keyFactory.generateSecret(keySpec);
    }
View Full Code Here


        try {
            //System.out.println("Key length " + key.length);
            SecretKey k = SecretKeyFactory.getInstance("DESEDE").generateSecret(
                    new DESedeKeySpec(key));
            Cipher cipher = Cipher.getInstance("DESEDE");
            cipher.init(Cipher.ENCRYPT_MODE, k);

            return cipher.doFinal(data);
        } catch (NoSuchAlgorithmException ex) {
View Full Code Here

    public static byte[] decrypt(PublicInfo info, byte[] key, byte[] data) throws InvalidVSSScheme {
        try {

            //System.out.println("keylen in decrypt is " + key.length);
            SecretKey k = SecretKeyFactory.getInstance("DESEDE").generateSecret(
                    new DESedeKeySpec(key));

            Cipher cipher = Cipher.getInstance("DESEDE");
            cipher.init(Cipher.DECRYPT_MODE, k);
            return cipher.doFinal(data);
        } catch (NoSuchAlgorithmException ex) {
View Full Code Here

        // keyspec test
        //
        try
        {
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede", "BC");
            DESedeKeySpec keySpec = (DESedeKeySpec)keyFactory.getKeySpec((SecretKey)key, DESedeKeySpec.class);

            if (!equalArray(key.getEncoded(), keySpec.getKey(), 16))
            {
                fail("DESEDE KeySpec does not match key.");
            }
        }
        catch (Exception e)
View Full Code Here

                        byte[]  longKey = new byte[24];

                        System.arraycopy(bytes, 0, longKey, 0, 16);
                        System.arraycopy(bytes, 0, longKey, 16, 8);

                        return new DESedeKeySpec(longKey);
                    }
                    else
                    {
                        return new DESedeKeySpec(bytes);
                    }
                }
                catch (Exception e)
                {
                    throw new InvalidKeySpecException(e.toString());
View Full Code Here

            KeySpec keySpec)
        throws InvalidKeySpecException
        {
            if (keySpec instanceof DESedeKeySpec)
            {
                DESedeKeySpec desKeySpec = (DESedeKeySpec)keySpec;
                return new SecretKeySpec(desKeySpec.getKey(), "DESede");
            }

            return super.engineGenerateSecret(keySpec);
        }
View Full Code Here

        {
            fail("failed exception test.", e);
        }
        try
        {
            ks = (KeySpec)new DESedeKeySpec(bb);
            skF.getKeySpec(null, ks.getClass());
           
            fail("failed exception test - no exception thrown");
        }
        catch (InvalidKeySpecException e)
View Full Code Here

                    j = -1;
                }
            }

            // 为上一密钥创建一个指定的 DESSede key
            DESedeKeySpec spec = new DESedeKeySpec(encryptKey);
            // 得到 DESSede keys
            SecretKeyFactory keyFactory = SecretKeyFactory
                    .getInstance("DESede");
            theKey = keyFactory.generateSecret(spec);
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of javax.crypto.spec.DESedeKeySpec

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.