00001
#ifndef CRYPTOPP_SAFER_H
00002
#define CRYPTOPP_SAFER_H
00003
00004
00005
00006
00007
#include "seckey.h"
00008
#include "secblock.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00012
00013 class
SAFER
00014 {
00015
public:
00016
class CRYPTOPP_NO_VTABLE Base :
public BlockCipher
00017 {
00018
public:
00019
unsigned int GetAlignment()
const {
return 1;}
00020
void UncheckedSetKey(
CipherDir dir,
const byte *userkey,
unsigned int length,
unsigned nof_rounds);
00021
00022
bool strengthened;
00023
SecByteBlock keySchedule;
00024
static const byte exp_tab[256];
00025
static const byte log_tab[256];
00026 };
00027
00028
class CRYPTOPP_NO_VTABLE Enc :
public Base
00029 {
00030
public:
00031
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00032 };
00033
00034
class CRYPTOPP_NO_VTABLE Dec :
public Base
00035 {
00036
public:
00037
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00038 };
00039 };
00040
00041
00042 struct SAFER_K_Info :
public FixedBlockSize<8>,
public VariableKeyLength<16, 8, 16, 8>,
public VariableRounds<10, 1, 13>
00043 {
00044
static const char *StaticAlgorithmName() {
return "SAFER-K";}
00045
static unsigned int DefaultRounds(
unsigned int keylength) {
return keylength == 8 ? 6 : 10;}
00046 };
00047
00048
00049 class SAFER_K :
public SAFER_K_Info,
public SAFER,
public BlockCipherDocumentation
00050 {
00051
class CRYPTOPP_NO_VTABLE Enc :
public BlockCipherImpl<SAFER_K_Info, SAFER::Enc>
00052 {
00053
public:
00054 Enc() {strengthened =
false;}
00055 };
00056
00057
class CRYPTOPP_NO_VTABLE Dec :
public BlockCipherImpl<SAFER_K_Info, SAFER::Dec>
00058 {
00059
public:
00060 Dec() {strengthened =
false;}
00061 };
00062
00063
public:
00064 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00065 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00066 };
00067
00068
00069 struct SAFER_SK_Info :
public FixedBlockSize<8>,
public VariableKeyLength<16, 8, 16, 8>,
public VariableRounds<10, 1, 13>
00070 {
00071
static const char *StaticAlgorithmName() {
return "SAFER-SK";}
00072
static unsigned int DefaultRounds(
unsigned int keylength) {
return keylength == 8 ? 8 : 10;}
00073 };
00074
00075
00076 class SAFER_SK :
public SAFER_SK_Info,
public SAFER,
public BlockCipherDocumentation
00077 {
00078
class CRYPTOPP_NO_VTABLE Enc :
public BlockCipherImpl<SAFER_SK_Info, SAFER::Enc>
00079 {
00080
public:
00081 Enc() {strengthened =
true;}
00082 };
00083
00084
class CRYPTOPP_NO_VTABLE Dec :
public BlockCipherImpl<SAFER_SK_Info, SAFER::Dec>
00085 {
00086
public:
00087 Dec() {strengthened =
true;}
00088 };
00089
00090
public:
00091 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00092 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00093 };
00094
00095
typedef SAFER_K::Encryption SAFER_K_Encryption;
00096
typedef SAFER_K::Decryption SAFER_K_Decryption;
00097
00098
typedef SAFER_SK::Encryption SAFER_SK_Encryption;
00099
typedef SAFER_SK::Decryption SAFER_SK_Decryption;
00100
00101 NAMESPACE_END
00102
00103
#endif