summaryrefslogtreecommitdiff
path: root/src/experimental/ciphermodecbc.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/experimental/ciphermodecbc.h
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/experimental/ciphermodecbc.h')
-rw-r--r--src/experimental/ciphermodecbc.h86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/experimental/ciphermodecbc.h b/src/experimental/ciphermodecbc.h
index 8fbf9f6..b06a972 100644
--- a/src/experimental/ciphermodecbc.h
+++ b/src/experimental/ciphermodecbc.h
@@ -6,49 +6,49 @@
6 6
7namespace Bu 7namespace Bu
8{ 8{
9 template<int iBlockSize, typename CipherType> 9 template<int iBlockSize, typename CipherType>
10 class CipherModeCbc : public CipherType 10 class CipherModeCbc : public CipherType
11 { 11 {
12 public: 12 public:
13 CipherModeCbc(class Stream &rNext ) : 13 CipherModeCbc(class Stream &rNext ) :
14 CipherType( rNext ), 14 CipherType( rNext ),
15 bStart( true ) 15 bStart( true )
16 { 16 {
17 memset( aVector, 0, iBlockSize ); 17 memset( aVector, 0, iBlockSize );
18 } 18 }
19 19
20 virtual ~CipherModeCbc() 20 virtual ~CipherModeCbc()
21 { 21 {
22 } 22 }
23 23
24 void setIv( const Bu::String &sIv ) 24 void setIv( const Bu::String &sIv )
25 { 25 {
26 memcpy( aVector, sIv.getStr(), iBlockSize ); 26 memcpy( aVector, sIv.getStr(), iBlockSize );
27 } 27 }
28 28
29 protected: 29 protected:
30 void decipher( void *pBuf ) 30 void decipher( void *pBuf )
31 { 31 {
32 uint8_t aTmp[iBlockSize]; 32 uint8_t aTmp[iBlockSize];
33 memcpy( aTmp, pBuf, iBlockSize ); 33 memcpy( aTmp, pBuf, iBlockSize );
34 CipherType::decipher( pBuf ); 34 CipherType::decipher( pBuf );
35 for( int j = 0; j < iBlockSize; j++ ) 35 for( int j = 0; j < iBlockSize; j++ )
36 ((uint8_t *)pBuf)[j] ^= aVector[j]; 36 ((uint8_t *)pBuf)[j] ^= aVector[j];
37 memcpy( aVector, aTmp, iBlockSize ); 37 memcpy( aVector, aTmp, iBlockSize );
38 } 38 }
39 39
40 void encipher( void *pBuf ) 40 void encipher( void *pBuf )
41 { 41 {
42 for( int j = 0; j < iBlockSize; j++ ) 42 for( int j = 0; j < iBlockSize; j++ )
43 ((uint8_t *)pBuf)[j] ^= aVector[j]; 43 ((uint8_t *)pBuf)[j] ^= aVector[j];
44 CipherType::encipher( pBuf ); 44 CipherType::encipher( pBuf );
45 memcpy( aVector, pBuf, iBlockSize ); 45 memcpy( aVector, pBuf, iBlockSize );
46 } 46 }
47 47
48 private: 48 private:
49 bool bStart; 49 bool bStart;
50 uint8_t aVector[iBlockSize]; 50 uint8_t aVector[iBlockSize];
51 }; 51 };
52}; 52};
53 53
54#endif 54#endif