Crypto++  5.6.4
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 //! \class SEAL_Info
15 //! \brief SEAL stream cipher information
16 //! \tparam B Endianess of the stream cipher
17 template <class B = BigEndian>
18 struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV, 4>
19 {
20  CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
21 };
22 
23 //! \class SEAL_Policy
24 //! \brief SEAL stream cipher operation
25 //! \tparam B Endianess of the stream cipher
26 template <class B = BigEndian>
27 class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
28 {
29 protected:
30  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
31  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
32  void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
33  bool CipherIsRandomAccess() const {return true;}
34  void SeekToIteration(lword iterationCount);
35 
36 private:
39  SecBlock<word32> m_R;
40 
41  word32 m_startCount, m_iterationsPerCount;
42  word32 m_outsideCounter, m_insideCounter;
43 };
44 
45 //! \class SEAL
46 //! \brief SEAL stream cipher
47 //! \tparam B Endianess of the stream cipher
48 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#SEAL-3.0-BE">SEAL</a>
49 template <class B = BigEndian>
50 struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
51 {
53  typedef Encryption Decryption;
54 };
55 
56 NAMESPACE_END
57 
58 #endif
AdditiveCipherAbstractPolicy::CipherIsRandomAccess
virtual bool CipherIsRandomAccess() const =0
Flag indicating random access.
AdditiveCipherAbstractPolicy::CipherResynchronize
virtual void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
Resynchronize the cipher.
Definition: strciphr.h:166
SymmetricCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher.
Definition: seckey.h:439
SymmetricCipherFinal
SymmetricCipher implementation.
Definition: strciphr.h:582
AdditiveCipherConcretePolicy
Base class for additive stream ciphers.
Definition: strciphr.h:188
AdditiveCipherAbstractPolicy::CipherSetKey
virtual void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)=0
Key the cipher.
secblock.h
Classes and functions for secure memory allocations.
LITTLE_ENDIAN_ORDER
@ LITTLE_ENDIAN_ORDER
byte order is little-endian
Definition: cryptlib.h:125
SEAL_Info
SEAL stream cipher information.
Definition: seal.h:18
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:128
AdditiveCipherTemplate
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:269
KeystreamOperation
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:92
SEAL
SEAL stream cipher.
Definition: seal.h:50
FixedSizeSecBlock< word32, 512 >
CryptoPP
Crypto++ library namespace.
AdditiveCipherAbstractPolicy::SeekToIteration
virtual void SeekToIteration(lword iterationCount)
Seeks to a random position in the stream.
Definition: strciphr.h:177
SEAL_Policy
SEAL stream cipher operation.
Definition: seal.h:27
SecBlock< word32 >
AdditiveCipherConcretePolicy::OperateKeystream
virtual void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)=0
Operates the keystream.
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:277
strciphr.h
Classes for implementing stream ciphers.