Security Scol plugin
safer.h
Go to the documentation of this file.
1// safer.h - originally written and placed in the public domain by Wei Dai
2
5
6#ifndef CRYPTOPP_SAFER_H
7#define CRYPTOPP_SAFER_H
8
9#include "seckey.h"
10#include "secblock.h"
11
12NAMESPACE_BEGIN(CryptoPP)
13
14
15class SAFER
16{
17public:
19 class CRYPTOPP_NO_VTABLE Base : public BlockCipher
20 {
21 public:
22 unsigned int OptimalDataAlignment() const {return 1;}
23 void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
24
25 protected:
26 virtual bool Strengthened() const =0;
27
28 SecByteBlock keySchedule;
29 static const byte exp_tab[256];
30 static const byte log_tab[256];
31 };
32
34 class CRYPTOPP_NO_VTABLE Enc : public Base
35 {
36 public:
37 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
38 };
39
41 class CRYPTOPP_NO_VTABLE Dec : public Base
42 {
43 public:
44 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
45 };
46};
47
53template <class BASE, class INFO, bool STR>
54class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
55{
56protected:
57 bool Strengthened() const {return STR;}
58};
59
61struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
62{
63 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SAFER-K";}
64};
65
74
76struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
77{
78 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SAFER-SK";}
79};
80
89
92
95
96NAMESPACE_END
97
98#endif
Provides class member functions to key a block cipher.
Definition seckey.h:318
Interface for one direction (encryption or decryption) of a block cipher.
Definition cryptlib.h:1283
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition seckey.h:306
virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
Encrypt or decrypt a block.
Inherited by algorithms with fixed block size.
Definition seckey.h:41
Interface for retrieving values given their names.
Definition cryptlib.h:322
SAFER block cipher default operation.
Definition safer.h:20
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition safer.h:22
SAFER block cipher decryption operation.
Definition safer.h:42
SAFER block cipher encryption operation.
Definition safer.h:35
SAFER block cipher default implementation.
Definition safer.h:55
SAFER-K block cipher.
Definition safer.h:69
SAFER-SK block cipher.
Definition safer.h:84
SAFER block cipher.
Definition safer.h:16
virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)=0
Sets the key for this object without performing parameter validation.
Inherited by keyed algorithms with variable key length.
Definition seckey.h:166
Inherited by algorithms with variable number of rounds.
Definition seckey.h:65
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition seckey.h:399
SAFER-K block cipher information.
Definition safer.h:62
SAFER-SK block cipher information.
Definition safer.h:77