// Arup Guha
// 11/7/06
// Skeleton for CIS 3362 DES Project

// There are many weaknesses in this framework due to my laziness!
// All of the constants in the algorithm should be stored in final
// static variables, but I just wanted to read in the information
// from the files instead of hard-coding them.

// Also, the key should stay the same for encrypting one file, but
// the blocks must change. This hasn't been indicated clearly.

public class DES {
	
	private int[] key;
	private int[][] roundkeys;
	private int[] block;
	
	private static int[][][] stables;
	private static int[] IP;
	private static int[] IPInv;
	private static int[] E;
	private static int[] PC2;
	private static int[] P;
	private static int[] PC1;
	private static int[] keyshifts;		 
	
	public DES(int[] thekey) {
		
		key = new int[64];
		stables = new int[8][4][16];
		IP = new int[64];
		IPInv = new int[64];
		E = new int[48];
		PC2 = new int[48];
		P = new int[32];
		PC1 = new int[56];
		keyshifts = new int[16];
		block = new int[64];
		
		for (int i=0; i<64; i++)
			key[i] = thekey[i];
		
		Scanner fin = new Scanner(new File("destables.in"));
		
		for (int i=0; i<64; i++)
			IP[i] = fin.nextInt();
			
		for (int i=0; i<64; i++)
			IPInv[i] = fin.nextInt();
			
		for (int i=0; i<48; i++)
			E[i] = fin.nextInt();	
		
		for (int i=0; i<32; i++)
			P[i] = fin.nextInt();
			
		for (int i=0; i<8; i++)
			for (int j=0; j<64; j++)
				stables[i][j/16][j%16] = fin.nextInt();
		
		for (int i=0; i<56; i++)
			PC1[i] = fin.nextInt();
			
		for (int i=0; i<48; i++)
			PC2[i] = fin.nextInt();
			
		for (int i=0; i<16; i++)
			keyhshifts[i] = fin.nextInt();
			
		fin.close();
	}
	
	public void setBlock(int[] bits) {
		for (int i=0; i<64; i++)
			block[i] = bits[i];
	}
	
	// Encrypts the current block.
	public void encrypt() {
		
	}
	
	// Permutes the bits in original according to perm and
	// returns this permutation of the original bits.
	public static int[] Permute(int[] original, int[] perm) {
		
	}
	
	// Runs round num of DES.
	public void round(int num) {
		
	}
	
	// Inverts the initial permutation.
	public void IPInv() {
		
	}
	
	// Expand the 32 bits and return the corresponding 48 bits.
	public int[] E(int[] bits) {
		
	}
	
	// Returns the XOR of the bit streams a and b.
	public int[] XOR(int[] a, int[] b) {
		
	}
	
	// Returns the output of putting the 48 bit input through the
	// 8 S-boxes.
	public int[] Sboxes(int[] input) {
		
	}
	
	// Set up the keys for each round.
	public void setKeys() {
		
	}
	
}