List of usage examples for org.bouncycastle.crypto.engines SerpentEngine SerpentEngine
SerpentEngine
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 w w. j a v a 2 s. c o m*/ 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:de.burlov.amazon.s3.dirsync.DirSync.java
License:Apache License
public DirSync(String accessKey, String secretKey, String bucket, String location, char[] encPassword) throws DirSyncException { super();/*from ww w.j a v a2 s . c om*/ try { shaDigest = MessageDigest.getInstance("SHA-1"); md5Digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new DirSyncException(e.getMessage()); } this.accessKey = accessKey; this.secretKey = secretKey; if (encPassword == null) { throw new IllegalArgumentException("encryption password is null"); } this.bucket = bucket; this.location = location; if (StringUtils.equalsIgnoreCase(location, S3Bucket.LOCATION_EUROPE)) { this.location = S3Bucket.LOCATION_EUROPE; } else { this.location = null; } if (StringUtils.isBlank(this.bucket)) { this.bucket = accessKey + ".dirsync"; } cipher = new SerpentEngine(); pbeKey = generatePbeKey(encPassword); try { s3Service = new RestS3Service(new AWSCredentials(accessKey, secretKey)); } catch (S3ServiceException e1) { throw new DirSyncException("Connecting to S3 service failed", e1); } }
From source file:de.burlov.bouncycastle.io.test.EncryptOutputStreamTest.java
License:Apache License
@Test public void testEncryptDecrypt() throws IOException { BlockCipher cipher = new SerpentEngine(); Random rnd = new Random(); byte[] key = new byte[256 / 8]; rnd.nextBytes(key);/*from w ww. j a v a2 s .co m*/ byte[] iv = new byte[cipher.getBlockSize()]; rnd.nextBytes(iv); byte[] data = new byte[1230000]; new Random().nextBytes(data); ByteArrayOutputStream bout = new ByteArrayOutputStream(); CryptOutputStream eout = new CryptOutputStream(bout, cipher, key); eout.write(data); eout.close(); byte[] eData = bout.toByteArray(); // eData[1000] = (byte) (eData[1000] & 0x88); ByteArrayInputStream bin = new ByteArrayInputStream(eData); CryptInputStream din = new CryptInputStream(bin, cipher, key); bout = new ByteArrayOutputStream(); IOUtils.copy(din, bout); eData = bout.toByteArray(); Assert.assertTrue(Arrays.areEqual(data, eData)); }
From source file:de.burlov.crypt.CryptUtils.java
License:Apache License
/** * Verschluesselt ein Datenblock mit Serpent Cipher in AEAD/EAX Modus. * /* ww w. j a va2 s . co m*/ * @param cleartext * @param key * @return */ static public byte[] encrypt(byte[] cleartext, byte[] key) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { CryptOutputStream out = new CryptOutputStream(bout, new SerpentEngine(), key); out.write(cleartext); out.close(); return bout.toByteArray(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:de.burlov.crypt.CryptUtils.java
License:Apache License
static public byte[] decrypt(byte[] ciphertext, byte[] key) throws IOException { CryptInputStream in = new CryptInputStream(new ByteArrayInputStream(ciphertext), new SerpentEngine(), key); ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.copy(in, bout);//from w w w . j a v a 2s. co m return bout.toByteArray(); }
From source file:de.gs_sys.kp2016.crypto.SymmetricCipher.java
License:Open Source License
public static void setEngine(ENGINE e) { activeEngine = e;/*from www . ja v a2 s . c om*/ switch (e) { case AES: engine = new AESEngine(); break; // case AES_WRAP: // engine = new AESWrapEngine(); // break; case Rijndael: engine = new RijndaelEngine(); break; case Camellia: engine = new CamelliaEngine(); break; case Blowfish: engine = new BlowfishEngine(); break; case Serpent: engine = new SerpentEngine(); break; case Threefish: //engine = new ThreefishEngine(256); engine = new ThreefishEngine(ThreefishSize); break; case Twofish: default: engine = new TwofishEngine(); } }
From source file:de.gs_sys.kp2016.crypto.SymmetricCipher.java
License:Open Source License
@Deprecated protected static BlockCipher getEngine(ENGINE engine) { switch (engine) { case AES://from w ww .j av a 2s . c o m return new AESEngine(); // case AES_WRAP: // return new AESWrapEngine(); case Rijndael: return new RijndaelEngine(); case Camellia: return new CamelliaEngine(); case Blowfish: return new BlowfishEngine(); case Serpent: return new SerpentEngine(); case Threefish: // return new ThreefishEngine(256); return new ThreefishEngine(ThreefishSize); case Twofish: default: return new TwofishEngine(); } }
From source file:org.cryptacular.spec.BlockCipherSpec.java
License:Open Source License
@Override public BlockCipher newInstance() { BlockCipher cipher;/*from ww w . j av a 2s . c om*/ if ("AES".equalsIgnoreCase(algorithm)) { cipher = new AESFastEngine(); } else if ("Blowfish".equalsIgnoreCase(algorithm)) { cipher = new BlowfishEngine(); } else if ("Camellia".equalsIgnoreCase(algorithm)) { cipher = new CamelliaEngine(); } else if ("CAST5".equalsIgnoreCase(algorithm)) { cipher = new CAST5Engine(); } else if ("CAST6".equalsIgnoreCase(algorithm)) { cipher = new CAST6Engine(); } else if ("DES".equalsIgnoreCase(algorithm)) { cipher = new DESEngine(); } else if ("DESede".equalsIgnoreCase(algorithm) || "DES3".equalsIgnoreCase(algorithm)) { cipher = new DESedeEngine(); } else if ("GOST".equalsIgnoreCase(algorithm) || "GOST28147".equals(algorithm)) { cipher = new GOST28147Engine(); } else if ("Noekeon".equalsIgnoreCase(algorithm)) { cipher = new NoekeonEngine(); } else if ("RC2".equalsIgnoreCase(algorithm)) { cipher = new RC2Engine(); } else if ("RC5".equalsIgnoreCase(algorithm)) { cipher = new RC564Engine(); } else if ("RC6".equalsIgnoreCase(algorithm)) { cipher = new RC6Engine(); } else if ("SEED".equalsIgnoreCase(algorithm)) { cipher = new SEEDEngine(); } else if ("Serpent".equalsIgnoreCase(algorithm)) { cipher = new SerpentEngine(); } else if ("Skipjack".equalsIgnoreCase(algorithm)) { cipher = new SkipjackEngine(); } else if ("TEA".equalsIgnoreCase(algorithm)) { cipher = new TEAEngine(); } else if ("Twofish".equalsIgnoreCase(algorithm)) { cipher = new TwofishEngine(); } else if ("XTEA".equalsIgnoreCase(algorithm)) { cipher = new XTEAEngine(); } else { throw new IllegalStateException("Unsupported cipher algorithm " + algorithm); } return cipher; }