Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
OTP4U (One Time Pad For You) - KeyManager.java

KeyManager.java

Caricato da: Teutoburgo
Scarica il programma completo

  1. /*
  2.     OTP4U 0.8.0 - One Time Pad for you
  3.     Copyright (C) 2003 Pierre Blanc
  4.     Pierre Blanc: blanc_teutoburgo@yahoo.it
  5.     http://www.teutoburgo.tk
  6.     http://it.geocities.com/teutoburgo
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License, or
  11.     (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.     or go to      http://www.gnu.org/copyleft/gpl.html
  22. */
  23.  
  24. package tk.teutoburgo.otp4u.crypt;
  25.  
  26. import tk.teutoburgo.otp4u.io.*;
  27. import tk.teutoburgo.otp4u.constants.*;
  28. import tk.teutoburgo.otp4u.util.*;
  29. import java.util.*;
  30. import java.io.*;
  31.  
  32. /**
  33.  * Title:        OTP4U
  34.  * Description:
  35.  * Copyright:    Copyright (c) 2002
  36.  * Company:      Teutoburgo
  37.  * @author Pierre Blanc
  38.  * @version 1.0
  39.  */
  40.  
  41. public abstract class KeyManager {
  42.  
  43.   String OTP4U_HOME;
  44.   public static final String PUBLIC_KEY_FILE=Constants.PUBLIC_KEY_FILE,
  45.                 RANDOM_KEY_FILE=Constants.RANDOM_KEY_FILE,
  46.                 RANDOM_KEY=Constants.RANDOM_KEY , PUBLIC_KEY=Constants.PUBLIC_KEY,
  47.                 ENTROPY=Constants.ENTROPY , KEY4KEY=Constants.KEY4KEY,
  48.                 KEY4KEY_FILE=Constants.KEY4KEY_FILE;
  49.  
  50.   Boolean isGui;
  51.   Xor xor = new Xor();
  52.   Io io;
  53.   MessagesPrinter mp;
  54.  
  55.   public KeyManager() {
  56.   }
  57.  
  58.   public KeyManager(String home, Boolean isGui) {
  59.     OTP4U_HOME=home;
  60.     this.isGui=isGui;
  61.     io = new Io(home, isGui.booleanValue());
  62.     mp = new MessagesPrinter(isGui.booleanValue());
  63.   }
  64.  
  65.  
  66.   public abstract void writePublicKey() throws IOException,
  67.  
  68.   public abstract void writeRandomKey() throws IOException,
  69.  
  70.     /**
  71.      * method for compacting the files used as entropy source in a single array
  72.      * @param entropyFiles the array of the entropy source files
  73.      */
  74.     public byte[] compactEntropyFiles(byte[][] entropyFiles) {
  75.                 int i = 0, totalLength = 0, k = 0;
  76.                 for (i = 0; i < entropyFiles.length; i++) {
  77.                         totalLength = totalLength + entropyFiles[i].length;
  78.                 }
  79.                 byte[] compacted = new byte[totalLength];
  80.                 for (i = 0; i < entropyFiles.length; i++) {
  81.                         for (int j = 0; j < entropyFiles[i].length; j++) {
  82.                                 compacted[k] = entropyFiles[i][j];
  83.                                 k++;
  84.                         }
  85.                 }
  86.                 return compacted;
  87.     }
  88.  
  89.  
  90. }