blob: 3430c086d955f1c813dbb65f5a7ba5f2e3478e53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "bu/cipher.h"
Bu::Cipher::Cipher( Bu::Stream &rNext ) :
Bu::Filter( rNext )
{
}
Bu::Cipher::~Cipher()
{
}
void Bu::Cipher::start()
{
}
Bu::size Bu::Cipher::stop()
{
return 0;
}
Bu::size Bu::Cipher::read( void *pBuf, Bu::size iBytes )
{
uint32_t i;
if (iBytes%8)
{
return 0;
}
iBytes /= 8;
for (i=0;i<iBytes;i++)
{
void *pSeg = ((char *)pBuf)+(i*8);
int iRead = rNext.read( pSeg, 8 );
decipher( pSeg );
}
return iBytes*8;
}
Bu::size Bu::Cipher::write( const void *pBuf, Bu::size iBytes )
{
uint32_t i;
if (iBytes%8)
{
return 0;
}
iBytes /= 8;
char buf[8];
for (i=0;i<iBytes;i++)
{
memcpy( buf, ((const char *)pBuf)+(i*8), 8 );
encipher( buf );
rNext.write( buf, 8 );
}
memset( &buf, 0, 8 );
return iBytes*8;
}
|