/*
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 tk.teutoburgo.otp4u.io.*;
import tk.teutoburgo.otp4u.constants.*;
import tk.teutoburgo.otp4u.util.*;
import java.util.*;
import java.io.*;
/**
* Title: OTP4U
* Description:
* Copyright: Copyright (c) 2002
* Company: Teutoburgo
* @author Pierre Blanc
* @version 1.0
*/
public abstract class KeyManager {
public static final String PUBLIC_KEY_FILE
=Constants.
PUBLIC_KEY_FILE,
RANDOM_KEY_FILE=Constants.RANDOM_KEY_FILE,
RANDOM_KEY=Constants.RANDOM_KEY , PUBLIC_KEY=Constants.PUBLIC_KEY,
ENTROPY=Constants.ENTROPY , KEY4KEY=Constants.KEY4KEY,
KEY4KEY_FILE=Constants.KEY4KEY_FILE;
Xor xor = new Xor();
Io io;
MessagesPrinter mp;
public KeyManager() {
}
OTP4U_HOME=home;
this.isGui=isGui;
io = new Io(home, isGui.booleanValue());
mp = new MessagesPrinter(isGui.booleanValue());
}
public abstract void writePublicKey
() throws IOException,
public abstract void writeRandomKey
() throws IOException,
/**
* method for compacting the files used as entropy source in a single array
* @param entropyFiles the array of the entropy source files
*/
public byte[] compactEntropyFiles(byte[][] entropyFiles) {
int i = 0, totalLength = 0, k = 0;
for (i = 0; i < entropyFiles.length; i++) {
totalLength = totalLength + entropyFiles[i].length;
}
byte[] compacted = new byte[totalLength];
for (i = 0; i < entropyFiles.length; i++) {
for (int j = 0; j < entropyFiles[i].length; j++) {
compacted[k] = entropyFiles[i][j];
k++;
}
}
return compacted;
}
}