Security Scol plugin
rabbit.h
Go to the documentation of this file.
1// rabbit.h - written and placed in the public domain by Jeffrey Walton
2// based on public domain code by Martin Boesgaard, Mette Vesterager,
3// Thomas Pedersen, Jesper Christiansen and Ove Scavenius.
4//
5// The reference materials and source files are available at
6// The eSTREAM Project, http://www.ecrypt.eu.org/stream/e2-rabbit.html.
7
14
15#ifndef CRYPTOPP_RABBIT_H
16#define CRYPTOPP_RABBIT_H
17
18#include "strciphr.h"
19#include "secblock.h"
20
21// The library does not have a way to describe an optional IV. Rabbit takes
22// an optional IV so two classes are offered to bridge the gap. One provides
23// Rabbit without an IV and the second provides Rabbit with an IV.
24
25NAMESPACE_BEGIN(CryptoPP)
26
27
29struct RabbitInfo : public FixedKeyLength<16, SimpleKeyingInterface::NOT_RESYNCHRONIZABLE>
30{
31 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "Rabbit"; }
32};
33
36struct RabbitWithIVInfo : public FixedKeyLength<16, SimpleKeyingInterface::UNIQUE_IV, 8>
37{
38 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "RabbitWithIV"; }
39};
40
43class RabbitPolicy : public AdditiveCipherConcretePolicy<word32, 4>, public RabbitInfo
44{
45protected:
46 void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
47 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
48 bool CanOperateKeystream() const { return true; }
49 bool CipherIsRandomAccess() const { return false; }
50
51private:
52 // Master and working states
53 FixedSizeSecBlock<word32, 8> m_mx, m_mc, m_wx, m_wc;
54 // Workspace
56 word32 m_mcy, m_wcy; // carry
57};
58
62{
63protected:
64 void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
65 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
66 void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
67 bool CanOperateKeystream() const { return true; }
68 bool CipherIsRandomAccess() const { return false; }
69
70private:
71 // Master and working states
72 FixedSizeSecBlock<word32, 8> m_mx, m_mc, m_wx, m_wc;
73 // Workspace
75 word32 m_mcy, m_wcy; // carry
76};
77
93
109
110NAMESPACE_END
111
112#endif // CRYPTOPP_RABBIT_H
Inherited by keyed algorithms with fixed key length.
Definition seckey.h:125
Fixed size stack-based SecBlock.
Definition secblock.h:1246
Interface for retrieving values given their names.
Definition cryptlib.h:322
Rabbit stream cipher implementation.
Definition rabbit.h:44
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition rabbit.h:49
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
Operates the keystream.
Definition rabbit.cpp:132
bool CanOperateKeystream() const
Flag indicating.
Definition rabbit.h:48
void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
Key the cipher.
Definition rabbit.cpp:86
Rabbit stream cipher implementation.
Definition rabbit.h:62
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition rabbit.h:68
void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
Key the cipher.
Definition rabbit.cpp:157
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
Operates the keystream.
Definition rabbit.cpp:234
bool CanOperateKeystream() const
Flag indicating.
Definition rabbit.h:67
void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
Resynchronize the cipher.
Definition rabbit.cpp:203
Interface for algorithms that take byte strings as keys.
Definition cryptlib.h:642
SymmetricCipher implementation.
Definition strciphr.h:684
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
Classes and functions for secure memory allocations.
Classes for implementing stream ciphers.
KeystreamOperation
Keystream operation flags.
Definition strciphr.h:88
Base class for additive stream ciphers.
Definition strciphr.h:202
Rabbit stream cipher.
Definition rabbit.h:89
Rabbit stream cipher information.
Definition rabbit.h:30
Rabbit stream cipher.
Definition rabbit.h:105
Rabbit stream cipher information.
Definition rabbit.h:37
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher.
Definition seckey.h:414