Package org.bouncycastle.crypto

Examples of org.bouncycastle.crypto.BufferedBlockCipher


    }

    private BufferedBlockCipher createCipher(boolean encrypt) throws Exception {
        AESEngine blockCipher = new AESEngine();
        CBCBlockCipher cbcCipher = new CBCBlockCipher(blockCipher);
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbcCipher);
        CipherParameters params = createCipherParams();
        cipher.init(encrypt, params);
        return cipher;
    }
View Full Code Here


    }

    @Override
    public void decrypt(File encrypted, File output) throws IOException, CryptoException {
        try {
            BufferedBlockCipher cipher = createCipher(false);
            decryptFile(encrypted, output, cipher);
        } catch (InvalidCipherTextException ex) {
            throw new CryptoException(ex.getMessage(), ex);
        }
    }
View Full Code Here

    }

    @Override
    public byte[] decrypt(byte[] encrypted) throws IOException, CryptoException {
        try {
            BufferedBlockCipher cipher = createCipher(false);
            return decryptBytes(encrypted, cipher);
        } catch (InvalidCipherTextException ex) {
            throw new CryptoException(ex.getMessage(), ex);
        }
    }
View Full Code Here

    }

    @Override
    public void encrypt(File clearText, File output) throws IOException, CryptoException {
        try {
            BufferedBlockCipher cipher = createCipher(true);
            encryptFile(clearText, output, cipher);
        } catch (InvalidCipherTextException ex) {
            throw new CryptoException(ex.getMessage(), ex);
        }
    }
View Full Code Here

    }

    @Override
    public byte[] encrypt(byte[] clearText) throws IOException, CryptoException {
        try {
            BufferedBlockCipher cipher = createCipher(true);
            return encryptBytes(clearText, cipher);
        } catch (InvalidCipherTextException ex) {
            throw new CryptoException(ex.getMessage(), ex);
        }
    }
View Full Code Here

    protected abstract PBEParametersGenerator createPBEParametersGenerator();

    private BufferedBlockCipher createCipher(boolean encrypt) {
        AESEngine blockCipher = new AESEngine();
        CBCBlockCipher cbcCipher = new CBCBlockCipher(blockCipher);
        BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbcCipher);
        CipherParameters params = createCipherParams();
        cipher.init(encrypt, params);
        return cipher;
    }
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 BufferedBlockCipher(
                        new SICBlockCipher(baseEngine));
        }
        else if (modeName.startsWith("CTR"))
        {
            ivLength = baseEngine.getBlockSize();
            cipher = new BufferedBlockCipher(
                        new SICBlockCipher(baseEngine));
        }
        else if (modeName.startsWith("GOFB"))
        {
            ivLength = baseEngine.getBlockSize();
            cipher = new BufferedBlockCipher(
                        new GOFBBlockCipher(baseEngine));
        }
        else if (modeName.startsWith("CTS"))
        {
            ivLength = baseEngine.getBlockSize();
View Full Code Here

        {
            padded = false;
           
            if (!(cipher instanceof CTSBlockCipher))
            {
                cipher = new BufferedBlockCipher(cipher.getUnderlyingCipher());
            }
        }
        else if (paddingName.equals("PKCS5PADDING") || paddingName.equals("PKCS7PADDING"))
        {
            cipher = new PaddedBufferedBlockCipher(cipher.getUnderlyingCipher());
View Full Code Here

      }
    }
  }

  public BufferedBlockCipher getStreamCipher(boolean out) {
    BufferedBlockCipher cipher = new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 8));
    cipher.init(out, new ParametersWithIV(new KeyParameter(sharedKey.getEncoded()), sharedKey.getEncoded(), 0, 16));
    return cipher;
  }
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.