Crypto++  5.6.3
Free C++ class library of cryptographic schemes
seal.h
Go to the documentation of this file.
1 // seal.h - written and placed in the public domain by Wei Dai
2 
3 //! \file seal.h
4 //! \brief Classes for SEAL stream cipher
5 
6 #ifndef CRYPTOPP_SEAL_H
7 #define CRYPTOPP_SEAL_H
8 
9 #include "strciphr.h"
10 #include "secblock.h"
11 
12 NAMESPACE_BEGIN(CryptoPP)
13 
14 //! _
15 template <class B = BigEndian>
16 struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV, 4>
17 {
18  static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
19 };
20 
21 template <class B = BigEndian>
22 class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
23 {
24 protected:
25  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
26  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
27  void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
28  bool CipherIsRandomAccess() const {return true;}
29  void SeekToIteration(lword iterationCount);
30 
31 private:
34  SecBlock<word32> m_R;
35 
36  word32 m_startCount, m_iterationsPerCount;
37  word32 m_outsideCounter, m_insideCounter;
38 };
39 
40 //! <a href="http://www.weidai.com/scan-mirror/cs.html#SEAL-3.0-BE">SEAL</a>
41 template <class B = BigEndian>
42 struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
43 {
45  typedef Encryption Decryption;
46 };
47 
48 NAMESPACE_END
49 
50 #endif
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:117
Converts a typename to an enumerated value.
Definition: cryptlib.h:115
byte order is little-endian
Definition: cryptlib.h:125
Classes and functions for secure memory allocations.
_
Definition: seal.h:16
Interface for algorithms that take byte strings as keys.
Definition: cryptlib.h:514
SEAL
Definition: seal.h:42
const char * IV()
ConstByteArrayParameter, also accepts const byte * for backwards compatibility.
Definition: argnames.h:21
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
Definition: seckey.h:412
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:277