/*
OTP4U 0.8.0 - One Time Pad for you
Copyright (C) 2003 Pierre Blanc
Pierre Blanc: blanc_teutoburgo@yahoo.it
http://www.teutoburgo.tk
http://it.geocities.com/teutoburgo
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or go to http://www.gnu.org/copyleft/gpl.html
*/
package tk.teutoburgo.otp4u.crypt;
import java.util.*;
import java.io.*;
/**
* Title: OTP4U
* Description:
* Copyright: Copyright (c) 2002
* Company: Teutoburgo
* @author Pierre Blanc
* @version 1.0
*/
public class KM_Permutation extends KeyManager{
KeyPermutator kp = new KeyPermutator();
public KM_Permutation() {
}
super(home, isGui);
}
byte[][] entropyFiles = io.readRandomKey(OTP4U_HOME + ENTROPY);
byte[] publicKeyBytes = this.compactEntropyFiles(entropyFiles);
byte[] oldKey4Key = io.readFile(OTP4U_HOME + RANDOM_KEY +KEY4KEY +
KEY4KEY_FILE);
io.writeFile(OTP4U_HOME+ PUBLIC_KEY + PUBLIC_KEY_FILE ,
publicKeyBytes);
writeKeys(publicKeyBytes, oldKey4Key);
}
byte[] publicKeyBytes = io.readFile(OTP4U_HOME+
PUBLIC_KEY + PUBLIC_KEY_FILE), oldKey4Key = io.readFile(
OTP4U_HOME + RANDOM_KEY +KEY4KEY + KEY4KEY_FILE);
writeKeys(publicKeyBytes, oldKey4Key);
}
public void writeKeys
(byte[] publicKeyBytes,
byte[] k4k
)throws IOException,
mp.sPrintLog("Getting keys .....");
byte[][] iterated = kp.recurrence(publicKeyBytes, k4k);
io.writeFile(OTP4U_HOME + RANDOM_KEY + RANDOM_KEY_FILE,
iterated[0]);
io.writeFile(OTP4U_HOME +RANDOM_KEY+ KEY4KEY +
KEY4KEY_FILE , iterated[1]);
}
}