KeccakTools
|
#include <Keccak-fPropagation.h>
Public Types | |
enum | DCorLC { DC = 0, LC } |
Public Member Functions | |
KeccakFPropagation (const KeccakFDCLC &aParent, KeccakFPropagation::DCorLC aDCorLC) | |
DCorLC | getPropagationType () const |
void | display (ostream &out) const |
unsigned int | getWeight (const SliceValue &slice) const |
unsigned int | getWeight (const vector< SliceValue > &state) const |
unsigned int | getMinReverseWeight (const SliceValue &slice) const |
unsigned int | getMinReverseWeight (const vector< SliceValue > &state) const |
unsigned int | getMinReverseWeightAfterLambda (const vector< SliceValue > &state) const |
void | directPi (unsigned int &dx, unsigned int &dy) const |
void | reversePi (unsigned int &dx, unsigned int &dy) const |
AffineSpaceOfStates | buildStateBase (const vector< SliceValue > &state, bool packedIfPossible=false) const |
ReverseStateIterator | getReverseStateIterator (const vector< SliceValue > &stateAfterChi, unsigned int maxWeight=0) const |
bool | isChiCompatible (const RowValue &beforeChi, const RowValue &afterChi) const |
bool | isChiCompatible (const vector< SliceValue > &beforeChi, const vector< SliceValue > &afterChi) const |
bool | isRoundCompatible (const Trail &first, const Trail &second) const |
bool | isThetaJustAfterChi () const |
void | directLambda (const vector< SliceValue > &in, vector< SliceValue > &out) const |
void | reverseLambda (const vector< SliceValue > &in, vector< SliceValue > &out) const |
void | directLambdaBeforeTheta (const vector< SliceValue > &in, vector< SliceValue > &out) const |
void | reverseLambdaBeforeTheta (const vector< SliceValue > &in, vector< SliceValue > &out) const |
void | directLambdaAfterTheta (const vector< SliceValue > &in, vector< SliceValue > &out) const |
void | reverseLambdaAfterTheta (const vector< SliceValue > &in, vector< SliceValue > &out) const |
UINT64 | displayTrailsAndCheck (const string &fileNameIn, ostream &fout, unsigned int maxWeight=0) const |
string | buildFileName (const string &suffix) const |
string | buildFileName (const string &prefix, const string &suffix) const |
Public Attributes | |
vector< ListOfRowPatterns > | directRowOutputListPerInput |
vector< ListOfRowPatterns > | reverseRowOutputListPerInput |
vector< AffineSpaceOfRows > | affinePerInput |
const KeccakFDCLC & | parent |
unsigned int | laneSize |
const string | name |
Protected Attributes | |
KeccakFDCLC::LambdaMode | lambdaMode |
KeccakFDCLC::LambdaMode | reverseLambdaMode |
This class provides the necessary tools to compute the propagation of either differences or linear patterns through the rounds of Keccak-f. To provide methods that work similarly for linear (LC) and differential cryptanalysis (DC), an instance of this class is specialized in either DC or LC. The convention of the direction of propagation is as described in the Keccak main document:
In this context, the words "before" and "after" refer to the "direct" direction.
KeccakFPropagation::KeccakFPropagation | ( | const KeccakFDCLC & | aParent, |
KeccakFPropagation::DCorLC | aDCorLC | ||
) |
This constructor initializes the different attributes as a function of the Keccak-f instance referenced by aParent and whether the instance handles DC or LC (aDCorLC).
aParent | A reference to the Keccak-f instance as a KeccakFDCLC object. |
aDCorLC | The propagation type. |
string KeccakFPropagation::buildFileName | ( | const string & | suffix | ) | const |
This method builds a file name by prepending "DC" or "LC" as a prefix and appending a given suffix to the name produced by KeccakFDCLC::getName().
suffix | The given suffix. |
string KeccakFPropagation::buildFileName | ( | const string & | prefix, |
const string & | suffix | ||
) | const |
This method builds a file name by prepending "DC" or "LC" and a given prefix and appending a given suffix to the name produced by KeccakFDCLC::getName().
prefix | The given prefix. |
suffix | The given suffix. |
AffineSpaceOfStates KeccakFPropagation::buildStateBase | ( | const vector< SliceValue > & | state, |
bool | packedIfPossible = false |
||
) | const |
This method builds an affine set of states corresponding to the propagation of a given input state through χ and λ. The affine space produced thus covers the propagation through a whole round. The parities in the AffineSpaceOfStates object are those before θ.
state | The state before χ to propagate, given as a vector of slices. |
packedIfPossible | If true, the produced object will have AffineSpaceOfStates::packed set to true, unless the parities do not fit in the PackedParity type. If false, the produced object will have AffineSpaceOfStates::packed set to false. |
void KeccakFPropagation::directLambda | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies λ in the "direct" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::directLambdaAfterTheta | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies the part of λ after θ in the "direct" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::directLambdaBeforeTheta | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies the part of λ before θ in the "direct" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::directPi | ( | unsigned int & | dx, |
unsigned int & | dy | ||
) | const |
This method multiplies the vector (dx, dy)t by the matrix π or π-1 to the left:
void KeccakFPropagation::display | ( | ostream & | out | ) | const |
This function displays the possible patterns and their weights.
out | The stream to display to. |
UINT64 KeccakFPropagation::displayTrailsAndCheck | ( | const string & | fileNameIn, |
ostream & | fout, | ||
unsigned int | maxWeight = 0 |
||
) | const |
This methods reads all the trails in a file, checks their consistency and then produces a report in the given output stream. See also Trail::produceHumanReadableFile().
fileNameIn | The name of the file containing the trails. |
fout | The output stream to send the report to. |
maxWeight | The maximum weight to display trails. If 0, the maximum weight of trails to display is computed automatically so that a reasonable number of trails are displayed in the report. |
unsigned int KeccakFPropagation::getMinReverseWeight | ( | const SliceValue & | slice | ) | const [inline] |
This method returns the minimum reverse weight of a slice.
slice | The value of a slice. |
unsigned int KeccakFPropagation::getMinReverseWeight | ( | const vector< SliceValue > & | state | ) | const |
This method returns the minimum reverse weight of a state.
state | The value of a state given as a vector of slices. |
unsigned int KeccakFPropagation::getMinReverseWeightAfterLambda | ( | const vector< SliceValue > & | state | ) | const |
This method returns the minimum reverse weight of a state, to which the reverse λ is first applied. This allows to give a state value before χ (so after λ), which is then converted to a state value after the χ of the previous round (so before λ).
state | The value of a state given as a vector of slices. |
KeccakFPropagation::DCorLC KeccakFPropagation::getPropagationType | ( | ) | const |
This method returns the propagation type (DC or LC) handled by the instance.
ReverseStateIterator KeccakFPropagation::getReverseStateIterator | ( | const vector< SliceValue > & | stateAfterChi, |
unsigned int | maxWeight = 0 |
||
) | const |
This method builds an iterator over the possible states propagating through χ in the "reverse" direction. The iterator can be restricted to run through the states only up to a given maximum propagation weight.
stateAfterChi | The state just after χ given as a vector of slices. |
maxWeight | The maximum propagation weight considered by the iterator. If 0, the iterator runs through all the possible states. |
unsigned int KeccakFPropagation::getWeight | ( | const vector< SliceValue > & | state | ) | const |
This method returns the propagation weight of a state.
state | The value of a state given as a vector of slices. |
unsigned int KeccakFPropagation::getWeight | ( | const SliceValue & | slice | ) | const [inline] |
This method returns the propagation weight of a slice.
slice | The value of a slice. |
bool KeccakFPropagation::isChiCompatible | ( | const vector< SliceValue > & | beforeChi, |
const vector< SliceValue > & | afterChi | ||
) | const |
This method returns true iff the given state before χ is compatible with the given state after χ.
beforeChi | The state value at the input of χ. |
afterChi | The state value at the output of χ. |
bool KeccakFPropagation::isChiCompatible | ( | const RowValue & | beforeChi, |
const RowValue & | afterChi | ||
) | const [inline] |
This method returns true iff the input row pattern is compatible with the output row pattern.
beforeChi | The row value at the input of χ. |
afterChi | The row value at the output of χ. |
This method returns true iff two trails can be chained, i.e., if last state of the first trail is compatible through χ and λ with the first state of the second trail.
first | The first trail. |
second | The second trail. |
bool KeccakFPropagation::isThetaJustAfterChi | ( | ) | const |
This method returns true iff θ (or θt) is the first step of the linear step between two χ's.
void KeccakFPropagation::reverseLambda | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies λ in the "reverse" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::reverseLambdaAfterTheta | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies the part of λ after θ in the "reverse" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::reverseLambdaBeforeTheta | ( | const vector< SliceValue > & | in, |
vector< SliceValue > & | out | ||
) | const |
This method applies the part of λ before θ in the "reverse" direction:
in | The input state value given as a vector of slices. |
out | The output state value returned as a vector of slices. |
void KeccakFPropagation::reversePi | ( | unsigned int & | dx, |
unsigned int & | dy | ||
) | const |
This method multiplies the vector (dx, dy)t by the matrix π or π-1 to the left:
This attribute contains the same as directRowOutputListPerInput but in the form of an affine space representation.
The output row patterns:
The λ mode contains the lambdaMode attribute to pass to KeccakFDCLC to compute the linear part in the "direct" direction.
unsigned int KeccakFPropagation::laneSize |
This attribute contains the lane size (a copy of parent.laneSize).
const string KeccakFPropagation::name |
This attribute contains a string to help build appropriate file names: "DC" or "LC".
This is a link to the 'parent' KeccakFDCLC class.
The λ mode contains the lambdaMode attribute to pass to KeccakFDCLC to compute the linear part in the "reverse" direction.
The output row patterns in the reverse direction: