Security Scol plugin
Protected Member Functions | Protected Attributes | List of all members
ChaCha_Policy Class Reference

ChaCha stream cipher implementation. More...

#include <chacha.h>

Inheritance diagram for ChaCha_Policy:
AdditiveCipherConcretePolicy< word32, 16 > AdditiveCipherAbstractPolicy

Protected Member Functions

void CipherSetKey (const NameValuePairs &params, const byte *key, size_t length)
 Key the cipher.
 
void OperateKeystream (KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
 Operates the keystream.
 
void CipherResynchronize (byte *keystreamBuffer, const byte *IV, size_t length)
 Resynchronize the cipher.
 
bool CipherIsRandomAccess () const
 Flag indicating random access.
 
void SeekToIteration (lword iterationCount)
 Seeks to a random position in the stream.
 
unsigned int GetAlignment () const
 Provides data alignment requirements.
 
unsigned int GetOptimalBlockSize () const
 Provides number of ideal bytes to process.
 
std::string AlgorithmName () const
 
std::string AlgorithmProvider () const
 Retrieve the provider of this algorithm.
 
 CRYPTOPP_CONSTANT (ROUNDS=20)
 

Protected Attributes

FixedSizeAlignedSecBlock< word32, 16 > m_state
 
unsigned int m_rounds
 

Additional Inherited Members

- Public Types inherited from AdditiveCipherConcretePolicy< word32, 16 >
typedef word32 WordType
 Word type for the cipher.
 
- Public Member Functions inherited from AdditiveCipherConcretePolicy< word32, 16 >
 CRYPTOPP_CONSTANT (BYTES_PER_ITERATION=sizeof(WordType) *W)
 Number of bytes for an iteration.
 
unsigned int GetBytesPerIteration () const
 Provides number of bytes operated upon during an iteration.
 
unsigned int GetIterationsToBuffer () const
 Provides buffer size based on iterations.
 
bool CanOperateKeystream () const
 Flag indicating.
 
- Public Member Functions inherited from AdditiveCipherAbstractPolicy
virtual void WriteKeystream (byte *keystream, size_t iterationCount)
 Generate the keystream.
 

Detailed Description

ChaCha stream cipher implementation.

Since
Crypto++ 5.6.4

Definition at line 57 of file chacha.h.

Constructor & Destructor Documentation

◆ ~ChaCha_Policy()

virtual ChaCha_Policy::~ChaCha_Policy ( )
inlinevirtual

Definition at line 60 of file chacha.h.

◆ ChaCha_Policy()

ChaCha_Policy::ChaCha_Policy ( )
inline

Definition at line 61 of file chacha.h.

Member Function Documentation

◆ AlgorithmName()

ANONYMOUS_NAMESPACE_END std::string ChaCha_Policy::AlgorithmName ( ) const
protected

Definition at line 311 of file chacha.cpp.

◆ AlgorithmProvider()

std::string ChaCha_Policy::AlgorithmProvider ( ) const
protectedvirtual

Retrieve the provider of this algorithm.

Returns
the algorithm provider

The algorithm provider can be a name like "C++", "SSE", "NEON", "AESNI", "ARMv8" and "Power8". C++ is standard C++ code. Other labels, like SSE, usually indicate a specialized implementation using instructions from a higher instruction set architecture (ISA). Future labels may include external hardware like a hardware security module (HSM).

Generally speaking Wei Dai's original IA-32 ASM code falls under "SSE2". Labels like "SSSE3" and "SSE4.1" follow after Wei's code and use intrinsics instead of ASM.

Algorithms which combine different instructions or ISAs provide the dominant one. For example on x86 AES/GCM returns "AESNI" rather than "CLMUL" or "AES+SSE4.1" or "AES+CLMUL" or "AES+SSE4.1+CLMUL".

Note
Provider is not universally implemented yet.

Reimplemented from AdditiveCipherAbstractPolicy.

Definition at line 316 of file chacha.cpp.

◆ CipherIsRandomAccess()

bool ChaCha_Policy::CipherIsRandomAccess ( ) const
inlineprotectedvirtual

Flag indicating random access.

Returns
true if the cipher is seekable, false otherwise
See also
SeekToIteration()

Implements AdditiveCipherAbstractPolicy.

Definition at line 67 of file chacha.h.

◆ CipherResynchronize()

void ChaCha_Policy::CipherResynchronize ( byte keystreamBuffer,
const byte iv,
size_t  length 
)
protectedvirtual

Resynchronize the cipher.

Parameters
keystreamBufferthe keystream buffer
iva byte array used to resynchronize the cipher
lengththe size of the IV array

Reimplemented from AdditiveCipherAbstractPolicy.

Definition at line 347 of file chacha.cpp.

◆ CipherSetKey()

void ChaCha_Policy::CipherSetKey ( const NameValuePairs params,
const byte key,
size_t  length 
)
protectedvirtual

Key the cipher.

Parameters
paramsset of NameValuePairs use to initialize this object
keya byte array used to key the cipher
lengththe size of the key array

Implements AdditiveCipherAbstractPolicy.

Definition at line 321 of file chacha.cpp.

◆ GetAlignment()

unsigned int ChaCha_Policy::GetAlignment ( ) const
protectedvirtual

Provides data alignment requirements.

Returns
data alignment requirements, in bytes

Internally, the default implementation returns 1. If the stream cipher is implemented using an SSE2 ASM or intrinsics, then the value returned is usually 16.

Reimplemented from AdditiveCipherConcretePolicy< word32, 16 >.

Definition at line 363 of file chacha.cpp.

◆ GetOptimalBlockSize()

unsigned int ChaCha_Policy::GetOptimalBlockSize ( ) const
protectedvirtual

Provides number of ideal bytes to process.

Returns
the ideal number of bytes to process

Internally, the default implementation returns GetBytesPerIteration()

See also
GetBytesPerIteration()

Reimplemented from AdditiveCipherAbstractPolicy.

Definition at line 368 of file chacha.cpp.

◆ OperateKeystream()

void ChaCha_Policy::OperateKeystream ( KeystreamOperation  operation,
byte output,
const byte input,
size_t  iterationCount 
)
protectedvirtual

Operates the keystream.

Parameters
operationthe operation with additional flags
outputthe output buffer
inputthe input buffer
iterationCountthe number of iterations to perform on the input

OperateKeystream() will attempt to operate upon GetOptimalBlockSize() buffer, which will be derived from GetBytesPerIteration().

See also
CanOperateKeystream(), OperateKeystream(), WriteKeystream(), KeystreamOperation()

Implements AdditiveCipherConcretePolicy< word32, 16 >.

Definition at line 373 of file chacha.cpp.

◆ SeekToIteration()

void ChaCha_Policy::SeekToIteration ( lword  iterationCount)
protectedvirtual

Seeks to a random position in the stream.

See also
CipherIsRandomAccess()

Reimplemented from AdditiveCipherAbstractPolicy.

Definition at line 357 of file chacha.cpp.

Member Data Documentation

◆ m_rounds

unsigned int ChaCha_Policy::m_rounds
protected

Definition at line 77 of file chacha.h.

◆ m_state

FixedSizeAlignedSecBlock<word32, 16> ChaCha_Policy::m_state
protected

Definition at line 76 of file chacha.h.


The documentation for this class was generated from the following files: