Example usage for org.bouncycastle.crypto.engines AESFastEngine AESFastEngine

List of usage examples for org.bouncycastle.crypto.engines AESFastEngine AESFastEngine

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.engines AESFastEngine AESFastEngine.

Prototype

public AESFastEngine() 

Source Link

Document

default constructor - 128 bit block size.

Usage

From source file:at.archistar.crypto.symmetric.AESEncryptor.java

@Override
public byte[] encrypt(byte[] data, byte[] randomKeyBytes) throws IOException, InvalidKeyException,
        InvalidAlgorithmParameterException, InvalidCipherTextException {

    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(true, new ParametersWithIV(new KeyParameter(randomKeyBytes), randomIvBytes));
    return cipherData(cipher, data);
}

From source file:at.archistar.crypto.symmetric.AESEncryptor.java

@Override
public byte[] decrypt(byte[] data, byte[] randomKeyBytes) throws InvalidKeyException,
        InvalidAlgorithmParameterException, IOException, IllegalStateException, InvalidCipherTextException {

    PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false, new ParametersWithIV(new KeyParameter(randomKeyBytes), randomIvBytes));
    return cipherData(cipher, data);
}

From source file:at.archistar.crypto.symmetric.AESGCMEncryptor.java

@Override
public byte[] encrypt(byte[] data, byte[] randomKeyBytes) throws IOException, InvalidKeyException,
        InvalidAlgorithmParameterException, InvalidCipherTextException, ImpossibleException {

    AEADBlockCipher cipher = new GCMBlockCipher(new AESFastEngine());
    cipher.init(true, new AEADParameters(new KeyParameter(randomKeyBytes), 128, randomIvBytes));
    return cipherData(cipher, data);
}

From source file:at.archistar.crypto.symmetric.AESGCMEncryptor.java

@Override
public byte[] decrypt(byte[] data, byte[] randomKey)
        throws InvalidKeyException, InvalidAlgorithmParameterException, IOException, IllegalStateException,
        InvalidCipherTextException, ImpossibleException {

    AEADBlockCipher cipher = new GCMBlockCipher(new AESFastEngine());
    cipher.init(false, new AEADParameters(new KeyParameter(randomKey), 128, randomIvBytes));
    return cipherData(cipher, data);
}

From source file:cologne.eck.peafactory.gui.Menu.java

License:Open Source License

@Override
public void actionPerformed(ActionEvent ape) {

    //JComponent source = (JComponent) ape.getSource();
    String command = ape.getActionCommand();

    //Menu//from   w  ww . ja va2s  .c om
    if (command.equals("newProject")) {
        ProjectSelection proj = new ProjectSelection();
        Point p = MainView.getFrameLocation();
        proj.setLocation((int) p.getX() + 100, (int) p.getY() + 60);
        proj.setVisible(true);
    } else if (command.equals("randomPassword")) {
        PasswordGeneratorDialog pg = new PasswordGeneratorDialog(PeaFactory.getFrame());
        pg.setVisible(true);
    } else if (command.equals("keyboard")) {
        int input = JOptionPane.showConfirmDialog(PeaFactory.getFrame(),
                languageBundle.getString("add_keyboard"), " ", JOptionPane.YES_NO_OPTION);
        if (input == 0) {
            FileModifier.setSetKeyboard(true);
        } else {
            FileModifier.setSetKeyboard(false);
        }
    } else if (command.equals("psw_generator")) {
        int input = JOptionPane.showConfirmDialog(PeaFactory.getFrame(),
                languageBundle.getString("add_psw_generator"), " ", JOptionPane.YES_NO_OPTION);
        if (input == 0) {
            FileModifier.setPswGenerator(true);
        } else {
            FileModifier.setPswGenerator(false);
        }
    } else if (command.equals("quit")) {
        System.exit(0);

    } else if (command.equals("generalPeaSettings")) {

        @SuppressWarnings("unused")
        GeneralPeaSettings imageSetting = new GeneralPeaSettings();

    } else if (command.equals("setThoughtless")) {
        securityLevel = 1;
        setSecurityLevel(1);
    } else if (command.equals("setLow")) {
        securityLevel = 2;
        setSecurityLevel(2);
    } else if (command.equals("setStandard")) {
        securityLevel = 3;
        setSecurityLevel(3);
    } else if (command.equals("setHigh")) {
        securityLevel = 4;
        setSecurityLevel(4);
    } else if (command.equals("setParanoid")) {
        securityLevel = 5;
        setSecurityLevel(5);

    } else if (command.equals("setBcrypt")) {
        setSecurityLevel(securityLevel);
        KeyDerivation.setKdf(new BcryptKDF());
    } else if (command.equals("setScrypt")) {
        setSecurityLevel(securityLevel);
        KeyDerivation.setKdf(new ScryptKDF());
    } else if (command.equals("setDragonfly")) {
        setSecurityLevel(securityLevel);
        CatenaKDF.setVersionID("Dragonfly-Full");
        KeyDerivation.setKdf(new CatenaKDF());
    } else if (command.equals("setButterfly")) {
        setSecurityLevel(securityLevel);
        CatenaKDF.setVersionID("Butterfly-Full");
        KeyDerivation.setKdf(new CatenaKDF());
    } else if (command.equals("setPomelo")) {
        setSecurityLevel(securityLevel);
        KeyDerivation.setKdf(new PomeloKDF());

    } else if (command.equals("setBcryptParameters")) {

        @SuppressWarnings("unused")
        BcryptSetting bcryptSetting = new BcryptSetting();

    } else if (command.equals("setPomeloParameters")) {

        @SuppressWarnings("unused")
        PomeloSetting pomeloSetting = new PomeloSetting();

    } else if (command.equals("setScryptParameters")) {

        @SuppressWarnings("unused")
        ScryptSetting scryptSetting = new ScryptSetting();

    } else if (command.equals("setCatenaParameters")) {

        @SuppressWarnings("unused")
        CatenaSetting catenaSetting = new CatenaSetting();

    } else if (command.equals("setImageParameters")) {

        @SuppressWarnings("unused")
        ImageSetting imageSetting = new ImageSetting();

    } else if (command.equals("setShacal2")) {
        CipherStuff.setCipherAlgo(new Shacal2Engine());
    } else if (command.equals("setThreefish256")) {
        CipherStuff.setCipherAlgo(new ThreefishEngine(256));
    } else if (command.equals("setThreefish512")) {
        CipherStuff.setCipherAlgo(new ThreefishEngine(512));
    } else if (command.equals("setThreefish1024")) {
        CipherStuff.setCipherAlgo(new ThreefishEngine(1024));
    } else if (command.equals("setTwofish")) {
        CipherStuff.setCipherAlgo(new TwofishEngine());
    } else if (command.equals("setSerpent")) {
        CipherStuff.setCipherAlgo(new SerpentEngine());
    } else if (command.equals("setAES")) {
        CipherStuff.setCipherAlgo(new AESEngine());
    } else if (command.equals("setAESFast")) {
        CipherStuff.setCipherAlgo(new AESFastEngine());

        // hash function:
    } else if (command.equals("setWhirlpool")) {
        HashStuff.setHashAlgo(new WhirlpoolDigest());
    } else if (command.equals("setKeccak")) {
        HashStuff.setHashAlgo(new SHA3Digest());
    } else if (command.equals("setSha512")) {
        HashStuff.setHashAlgo(new SHA512Digest());
    } else if (command.equals("setSha384")) {
        HashStuff.setHashAlgo(new SHA384Digest());
    } else if (command.equals("setSkein512")) {
        HashStuff.setHashAlgo(new SkeinDigest(512, 512));
    } else if (command.equals("setBlake512")) {
        HashStuff.setHashAlgo(new Blake2bDigest());
        //      } else if (command.equals("setRipemd256")) {
        //         HashStuff.setHashAlgo( new RIPEMD256Digest() );          
    } else if (command.equals("setRipemd320")) {
        HashStuff.setHashAlgo(new RIPEMD320Digest());

    } else if (command.equals("setDE")) {
        PeaFactory.setI18n("de");
    } else if (command.equals("setEN")) {
        PeaFactory.setI18n("en");

    } else if (command.equals("notes")) {
        @SuppressWarnings("unused")
        InfoDialog info = new InfoDialog(languageBundle.getString("notes_description"), null, "notes");
    } else if (command.equals("editor")) {
        @SuppressWarnings("unused")
        InfoDialog info = new InfoDialog(languageBundle.getString("editor_description"), null, "editor");
    } else if (command.equals("image")) {
        @SuppressWarnings("unused")
        InfoDialog info = new InfoDialog(languageBundle.getString("image_description"), null, "image");
    } else if (command.equals("keyboard_info")) {
        @SuppressWarnings("unused")
        InfoDialog info = new InfoDialog("Onscreen Keyboard", null, "keyboard");
    } else if (command.equals("file")) {
        @SuppressWarnings("unused")
        InfoDialog info = new InfoDialog(languageBundle.getString("file_description"), null, "file");

    } else if (command.equals("problemHelp")) {
        JOptionPane pane = new JOptionPane(languageBundle.getString("problem_help_dialog"),
                JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_OPTION, null, null);//new ImageIcon(PswDialogView.getImage()), null);
        pane.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
        //pane.setIconImage(PswDialogView.getImage());
        pane.setVisible(true);
        //pane.showMessageDialog(null, languageBundle.getString("problem_help_dialog"), null, JOptionPane.PLAIN_MESSAGE);
    } else if (command.equals("howToUse")) {
        JOptionPane.showMessageDialog(PeaFactory.getFrame(), languageBundle.getString("how_to_use_dialog"),
                null, JOptionPane.PLAIN_MESSAGE);
    } else if (command.equals("aboutLicense")) {
        JOptionPane.showMessageDialog(PeaFactory.getFrame(), languageBundle.getString("about_license_dialog"),
                null, JOptionPane.PLAIN_MESSAGE);
    }
}

From source file:com.foilen.smalltools.crypt.symmetric.AESCrypt.java

License:Open Source License

@Override
protected BufferedBlockCipher generateBufferedBlockCipher() {
    return new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
}

From source file:com.github.horrorho.inflatabledonkey.chunk.engine.ChunkDecrypters.java

License:Open Source License

public static Optional<byte[]> decrypt(byte[] key, byte[] data, int offset, int length) {
    StreamBlockCipher cipher = new CFBBlockCipher(new AESFastEngine(), 128);
    return decrypt(key, cipher, data, offset, length);
}

From source file:com.github.horrorho.inflatabledonkey.chunk.engine.ChunkListDecrypter.java

License:Open Source License

CipherInputStream cipherInputStream(InputStream inputStream, byte[] key, byte[] checksum) {
    CFBBlockCipher cipher = new CFBBlockCipher(new AESFastEngine(), 128);
    KeyParameter keyParameter = new KeyParameter(key);
    cipher.init(false, keyParameter);// w  ww.  ja  v  a 2  s .c  om
    return new CipherInputStream(inputStream, cipher);
}

From source file:com.github.horrorho.inflatabledonkey.crypto.AESCBC.java

License:Open Source License

public static byte[] decryptAESCBC(byte[] key, byte[] iv, byte[] data) {
    // AES CBC PKCS7 decrypt
    try {//from w  w  w  .  j av a  2 s  .  c o m
        CipherParameters cipherParameters = new ParametersWithIV(new KeyParameter(key), iv);
        PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
                new CBCBlockCipher(new AESFastEngine()), new PKCS7Padding());
        cipher.init(false, cipherParameters);

        byte[] buffer = new byte[cipher.getOutputSize(data.length)];

        int pos = cipher.processBytes(data, 0, data.length, buffer, 0);
        pos += cipher.doFinal(buffer, pos);

        return Arrays.copyOf(buffer, pos);

    } catch (DataLengthException | IllegalStateException | InvalidCipherTextException ex) {
        throw new IllegalArgumentException("decrypt failed", ex);
    }
}

From source file:com.github.horrorho.inflatabledonkey.crypto.AESGCM.java

License:Open Source License

/**
 * Returns decrypted data.//from  w  w w .  jav  a  2s.  co  m
 *
 * @param key
 * @param nonce nonce/ IV
 * @param header
 * @param encryptedData
 * @param tag
 * @param optional optional AADBytes (post header)
 * @return decrypted data
 * @throws IllegalArgumentException on decryption exceptions
 * @throws NullPointerException on null arguments
 */
public static byte[] decrypt(byte[] key, byte[] nonce, byte[] header, byte[] encryptedData, byte[] tag,
        Optional<byte[]> optional) {

    try {
        GCMBlockCipher cipher = new GCMBlockCipher(new AESFastEngine());
        AEADParameters parameters = new AEADParameters(new KeyParameter(key), tag.length * 8, nonce, header);
        cipher.init(false, parameters);

        if (optional.isPresent()) {
            byte[] aadBytes = optional.get();
            cipher.processAADBytes(aadBytes, 0, aadBytes.length);
        }

        byte[] out = new byte[cipher.getOutputSize(encryptedData.length + tag.length)];

        int pos = cipher.processBytes(encryptedData, 0, encryptedData.length, out, 0);
        pos += cipher.processBytes(tag, 0, tag.length, out, pos);
        pos += cipher.doFinal(out, pos);

        return Arrays.copyOf(out, pos);

    } catch (IllegalStateException | InvalidCipherTextException ex) {
        throw new IllegalStateException("GCM decrypt error", ex);
    }
}