Crypto++ 8.1 Free C++ class library of cryptographic schemes

seal.h
Go to the documentation of this file.
1 // seal.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file seal.h
4 /// \brief Classes for SEAL stream cipher
5 /// \since Crypto++ 2.2
6
7 #ifndef CRYPTOPP_SEAL_H
8 #define CRYPTOPP_SEAL_H
9
10 #include "strciphr.h"
11 #include "secblock.h"
12
13 NAMESPACE_BEGIN(CryptoPP)
14
15 /// \brief SEAL stream cipher information
16 /// \tparam B Endianness of the stream cipher
17 /// \since Crypto++ 2.2
18 template <class B = BigEndian>
19 struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV, 4>
20 {
21 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
22 };
23
24 /// \brief SEAL stream cipher operation
25 /// \tparam B Endianness of the stream cipher
26 /// \since Crypto++ 2.2
27 template <class B = BigEndian>
28 class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
29 {
30 protected:
31 void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
32 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
33 void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
34 bool CipherIsRandomAccess() const {return true;}
35 void SeekToIteration(lword iterationCount);
36
37 private:
38 FixedSizeSecBlock<word32, 512> m_T;
39 FixedSizeSecBlock<word32, 256> m_S;
40 SecBlock<word32> m_R;
41
42 word32 m_startCount, m_iterationsPerCount;
43 word32 m_outsideCounter, m_insideCounter;
44 };
45
46 /// \brief SEAL stream cipher
47 /// \tparam B Endianness of the stream cipher
48 /// \sa <a href="http://www.cryptopp.com/wiki/SEAL-3.0-BE">SEAL</a>
49 /// \since Crypto++ 2.2
50 template <class B = BigEndian>
51 struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
52 {
53 typedef SymmetricCipherFinal<ConcretePolicyHolder<SEAL_Policy<B>, AdditiveCipherTemplate<> >, SEAL_Info<B> > Encryption;
54 typedef Encryption Decryption;
55 };
56
57 NAMESPACE_END
58
59 #endif
SEAL_Policy
SEAL stream cipher operation.
Definition: seal.h:28
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:124
AdditiveCipherConcretePolicy
Base class for additive stream ciphers.
Definition: strciphr.h:201
SecBlock< word32 >
LITTLE_ENDIAN_ORDER
byte order is little-endian
Definition: cryptlib.h:145
secblock.h
Classes and functions for secure memory allocations.
SEAL_Info
SEAL stream cipher information.
Definition: seal.h:19
AdditiveCipherConcretePolicy::OperateKeystream
virtual void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)=0
Operates the keystream.
FixedSizeSecBlock< word32, 512 >
SEAL
SEAL stream cipher.
Definition: seal.h:51
Name::IV
const char * IV()
ConstByteArrayParameter, also accepts const byte * for backwards compatibility.
Definition: argnames.h:21
strciphr.h
Classes for implementing stream ciphers.
SymmetricCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
Definition: seckey.h:413
KeystreamOperation
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:88
CryptoPP
Crypto++ library namespace.
SymmetricCipherFinal
SymmetricCipher implementation.
Definition: strciphr.h:673
AdditiveCipherTemplate<>
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:293