aboutsummaryrefslogtreecommitdiff
path: root/src/experimental/ciphermodecbc.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-28 17:39:09 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-28 17:39:09 +0000
commit03e8c5ad314252cde58c53688c70b9f836a1d5b4 (patch)
tree6d26558aaae5e3758ca8b23c4086116e6d6b2636 /src/experimental/ciphermodecbc.h
parent223e2986ad7752d38ce24d1cbeff47db98df1ae3 (diff)
downloadlibbu++-03e8c5ad314252cde58c53688c70b9f836a1d5b4.tar.gz
libbu++-03e8c5ad314252cde58c53688c70b9f836a1d5b4.tar.bz2
libbu++-03e8c5ad314252cde58c53688c70b9f836a1d5b4.tar.xz
libbu++-03e8c5ad314252cde58c53688c70b9f836a1d5b4.zip
More comments; moved the encryption system to unstable.
Diffstat (limited to 'src/experimental/ciphermodecbc.h')
-rw-r--r--src/experimental/ciphermodecbc.h54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/experimental/ciphermodecbc.h b/src/experimental/ciphermodecbc.h
deleted file mode 100644
index b06a972..0000000
--- a/src/experimental/ciphermodecbc.h
+++ /dev/null
@@ -1,54 +0,0 @@
1#ifndef BU_MODE_CBC_H
2#define BU_MODE_CBC_H
3
4#include "bu/filter.h"
5#include "bu/string.h"
6
7namespace Bu
8{
9 template<int iBlockSize, typename CipherType>
10 class CipherModeCbc : public CipherType
11 {
12 public:
13 CipherModeCbc(class Stream &rNext ) :
14 CipherType( rNext ),
15 bStart( true )
16 {
17 memset( aVector, 0, iBlockSize );
18 }
19
20 virtual ~CipherModeCbc()
21 {
22 }
23
24 void setIv( const Bu::String &sIv )
25 {
26 memcpy( aVector, sIv.getStr(), iBlockSize );
27 }
28
29 protected:
30 void decipher( void *pBuf )
31 {
32 uint8_t aTmp[iBlockSize];
33 memcpy( aTmp, pBuf, iBlockSize );
34 CipherType::decipher( pBuf );
35 for( int j = 0; j < iBlockSize; j++ )
36 ((uint8_t *)pBuf)[j] ^= aVector[j];
37 memcpy( aVector, aTmp, iBlockSize );
38 }
39
40 void encipher( void *pBuf )
41 {
42 for( int j = 0; j < iBlockSize; j++ )
43 ((uint8_t *)pBuf)[j] ^= aVector[j];
44 CipherType::encipher( pBuf );
45 memcpy( aVector, pBuf, iBlockSize );
46 }
47
48 private:
49 bool bStart;
50 uint8_t aVector[iBlockSize];
51 };
52};
53
54#endif