Rot

Files CCore/inc/crypton/Rot.h CCore/src/crypton/Rot.cpp

This is a set of rotation functions.


/* Ror...() */ 

template <class UInt,unsigned UIntBits>
UInt Ror_gen(UInt a,unsigned n); // 0 < n < UIntBits 
 
uint8 Ror8(uint8 a,unsigned n);
 
uint16 Ror16(uint16 a,unsigned n);
 
uint32 Ror32(uint32 a,unsigned n);
 
uint64 Ror64(uint64 a,unsigned n);

/* Rol...() */

template <class UInt,unsigned UIntBits>
UInt Rol_gen(UInt a,unsigned n); // 0 < n < UIntBits
 
uint8 Rol8(uint8 a,unsigned n);
 
uint16 Rol16(uint16 a,unsigned n);
 
uint32 Rol32(uint32 a,unsigned n);

uint64 Rol64(uint64 a,unsigned n);

RorN() performs the right rotation of the N-bit argument by the given number of bits. The number of bits is given by the second argument. This value must be greater than 0 and less than N.

RolN() performs the left rotation of the N-bit argument by the given number of bits. The number of bits is given by the second argument. This value must be greater than 0 and less than N.

Ror_gen() is a generic right rotation function. The first argument is an unsigned integral value. The second is the number of bits to rotate by. It must be greater than 0 and less than UIntBits. The second template parameter must be the number of bits of the type UInt.

Rol_gen() is a generic left rotation function. The first argument is an unsigned integral value. The second is the number of bits to rotate by. It must be greater than 0 and less than UIntBits. The second template parameter must be the number of bits of the type UInt.