package fugue;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;
public class VectorPrint {
//N messages
//rndLen=true: random length between 32 and 32*nmax bits
//rndLen=false: fixed length 32*nmax bits
static void stimuliExpResp(int N,boolean rndLen,int nmax,String stmFile,String expFile){
BufferedWriter stm=null;
BufferedWriter exp=null;
try {
//Construct the BufferedWriter object
stm=new BufferedWriter(new FileWriter(stmFile));
exp=new BufferedWriter(new FileWriter(expFile));
//reset
stm.write(String.format("%01X %01X %04X%04X",0,0,0,0));
stm.newLine();
stm.write(String.format("%01X %01X %04X%04X",0,0,0,0));
stm.newLine();
//wait for initial value
stm.write(String.format("%01X %01X %2$0128X",1,0));
stm.newLine();
// //feed data
// stm.write(String.format("%X %X %032X",a));
// stm.newLine();
// short[] b={1,0,0,0,0};
// stm.write(String.format("%X %X %032X",b));
// stm.newLine();
// stm.write(String.format("%X %X %032X",b));
// stm.newLine();
Random myRnd=new Random();
System.out.println("Writing stimuli & exp. responses files...");
//messages
for(int i=0;i>(8*i));
short[] expHash=FugueHash.F256(msg,FugueHash.fixedIV());
//MULTI, ROR3_CMIX
for(int j=0;j<64+8;j+=4){
stm.write(String.format("%01X %01X %02X%02X%02X%02X",1,1,msg[j],msg[j+1],msg[j+2],msg[j+3])); //input data
stm.newLine();
stm.write(String.format("%01X %01X %02X%02X%02X%02X",1,1,0,0,0,0)); //wait for SMIX cycle
stm.newLine();
}
for(int j=0;j<37;j++){
stm.write(String.format("%01X %01X %04X%04X",1,0,0,0));
stm.newLine();
}
String hexOut=new String();
for(int j=0;j<32;j++)
hexOut=hexOut.concat(expHash[j]<16?"0":"").concat(Integer.toHexString(expHash[j]));
exp.write(hexOut);
exp.newLine();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
//Close the BufferedWriter
try {
if (stm != null) {
stm.flush();
stm.close();
}
if (exp != null) {
exp.flush();
exp.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}