1
by weidai
Initial revision |
1 |
#ifndef CRYPTOPP_CAST_H
|
2 |
#define CRYPTOPP_CAST_H
|
|
3 |
||
4 |
/** \file
|
|
5 |
*/
|
|
6 |
||
7 |
#include "seckey.h" |
|
8 |
#include "secblock.h" |
|
9 |
||
10 |
NAMESPACE_BEGIN(CryptoPP) |
|
11 |
||
12 |
class CAST |
|
13 |
{
|
|
14 |
protected: |
|
15 |
static const word32 S[8][256]; |
|
16 |
};
|
|
17 |
||
173
by weidai
fix documentation, fix PanamaMAC, fix algorithm names |
18 |
//! algorithm info
|
1
by weidai
Initial revision |
19 |
struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16> |
20 |
{
|
|
21 |
static const char *StaticAlgorithmName() {return "CAST-128";} |
|
22 |
};
|
|
23 |
||
24 |
/// <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-128">CAST-128</a>
|
|
25 |
class CAST128 : public CAST128_Info, public BlockCipherDocumentation |
|
26 |
{
|
|
75
by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes |
27 |
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info> |
1
by weidai
Initial revision |
28 |
{
|
29 |
public: |
|
232
by weidai
port to GCC 4, reorganize implementations of SetKey |
30 |
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); |
1
by weidai
Initial revision |
31 |
|
32 |
protected: |
|
33 |
bool reduced; |
|
34 |
FixedSizeSecBlock<word32, 32> K; |
|
35 |
};
|
|
36 |
||
57
by weidai
add CRYPTOPP_NO_VTABLE |
37 |
class CRYPTOPP_NO_VTABLE Enc : public Base |
1
by weidai
Initial revision |
38 |
{
|
39 |
public: |
|
40 |
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
|
41 |
};
|
|
42 |
||
57
by weidai
add CRYPTOPP_NO_VTABLE |
43 |
class CRYPTOPP_NO_VTABLE Dec : public Base |
1
by weidai
Initial revision |
44 |
{
|
45 |
public: |
|
46 |
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
|
47 |
};
|
|
48 |
||
49 |
public: |
|
75
by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes |
50 |
typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; |
51 |
typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; |
|
1
by weidai
Initial revision |
52 |
};
|
53 |
||
173
by weidai
fix documentation, fix PanamaMAC, fix algorithm names |
54 |
//! algorithm info
|
1
by weidai
Initial revision |
55 |
struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32> |
56 |
{
|
|
57 |
static const char *StaticAlgorithmName() {return "CAST-256";} |
|
58 |
};
|
|
59 |
||
60 |
//! <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a>
|
|
61 |
class CAST256 : public CAST256_Info, public BlockCipherDocumentation |
|
62 |
{
|
|
75
by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes |
63 |
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info> |
1
by weidai
Initial revision |
64 |
{
|
65 |
public: |
|
232
by weidai
port to GCC 4, reorganize implementations of SetKey |
66 |
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); |
1
by weidai
Initial revision |
67 |
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
68 |
||
69 |
protected: |
|
70 |
static const word32 t_m[8][24]; |
|
71 |
static const unsigned int t_r[8][24]; |
|
72 |
||
73 |
static void Omega(int i, word32 kappa[8]); |
|
74 |
||
75 |
FixedSizeSecBlock<word32, 8*12> K; |
|
76 |
};
|
|
77 |
||
78 |
public: |
|
75
by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes |
79 |
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption; |
80 |
typedef BlockCipherFinal<DECRYPTION, Base> Decryption; |
|
1
by weidai
Initial revision |
81 |
};
|
82 |
||
83 |
typedef CAST128::Encryption CAST128Encryption; |
|
84 |
typedef CAST128::Decryption CAST128Decryption; |
|
85 |
||
86 |
typedef CAST256::Encryption CAST256Encryption; |
|
87 |
typedef CAST256::Decryption CAST256Decryption; |
|
88 |
||
89 |
NAMESPACE_END
|
|
90 |
||
91 |
#endif
|