Commit 5470a5fd authored by rwm's avatar rwm

old crypto classes renamed

parent dc865458
......@@ -14,16 +14,16 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
public class DecryptingInputStream implements ReadableByteChannel {
public class DecryptingByteChannel implements ReadableByteChannel {
private Cipher cipher;
private ReadableByteChannel in;
private ByteBuffer buffer;
private boolean endOfStream;
public DecryptingInputStream(ReadableByteChannel in, Key asymmetricKey) throws GeneralSecurityException, IOException{
public DecryptingByteChannel(ReadableByteChannel in, Key asymmetricKey) throws GeneralSecurityException, IOException{
this(in, "AES",128,"RSA", asymmetricKey);
}
public DecryptingInputStream(ReadableByteChannel in, String symmetricAlgorithm, int symmetricKeysize, String asymmetricCipher, Key asymmetricKey) throws GeneralSecurityException, IOException{
public DecryptingByteChannel(ReadableByteChannel in, String symmetricAlgorithm, int symmetricKeysize, String asymmetricCipher, Key asymmetricKey) throws GeneralSecurityException, IOException{
// use buffer
endOfStream = false;
buffer = ByteBuffer.allocate(1024*8);
......@@ -33,7 +33,7 @@ public class DecryptingInputStream implements ReadableByteChannel {
int version = buffer.getInt();
int ks = buffer.getShort();
if( version != EncryptingOutputStream.Version )throw new IOException("Unsupported MDAT stream version "+version);
if( version != EncryptingByteChannel.Version )throw new IOException("Unsupported MDAT stream version "+version);
byte[] wrapped = new byte[ks];
buffer.get(wrapped);
buffer.compact();
......@@ -59,6 +59,7 @@ public class DecryptingInputStream implements ReadableByteChannel {
@Override
public void close() throws IOException {
in.close();
}
@Override
......
......@@ -20,16 +20,16 @@ import javax.crypto.ShortBufferException;
* @author Raphael
*
*/
public class EncryptingOutputStream implements WritableByteChannel{
public class EncryptingByteChannel implements WritableByteChannel{
public static final int Version = 1;
private Cipher cipher;
private WritableByteChannel out;
private ByteBuffer buffer;
public EncryptingOutputStream(WritableByteChannel out, Key asymmetricKey) throws GeneralSecurityException, IOException{
public EncryptingByteChannel(WritableByteChannel out, Key asymmetricKey) throws GeneralSecurityException, IOException{
this(out, "AES",128,"RSA", asymmetricKey);
}
public EncryptingOutputStream(WritableByteChannel out, String symmetricAlgorithm, int symmetricKeysize, String asymmetricCipher, Key asymmetricKey) throws GeneralSecurityException, IOException{
public EncryptingByteChannel(WritableByteChannel out, String symmetricAlgorithm, int symmetricKeysize, String asymmetricCipher, Key asymmetricKey) throws GeneralSecurityException, IOException{
KeyGenerator kg = KeyGenerator.getInstance(symmetricAlgorithm);
//log.fine("Generating symmetric key "+symmetricAlgorithm+" with size "+symmetricKeysize);
kg.init( symmetricKeysize );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment