aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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