Package org.bouncycastle2.crypto

Examples of org.bouncycastle2.crypto.PBEParametersGenerator


            this(256);
        }

        public KeyGen(int keySize)
        {
            super("Camellia", keySize, new CipherKeyGenerator());
        }
View Full Code Here


    public static class KeyGen
        extends JCEKeyGenerator
    {
        public KeyGen()
        {
            super("Grainv1", 80, new CipherKeyGenerator());
        }
View Full Code Here

        Key                     key,
        AlgorithmParameterSpec  params,
        SecureRandom            random)
    throws InvalidKeyException, InvalidAlgorithmParameterException
    {
        CipherParameters        param;

        //
        // a note on iv's - if ivLength is zero the IV gets ignored (we don't use it).
        //
        if (key instanceof JCEPBEKey)
View Full Code Here

    {
        static private PBEParametersGenerator makePBEGenerator(
            int                     type,
            int                     hash)
        {
            PBEParametersGenerator  generator;
   
            if (type == PKCS5S1)
            {
                switch (hash)
                {
View Full Code Here

            {
                throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
            }
   
            PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
            PBEParametersGenerator  generator = makePBEGenerator(pbeKey.getType(), pbeKey.getDigest());
            byte[]                  key = pbeKey.getEncoded();
            CipherParameters        param;
   
            if (pbeKey.shouldTryWrongPKCS12())
            {
                key = new byte[2];
            }
           
            generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

            if (pbeKey.getIvSize() != 0)
            {
                param = generator.generateDerivedParameters(pbeKey.getKeySize(), pbeKey.getIvSize());
            }
            else
            {
                param = generator.generateDerivedParameters(pbeKey.getKeySize());
            }

            if (targetAlgorithm.startsWith("DES"))
            {
                if (param instanceof ParametersWithIV)
View Full Code Here

            {
                throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
            }
   
            PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
            PBEParametersGenerator  generator = makePBEGenerator(pbeKey.getType(), pbeKey.getDigest());
            byte[]                  key = pbeKey.getEncoded();
            CipherParameters        param;
   
            if (pbeKey.shouldTryWrongPKCS12())
            {
                key = new byte[2];
            }
           
            generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

            param = generator.generateDerivedMacParameters(pbeKey.getKeySize());
   
            for (int i = 0; i != key.length; i++)
            {
                key[i] = 0;
            }
View Full Code Here

            int                     type,
            int                     hash,
            int                     keySize,
            int                     ivSize)
        {   
            PBEParametersGenerator  generator = makePBEGenerator(type, hash);
            byte[]                  key;
            CipherParameters        param;
   
            if (type == PKCS12)
            {
                key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
            }
            else
            {  
                key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
            }
           
            generator.init(key, keySpec.getSalt(), keySpec.getIterationCount());
   
            if (ivSize != 0)
            {
                param = generator.generateDerivedParameters(keySize, ivSize);
            }
            else
            {
                param = generator.generateDerivedParameters(keySize);
            }
   
            for (int i = 0; i != key.length; i++)
            {
                key[i] = 0;
View Full Code Here

            PBEKeySpec              keySpec,
            int                     type,
            int                     hash,
            int                     keySize)
        {
            PBEParametersGenerator  generator = makePBEGenerator(type, hash);
            byte[]                  key;
            CipherParameters        param;
   
            if (type == PKCS12)
            {
                key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
            }
            else
            {  
                key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
            }
           
            generator.init(key, keySpec.getSalt(), keySpec.getIterationCount());
   
            param = generator.generateDerivedMacParameters(keySize);
   
            for (int i = 0; i != key.length; i++)
            {
                key[i] = 0;
            }
View Full Code Here

        static private PBEParametersGenerator makePBEGenerator(
            int                     type,
            int                     hash)
        {
            PBEParametersGenerator  generator;
   
            if (type == PKCS5S1)
            {
                switch (hash)
                {
View Full Code Here

            {
                throw new IllegalArgumentException("Need a PBEParameter spec with a PBE key.");
            }
   
            PBEParameterSpec        pbeParam = (PBEParameterSpec)spec;
            PBEParametersGenerator  generator = makePBEGenerator(type, hash);
            byte[]                  key = pbeKey.getEncoded();
            CipherParameters        param;
   
            generator.init(key, pbeParam.getSalt(), pbeParam.getIterationCount());

            if (ivSize != 0)
            {
                param = generator.generateDerivedParameters(keySize, ivSize);
            }
            else
            {
                param = generator.generateDerivedParameters(keySize);
            }

            if (targetAlgorithm.startsWith("DES"))
            {
                if (param instanceof ParametersWithIV)
View Full Code Here

TOP

Related Classes of org.bouncycastle2.crypto.PBEParametersGenerator

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.