|
@@ -88,13 +88,15 @@ void cbc_encrypt ( void *ctx, const void *src, void *dst, size_t len,
|
88
|
88
|
void cbc_decrypt ( void *ctx, const void *src, void *dst, size_t len,
|
89
|
89
|
struct cipher_algorithm *raw_cipher, void *cbc_ctx ) {
|
90
|
90
|
size_t blocksize = raw_cipher->blocksize;
|
|
91
|
+ uint8_t next_cbc_ctx[blocksize];
|
91
|
92
|
|
92
|
93
|
assert ( ( len % blocksize ) == 0 );
|
93
|
94
|
|
94
|
95
|
while ( len ) {
|
|
96
|
+ memcpy ( next_cbc_ctx, src, blocksize );
|
95
|
97
|
cipher_decrypt ( raw_cipher, ctx, src, dst, blocksize );
|
96
|
98
|
cbc_xor ( cbc_ctx, dst, blocksize );
|
97
|
|
- memcpy ( cbc_ctx, src, blocksize );
|
|
99
|
+ memcpy ( cbc_ctx, next_cbc_ctx, blocksize );
|
98
|
100
|
dst += blocksize;
|
99
|
101
|
src += blocksize;
|
100
|
102
|
len -= blocksize;
|