@@ -0,0 +1,2256 @@
+package cologne.eck.peafactory.crypto.kdf;%0A%0A/*%0A * PeaFactory - Production of Password Encryption Archives%0A * Copyright (C) 2015  Axel von dem Bruch%0A * %0A * This library is free software; you can redistribute it and/or modify it %0A * under the terms of the GNU General Public License as published %0A * by the Free Software Foundation; either version 2 of the License, %0A * or (at your option) any later version.%0A * This library is distributed in the hope that it will be useful, but %0A * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY %0A * or FITNESS FOR A PARTICULAR PURPOSE. %0A * See the GNU General Public License for more details.%0A * See:  http://www.gnu.org/licenses/gpl-2.0.html%0A * You should have received a copy of the GNU General Public License %0A * along with this library.%0A */%0A%0A/**%0A * Class to call Bcrypt as key derivation function%0A */%0A%0Aimport org.bouncycastle.crypto.generators.BcryptCore;%0A%0Aimport cologne.eck.peafactory.crypto.KeyDerivation;%0A%0Apublic class BcryptKDF extends KeyDerivation %7B%0A%09%0A%09private static int rounds = 11;%0A%0A%09public BcryptKDF() %7B%0A%09%09settCost(rounds);%0A%09%09setmCost(0);%0A%09%09setArg3(0);%0A%09%09setArg4(0);%0A%09%09setArg5(0);%0A%09%09setArg6(0);%0A%09%09setVersionString(%22%22);%0A%09%09setKdf(this);%0A%09%7D%0A%0A%09@Override%0A%09public byte%5B%5D deriveKey(byte%5B%5D pswMaterial) %7B%0A%0A%09%09byte%5B%5D salt = getSalt();%0A%09%09if (salt.length != 16) %7B%0A%09%09%09if (salt.length %3E 16) %7B%0A%09%09%09%09System.out.println(%22Warning: Bcrypt uses only 16 byte salt - salt is truncated%22);%0A%09%09%09%09byte%5B%5D tmp = new byte%5B16%5D;%0A%09%09%09%09System.arraycopy(getSalt(), 0, tmp, 0, tmp.length);%0A%09%09%09%09salt = tmp;%0A%09%09%09%7D%0A%09%09%09//throw new IllegalArgumentException(%22Bcrypt - invalid salt size%22);%0A%09%09%7D%0A%0A%09%09byte%5B%5D keyMaterial = null;%0A%09%09try %7B%0A%09%09    keyMaterial = new BcryptCore().deriveRawKey(%0A%09%09    %09%09gettCost(), %0A%09%09    %09%09salt, %0A%09%09    %09%09pswMaterial);%0A%09%09    %7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09//System.out.println(%22Bcrypt:  2 %5E%22 + rounds + %22 iterations%22 );%0A%09%09printInfos(true);%0A%0A%09%09keyMaterial = adjustKeyMaterial(keyMaterial);%0A%0A%09%09return keyMaterial;%0A%09%7D%0A%0A%09@Override%0A%09public String getName() %7B%0A%09%09return %22Bcrypt%22;%0A%09%7D%0A%0A%09/**%0A%09 * @return the rounds%0A%09 */%0A%09public static int getRounds() %7B%0A%09%09return rounds;%0A%09%7D%0A%0A%09/**%0A%09 * @param rounds the rounds to set%0A%09 */%0A%09public static void setRounds(int _rounds) %7B%0A%09%09rounds = _rounds;%0A%09%7D%0A%7D%0A

Create BcryptKDF.java