Crypto++
Main Page
Namespaces
Classes
Files
File List
File Members
safer.h
Go to the documentation of this file.
1
#ifndef CRYPTOPP_SAFER_H
2
#define CRYPTOPP_SAFER_H
3
4
/** \file
5
*/
6
7
#include "seckey.h"
8
#include "secblock.h"
9
10
NAMESPACE_BEGIN(CryptoPP)
11
12
/// base class, do not use directly
13
class
SAFER
14
{
15
public
:
16
class
CRYPTOPP_NO_VTABLE
Base
:
public
BlockCipher
17
{
18
public
:
19
unsigned
int
OptimalDataAlignment
()
const
{
return
1;}
20
void
UncheckedSetKey(
const
byte *userkey,
unsigned
int
length,
const
NameValuePairs
¶ms);
21
22
protected
:
23
virtual
bool
Strengthened()
const
=0;
24
25
SecByteBlock
keySchedule;
26
static
const
byte exp_tab[256];
27
static
const
byte log_tab[256];
28
};
29
30
class
CRYPTOPP_NO_VTABLE
Enc
:
public
Base
31
{
32
public
:
33
void
ProcessAndXorBlock
(
const
byte *inBlock,
const
byte *xorBlock, byte *outBlock)
const
;
34
};
35
36
class
CRYPTOPP_NO_VTABLE
Dec
:
public
Base
37
{
38
public
:
39
void
ProcessAndXorBlock
(
const
byte *inBlock,
const
byte *xorBlock, byte *outBlock)
const
;
40
};
41
};
42
43
template
<
class
BASE,
class
INFO,
bool
STR>
44
class
CRYPTOPP_NO_VTABLE
SAFER_Impl
:
public
BlockCipherImpl
<INFO, BASE>
45
{
46
protected
:
47
bool
Strengthened()
const
{
return
STR;}
48
};
49
50
//! _
51
struct
SAFER_K_Info
:
public
FixedBlockSize
<8>,
public
VariableKeyLength
<16, 8, 16, 8>,
public
VariableRounds
<10, 1, 13>
52
{
53
static
const
char
*StaticAlgorithmName() {
return
"SAFER-K"
;}
54
};
55
56
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
57
class
SAFER_K
:
public
SAFER_K_Info
,
public
SAFER
,
public
BlockCipherDocumentation
58
{
59
public
:
60
typedef
BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_K_Info, false>
>
Encryption
;
61
typedef
BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_K_Info, false>
>
Decryption
;
62
};
63
64
//! _
65
struct
SAFER_SK_Info
:
public
FixedBlockSize
<8>,
public
VariableKeyLength
<16, 8, 16, 8>,
public
VariableRounds
<10, 1, 13>
66
{
67
static
const
char
*StaticAlgorithmName() {
return
"SAFER-SK"
;}
68
};
69
70
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
71
class
SAFER_SK
:
public
SAFER_SK_Info
,
public
SAFER
,
public
BlockCipherDocumentation
72
{
73
public
:
74
typedef
BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_SK_Info, true>
>
Encryption
;
75
typedef
BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_SK_Info, true>
>
Decryption
;
76
};
77
78
typedef
SAFER_K::Encryption
SAFER_K_Encryption
;
79
typedef
SAFER_K::Decryption
SAFER_K_Decryption
;
80
81
typedef
SAFER_SK::Encryption
SAFER_SK_Encryption
;
82
typedef
SAFER_SK::Decryption
SAFER_SK_Decryption
;
83
84
NAMESPACE_END
85
86
#endif
Generated on Thu Jul 19 2012 06:33:22 for Crypto++ by
1.8.1.1