CRYPTO-C v1.1.3
C/C++ Documentation
utildev.h File Reference

Go to the source code of this file.

#include <stddef.h>
#include <stdint.h>

Detailed Description

Device utilities and includes support.

Provides utilities and includes for device architectures.

Architecture Supported
CPU Yes
CUDA Yes
OPENCL No

Macros

#define bswap32(x)    ( (rol32(x, 24) & 0xFF00FF00) | (rol32(x, 8) & 0x00FF00FF) )
 Swap the byte order of a 32-bit word. More...
 
#define rol32(x, n)   ( ((x) << (n)) | ((x) >> (32 - (n))) )
 Rotate a 32-bit word left by n bits. More...
 
#define rol64(x, n)   ( ((x) << (n)) | ((x) >> (64 - (n))) )
 Rotate a 64-bit word left by n bits. More...
 
#define ror32(x, n)   ( ((x) >> (n)) | ((x) << (32 - (n))) )
 Rotate a 32-bit word right by n bits. More...
 
#define ror64(x, n)   ( ((x) >> (n)) | ((x) << (64 - (n))) )
 Rotate a 64-bit word right by n bits. More...
 
#define xandx(a, b, c)   ( ((a) & ((b) ^ (c))) ^ (c) )
 Perform an XANDX operation. More...
 
#define xor3(a, b, c)   ( (a) ^ (b) ^ (c) )
 XOR 3 values together. More...
 
#define xor4(a, b, c, d)   ( (a) ^ (b) ^ (c) ^ (d) )
 XOR 4 values together. More...
 

Macro Definition Documentation

◆ bswap32

#define bswap32 (   x)     ( (rol32(x, 24) & 0xFF00FF00) | (rol32(x, 8) & 0x00FF00FF) )

Swap the byte order of a 32-bit word.

Alternate expansion for nvcc: __byte_perm(x, 0, 0x0123)

Parameters
x32-bit word to be swapped
Returns
32-bit word with swapped byte ordering.

◆ rol32

#define rol32 (   x,
 
)    ( ((x) << (n)) | ((x) >> (32 - (n))) )

Rotate a 32-bit word left by n bits.

Parameters
x32-bit word to rotate
nNumber of bits to rotate left by
Returns
32-bit word rotated left by n bits.

◆ rol64

#define rol64 (   x,
 
)    ( ((x) << (n)) | ((x) >> (64 - (n))) )

Rotate a 64-bit word left by n bits.

Parameters
x64-bit word to rotate
nNumber of bits to rotate left by
Returns
64-bit word rotated left by n bits.

◆ ror32

#define ror32 (   x,
 
)    ( ((x) >> (n)) | ((x) << (32 - (n))) )

Rotate a 32-bit word right by n bits.

Parameters
x32-bit word to rotate
nNumber of bits to rotate right by
Returns
32-bit word rotated right by n bits.

◆ ror64

#define ror64 (   x,
 
)    ( ((x) >> (n)) | ((x) << (64 - (n))) )

Rotate a 64-bit word right by n bits.

Parameters
x64-bit word to rotate
nNumber of bits to rotate right by
Returns
64-bit word rotated right by n bits.

◆ xandx

#define xandx (   a,
  b,
 
)    ( ((a) & ((b) ^ (c))) ^ (c) )

Perform an XANDX operation.

An XANDX operation is composed of a XOR, an AND and another XOR in the form:

( (((a) & ((b) ^ (c))) ^ (c) )
Parameters
afirst parameter
bsecond parameter
cthird parameter
Returns
result of XANDX operation.

◆ xor3

#define xor3 (   a,
  b,
 
)    ( (a) ^ (b) ^ (c) )

XOR 3 values together.

Performs 2x XOR operations.

Parameters
afirst parameter
bsecond parameter
cthird parameter
Returns
result of 2x XOR operations.

◆ xor4

#define xor4 (   a,
  b,
  c,
 
)    ( (a) ^ (b) ^ (c) ^ (d) )

XOR 4 values together.

Performs 3x XOR operations.

Parameters
afirst parameter
bsecond parameter
cthird parameter
dfourth parameter
Returns
result of 3x XOR operations.