Reverser functions

Classes

struct  nil::crypto3::detail::bit_in_unit_byte_reverser< UnitBits, k >
 bit_in_unit_byte_reverser transforms the sequence of bits in each byte of the input unit into reversed sequence of bits in each byte of the output unit. The function reverse is recursively invoked and the parameter k is used to track the number of already processed input bytes. The recursion ends, when all input bytes have been processed, i.e. when k == UnitBits. More...
 
struct  nil::crypto3::detail::bit_in_unit_reverser< InputBits, UnitBits, k >
 bit_in_unit_reverser transforms the sequence of bits in each unit of the input value into reversed sequence of bytes in each unit of the output value. The function reverse is recursively invoked and the parameter k is used to track the number of already processed input units. The recursion ends, when all input units have been processed, i.e. when k == InputBits. More...
 
struct  nil::crypto3::detail::bit_reverser< InputEndianness, OutputEndianness, UnitBits, IsSameBit >
 bit_reverser reverses the sequence of bits in each unit of the given value, if InputEndianness and OutputEndianness endiannesses have different bit orders, and does nothing, otherwise. More...
 
struct  nil::crypto3::detail::bit_reverser< InputEndianness, OutputEndianness, UnitBits, false >
 This bit_reverser deals with the case of the endiannesses with different order of bits and invokes bit_in_unit_reverser which reverses bits in each unit of the input value. More...
 
struct  nil::crypto3::detail::bit_reverser< InputEndianness, OutputEndianness, UnitBits, true >
 This bit_reverser is a dummy and deals with the case of the endiannesses with the same order of bits. More...
 
struct  nil::crypto3::detail::byte_in_unit_reverser< InputBits, UnitBits, k >
 byte_in_unit_reverser transforms the sequence of bytes in each unit of the input value into reversed sequence of bytes in each unit of the output value. The function reverse is recursively invoked and the parameter k is used to track the number of already processed input units. The recursion ends, when all input units have been processed, i.e. when k == InputBits. More...
 
struct  nil::crypto3::detail::is_big_bit< Endianness, UnitBits >
 The group of traits below is used to determine the order of bits defined by the endianness. More...
 
struct  nil::crypto3::detail::is_big_unit< Endianness, UnitBits >
 The group of traits below is used to determine the order of units defined by the endianness. More...
 
struct  nil::crypto3::detail::is_little_bit< Endianness, UnitBits >
 Trait to determine whether the order of bits defined by Endianness endianness is little. More...
 
struct  nil::crypto3::detail::is_little_unit< Endianness, UnitBits >
 Trait to determine whether the order of units defined by Endianness endianness is little. More...
 
struct  nil::crypto3::detail::is_same_bit< Endianness1, Endianness2, UnitBits >
 Trait to determine whether the orders of bits defined by Endianness1 endianness and Endianness2 endianness are the same. More...
 
struct  nil::crypto3::detail::is_same_unit< Endianness1, Endianness2, UnitBits >
 Trait to determine whether the orders of units defined by Endianness1 endianness and Endianness2 endianness are the same. More...
 
struct  nil::crypto3::detail::unit_reverser< InputEndianness, OutputEndianness, UnitBits, Enable >
 unit_reverser reverses the sequence of units in the given value, if InputEndianness and OutputEndianness endiannesses have different unit orders, and does nothing, otherwise. More...
 
struct  nil::crypto3::detail::unit_reverser< InputEndianness, OutputEndianness, UnitBits, typename std::enable_if< is_same_unit< InputEndianness, OutputEndianness, UnitBits >::value >::type >
 This unit_reverser is a dummy and deals with the case of the endiannesses with the same order of units. More...
 
struct  nil::crypto3::detail::unit_reverser< InputEndianness, OutputEndianness, UnitBits, typename std::enable_if<!is_same_unit< InputEndianness, OutputEndianness, UnitBits >::value &&(UnitBits > CHAR_BIT)>::type >
 This unit_reverser deals with the case of UnitBits > CHAR_BIT. To reverse the order of units, first, it reverses the byte order in an input value, and then, it invokes byte_in_unit_reverser to reverse the byte order in each unit of the input value. More...
 
struct  nil::crypto3::detail::unit_reverser< InputEndianness, OutputEndianness, UnitBits, typename std::enable_if<!is_same_unit< InputEndianness, OutputEndianness, UnitBits >::value &&UnitBits==CHAR_BIT >::type >
 This unit_reverser deals with the case of UnitBits == CHAR_BIT. This case is special since it is sufficient to reverse the order of bytes in an input value. More...
 

Functions

template<typename UnitType , int UnitBits = sizeof(UnitType) * CHAR_BIT, typename std::enable_if<(UnitBits > CHAR_BIT), int >::type = 0>
void nil::crypto3::detail::reverse_bits (UnitType &unit)
 The functions listed below deal with bit reversal in a unit. More...
 
void nil::crypto3::detail::reverse_byte (byte_type &b)
 This function reverses bit order in the byte b depending on the machine word size. The underlying algorithms used in this function are described in http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits and in http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv . More...
 

Detailed Description

Function Documentation

◆ reverse_bits()

template<typename UnitType , int UnitBits = sizeof(UnitType) * CHAR_BIT, typename std::enable_if<(UnitBits > CHAR_BIT), int >::type = 0>
void nil::crypto3::detail::reverse_bits ( UnitType &  unit)
inline

The functions listed below deal with bit reversal in a unit.

This function deals with the special case of UnitBits == CHAR_BIT, it just reverses the bit order in the byte.

This function deals with the case of UnitBits > CHAR_BIT. To reverse the order of bits, first, it reverses the byte order of unit, and then, it invokes bit_in_unit_byte_reverser to reverse bits in each byte of unit.

Template Parameters
UnitType
UnitBits
Parameters
unit
Returns
Template Parameters
UnitType
UnitBits
Parameters
unit
Returns

◆ reverse_byte()

void nil::crypto3::detail::reverse_byte ( byte_type b)
inline

This function reverses bit order in the byte b depending on the machine word size. The underlying algorithms used in this function are described in http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits and in http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv .

Parameters
b
Returns