aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-06-16 01:11:23 +0000
committerMike Buland <eichlan@xagasoft.com>2012-06-16 01:11:23 +0000
commit0d10472c9c375026d0f98cfb066a6fb9d2992030 (patch)
treea6c98b0f206a456dd72a53276f885515963bb3a9 /src
parent7ea5c06059ee6668d6e6d04c3b3dcb8557061696 (diff)
downloadlibbu++-0d10472c9c375026d0f98cfb066a6fb9d2992030.tar.gz
libbu++-0d10472c9c375026d0f98cfb066a6fb9d2992030.tar.bz2
libbu++-0d10472c9c375026d0f98cfb066a6fb9d2992030.tar.xz
libbu++-0d10472c9c375026d0f98cfb066a6fb9d2992030.zip
Cipher will fill with zeros when flushed. There seems to be some odd
interaction still, here and there. I'll see if I can track it down.
Diffstat (limited to 'src')
-rw-r--r--src/experimental/cipher.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/experimental/cipher.h b/src/experimental/cipher.h
index a17030d..814e88c 100644
--- a/src/experimental/cipher.h
+++ b/src/experimental/cipher.h
@@ -80,21 +80,33 @@ namespace Bu
80 80
81 while( iPos < iBytes ) 81 while( iPos < iBytes )
82 { 82 {
83 int iLeft = Bu::min((int)(iBytes-iPos),iBlockSize-iReadBufFill); 83 int iLeft = Bu::min((int)(iBytes-iPos),iBlockSize-iWriteBufFill);
84 memcpy( aReadBuf+iReadBufFill, (char *)pBuf+iPos, iLeft ); 84 memcpy( aWriteBuf+iWriteBufFill, (char *)pBuf+iPos, iLeft );
85 iPos += iLeft; 85 iPos += iLeft;
86 iReadBufFill += iLeft; 86 iWriteBufFill += iLeft;
87 if( iReadBufFill == iBlockSize ) 87 if( iWriteBufFill == iBlockSize )
88 { 88 {
89 encipher( aReadBuf ); 89 encipher( aWriteBuf );
90 rNext.write( aReadBuf, iBlockSize ); 90 rNext.write( aWriteBuf, iBlockSize );
91 iReadBufFill = 0; 91 iWriteBufFill = 0;
92 } 92 }
93 } 93 }
94 94
95 return iPos; 95 return iPos;
96 } 96 }
97 97
98 virtual void flush()
99 {
100 if( iWriteBufFill < iBlockSize )
101 {
102 memset( aWriteBuf+iWriteBufFill, 0, iBlockSize-iWriteBufFill );
103 encipher( aWriteBuf );
104 rNext.write( aWriteBuf, iBlockSize );
105 iWriteBufFill = 0;
106 }
107 rNext.flush();
108 }
109
98 using Bu::Stream::read; 110 using Bu::Stream::read;
99 using Bu::Stream::write; 111 using Bu::Stream::write;
100 112