暗号化されたファイルをソケット経由で送信する際に問題が発生しています (クライアント/サーバー通信)。これはストリームに関連する問題だと思います(より具体的には、オブジェクトの入出力ストリームからデータ入出力ストリームを作成し、それらから入出力ストリームを暗号化するため、ストリームの配置はかなり複雑に見えます) ...
クライアント側:
private static void sendEncrypted(FileInputStream fis,DataOutputStream dos)throws Exception{
try {
byte[] data = new byte[1024];
CipherOutputStream cos = new CipherOutputStream(output, c);
makeFileHeader(dos, c, key, sig);
int i = fis.read(data);
while(i != -1){
cos.write(data, 0, i);
sig.update(data);
cos.flush();
i = fis.read(data);
}
cos.close();
fis.close();
byte[] signatureObj = sig.sign();
output.writeObject(signatureObj);
} catch (Exception e) {
System.out.println(e.toString());
}
}
dos - 元のオブジェクトから作成された出力ストリーム (ソケットから作成された出力) makefileheader - オブジェクトを作成し、出力を使用して上書きするメソッド
サーバ側:
private static void receiveFiles(DataInputStream dis,FileOutputStream fos, int size) throws IOException{
byte [] b = new byte[1024];
int read = 0;
int offset;
while(read < size){
offset = input.read();
dis.read(b,0,offset);
fos.write(b,0,offset);
read +=offset;
}
}