Package org.bouncycastle.crypto

Examples of org.bouncycastle.crypto.BufferedBlockCipher


    {
        String  paddingName = Strings.toUpperCase(padding);

        if (paddingName.equals("NOPADDING"))
        {
            cipher = new BufferedBlockCipher(cipher.getUnderlyingCipher());
        }
        else if (paddingName.equals("PKCS5PADDING") || paddingName.equals("PKCS7PADDING") || paddingName.equals("ISO10126PADDING"))
        {
            cipher = new PaddedBufferedBlockCipher(cipher.getUnderlyingCipher());
        }
View Full Code Here


        }
   
        public TestResult perform()
        {
            byte[]                  out = new byte[input.length];
            BufferedBlockCipher     engine = new CTSBlockCipher(cipher);
   
            engine.init(true, params);
   
            int len = engine.processBytes(input, 0, input.length, out, 0);
   
            try
            {
                engine.doFinal(out, len);
            }
            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": encryption exception - " + e.toString());
            }
   
            for (int i = 0; i != output.length; i++)
            {
                if (out[i] != output[i])
                {
                    return new SimpleTestResult(false, getName() + ": failed encryption expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
                }
            }
   
            engine.init(false, params);
   
            len = engine.processBytes(output, 0, output.length, out, 0);
   
            try
            {
                engine.doFinal(out, len);
            }
            catch (Exception e)
            {
                return new SimpleTestResult(false, getName() + ": decryption exception - " + e.toString());
            }
View Full Code Here

        return "PKCS5S2";
    }

    public TestResult perform()
    {
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new DESEngine()));
        Test                test = new PBETest(0, cipher, sample1, 64);
        TestResult          result = test.perform();

        if (!result.isSuccessful())
        {
View Full Code Here

        return engine.getAlgorithmName() + " Monte Carlo Test " + id;
    }

    public TestResult perform()
    {
        BufferedBlockCipher cipher = new BufferedBlockCipher(engine);

        cipher.init(true, param);

        byte[]  out = new byte[input.length];

        System.arraycopy(input, 0, out, 0, out.length);

        for (int i = 0; i != iterations; i++)
        {
            int len1 = cipher.processBytes(out, 0, out.length, out, 0);

            try
            {
                cipher.doFinal(out, len1);
            }
            catch (CryptoException e)
            {
                return new SimpleTestResult(false,
                       getName() + ": failed - exception " + e.toString());
            }
        }

        if (!isEqualArray(out, output))
        {
            return new SimpleTestResult(false,
                    getName() + ": failed - " + "expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
        }

        cipher.init(false, param);

        for (int i = 0; i != iterations; i++)
        {
            int len1 = cipher.processBytes(out, 0, out.length, out, 0);

            try
            {
                cipher.doFinal(out, len1);
            }
            catch (CryptoException e)
            {
                return new SimpleTestResult(false,
                       getName() + ": failed reversal - exception " + e.toString());
View Full Code Here

        return engine.getAlgorithmName() + " Vector Test " + id;
    }

    public TestResult perform()
    {
        BufferedBlockCipher cipher = new BufferedBlockCipher(engine);

        cipher.init(true, param);

        byte[]  out = new byte[input.length];

        int len1 = cipher.processBytes(input, 0, input.length, out, 0);

        try
        {
            cipher.doFinal(out, len1);
        }
        catch (CryptoException e)
        {
            return new SimpleTestResult(false,
                   getName() + ": failed - exception " + e.toString());
        }

        if (!isEqualArray(out, output))
        {
            return new SimpleTestResult(false,
                    getName() + ": failed - " + "expected " + new String(Hex.encode(output)) + " got " + new String(Hex.encode(out)));
        }

        cipher.init(false, param);

        int len2 = cipher.processBytes(output, 0, output.length, out, 0);

        try
        {
            cipher.doFinal(out, len2);
        }
        catch (CryptoException e)
        {
            return new SimpleTestResult(false,
                   getName() + ": failed reversal - exception " + e.toString());
View Full Code Here

        }

        //
        // twofish with IV0 test
        //
        BufferedBlockCipher c1 = new PaddedBufferedBlockCipher(
                                    new CBCBlockCipher(new TwofishEngine()));
        BufferedBlockCipher c2 = new PaddedBufferedBlockCipher(
                                    new CBCBlockCipher(new TwofishEngine()));
        i1 = new IESEngine(
                       new ECDHBasicAgreement(),
                       new KDF2BytesGenerator(new SHA1Digest()),
                       new HMac(new SHA1Digest()),
View Full Code Here

            ivLength = baseEngine.getBlockSize();
            if (ivLength < 16)
            {
                throw new IllegalArgumentException("Warning: SIC-Mode can become a twotime-pad if the blocksize of the cipher is too small. Use a cipher with a block size of at least 128 bits (e.g. AES)");
            }
            cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(
                        new SICBlockCipher(baseEngine)));
        }
        else if (modeName.startsWith("CTR"))
        {
            ivLength = baseEngine.getBlockSize();
            cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(
                        new SICBlockCipher(baseEngine)));
        }
        else if (modeName.startsWith("GOFB"))
        {
            ivLength = baseEngine.getBlockSize();
            cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(
                        new GOFBBlockCipher(baseEngine)));
        }
        else if (modeName.startsWith("CTS"))
        {
            ivLength = baseEngine.getBlockSize();
View Full Code Here

        if (paddingName.equals("NOPADDING"))
        {
            if (cipher.wrapOnNoPadding())
            {
                cipher = new BufferedGenericBlockCipher(new BufferedBlockCipher(cipher.getUnderlyingCipher()));
            }
        }
        else if (paddingName.equals("WITHCTS"))
        {
            cipher = new BufferedGenericBlockCipher(new CTSBlockCipher(cipher.getUnderlyingCipher()));
View Full Code Here

    static public class CFB
        extends JCEBlockCipher
    {
        public CFB()
        {
            super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
        }
View Full Code Here

    static public class OFB
        extends JCEBlockCipher
    {
        public OFB()
        {
            super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
        }
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.BufferedBlockCipher

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.