Crypto++
7.0
Free C++ class library of cryptographic schemes
|
Support functions for PowerPC and vector operations. More...
Go to the source code of this file.
Typedefs | |
typedef __vector unsigned char | uint8x16_p |
typedef __vector unsigned short | uint16x8_p |
typedef __vector unsigned int | uint32x4_p |
Functions | |
void | ReverseByteArrayLE (byte src[16]) |
Reverse a 16-byte array. More... | |
template<class T > | |
T | Reverse (const T &src) |
Reverse a vector. More... | |
uint32x4_p | VectorLoadBE (const uint8_t src[16]) |
Loads a vector from a byte array. More... | |
uint32x4_p | VectorLoadBE (int off, const uint8_t src[16]) |
Loads a vector from a byte array. More... | |
uint32x4_p | VectorLoad (const byte src[16]) |
Loads a vector from a byte array. More... | |
uint32x4_p | VectorLoad (int off, const byte src[16]) |
Loads a vector from a byte array. More... | |
uint32x4_p | VectorLoadKey (const byte src[16]) |
Loads a vector from a byte array. More... | |
uint32x4_p | VectorLoadKey (const word32 src[4]) |
Loads a vector from a 32-bit word array. More... | |
uint32x4_p | VectorLoadKey (int off, const byte src[16]) |
Loads a vector from a byte array. More... | |
template<class T > | |
void | VectorStoreBE (const T &src, uint8_t dest[16]) |
Stores a vector to a byte array. More... | |
template<class T > | |
void | VectorStoreBE (const T &src, int off, uint8_t dest[16]) |
Stores a vector to a byte array. More... | |
template<class T > | |
void | VectorStore (const T &src, byte dest[16]) |
Stores a vector to a byte array. More... | |
template<class T > | |
void | VectorStore (const T &src, int off, byte dest[16]) |
Stores a vector to a byte array. More... | |
template<class T1 , class T2 > | |
T1 | VectorPermute (const T1 &vec1, const T1 &vec2, const T2 &mask) |
Permutes two vectors. More... | |
template<class T1 , class T2 > | |
T1 | VectorXor (const T1 &vec1, const T2 &vec2) |
XOR two vectors. More... | |
template<class T1 , class T2 > | |
T1 | VectorAdd (const T1 &vec1, const T2 &vec2) |
Add two vector. More... | |
template<unsigned int C, class T1 , class T2 > | |
T1 | VectorShiftLeft (const T1 &vec1, const T2 &vec2) |
Shift two vectors left. More... | |
template<class T1 , class T2 > | |
T1 | VectorEncrypt (const T1 &state, const T2 &key) |
One round of AES encryption. More... | |
template<class T1 , class T2 > | |
T1 | VectorEncryptLast (const T1 &state, const T2 &key) |
Final round of AES encryption. More... | |
template<class T1 , class T2 > | |
T1 | VectorDecrypt (const T1 &state, const T2 &key) |
One round of AES decryption. More... | |
template<class T1 , class T2 > | |
T1 | VectorDecryptLast (const T1 &state, const T2 &key) |
Final round of AES decryption. More... | |
template<int func, int subfunc, class T > | |
T | VectorSHA256 (const T &vec) |
SHA256 Sigma functions. More... | |
template<int func, int subfunc, class T > | |
T | VectorSHA512 (const T &vec) |
SHA512 Sigma functions. More... | |
Support functions for PowerPC and vector operations.
This header provides an agnostic interface into GCC and IBM XL C/C++ compilers modulo their different built-in functions for accessing vector intructions.
The abstractions are necesssary to support back to GCC 4.8. GCC 4.8 and 4.9 are still popular, and they are the default compiler for GCC112, GCC118 and others on the compile farm. Older IBM XL C/C++ compilers also experience it due to lack of vec_xl_be
support on some platforms. Modern compilers provide best support and don't need many of the little hacks below.
Definition in file ppc-simd.h.
|
inline |
Reverse a 16-byte array.
src | the byte array |
ReverseByteArrayLE reverses a 16-byte array on a little endian system. It does nothing on a big endian system.
Definition at line 116 of file ppc-simd.h.
|
inline |
Reverse a vector.
T | vector type |
src | the vector |
Reverse() endian swaps the bytes in a vector
Definition at line 134 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
Loads a vector in big endian format from a byte array. VectorLoadBE will swap endianess on little endian systems.
Definition at line 147 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
off | offset into the src byte array |
Loads a vector in big endian format from a byte array. VectorLoadBE will swap endianess on little endian systems.
Definition at line 168 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
Loads a vector in big endian format from a byte array. VectorLoad will swap endianess on little endian systems.
Definition at line 188 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
off | offset into the src byte array |
Loads a vector in big endian format from a byte array. VectorLoad will swap endianess on little endian systems.
Definition at line 201 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
Loads a vector from a byte array. VectorLoadKey does not swap endianess on little endian systems.
Definition at line 213 of file ppc-simd.h.
|
inline |
Loads a vector from a 32-bit word array.
src | the 32-bit word array |
Loads a vector from a 32-bit word array. VectorLoadKey does not swap endianess on little endian systems.
Definition at line 229 of file ppc-simd.h.
|
inline |
Loads a vector from a byte array.
src | the byte array |
off | offset into the src byte array |
Loads a vector from a byte array. VectorLoadKey does not swap endianess on little endian systems.
Definition at line 246 of file ppc-simd.h.
|
inline |
Stores a vector to a byte array.
T | vector type |
src | the vector |
dest | the byte array |
Stores a vector in big endian format to a byte array. VectorStoreBE will swap endianess on little endian systems.
Definition at line 265 of file ppc-simd.h.
|
inline |
Stores a vector to a byte array.
T | vector type |
src | the vector |
off | offset into the dest byte array |
dest | the byte array |
Stores a vector in big endian format to a byte array. VectorStoreBE will swap endianess on little endian systems.
Definition at line 288 of file ppc-simd.h.
|
inline |
Stores a vector to a byte array.
T | vector type |
src | the vector |
dest | the byte array |
Stores a vector in big endian format to a byte array. VectorStore will swap endianess on little endian systems.
Definition at line 310 of file ppc-simd.h.
|
inline |
Stores a vector to a byte array.
T | vector type |
src | the vector |
off | offset into the dest byte array |
dest | the byte array |
Stores a vector in big endian format to a byte array. VectorStore will swap endianess on little endian systems.
Definition at line 334 of file ppc-simd.h.
|
inline |
Permutes two vectors.
T1 | vector type |
T2 | vector type |
vec1 | the first vector |
vec2 | the second vector |
mask | vector mask |
VectorPermute returns a new vector from vec1 and vec2 based on mask. mask is an uint8x16_p type vector. The return vector is the same type as vec1.
Definition at line 359 of file ppc-simd.h.
|
inline |
XOR two vectors.
T1 | vector type |
T2 | vector type |
vec1 | the first vector |
vec2 | the second vector |
VectorXor returns a new vector from vec1 and vec2. The return vector is the same type as vec1.
Definition at line 373 of file ppc-simd.h.
|
inline |
Add two vector.
T1 | vector type |
T2 | vector type |
vec1 | the first vector |
vec2 | the second vector |
VectorAdd returns a new vector from vec1 and vec2. vec2 is cast to the same type as vec1. The return vector is the same type as vec1.
Definition at line 388 of file ppc-simd.h.
|
inline |
Shift two vectors left.
C | shift byte count |
T1 | vector type |
T2 | vector type |
vec1 | the first vector |
vec2 | the second vector |
VectorShiftLeft() concatenates vec1 and vec2 and returns a new vector after shifting the concatenation by the specified number of bytes. Both vec1 and vec2 are cast to uint8x16_p. The return vector is the same type as vec1.
On big endian machines VectorShiftLeft() is vec_sld(a, b, c)
. On little endian machines VectorShiftLeft() is translated to vec_sld(b, a, 16-c)
. You should always call the function as if on a big endian machine as shown below.
uint8x16_p r0 = {0}; uint8x16_p r1 = VectorLoad(ptr); uint8x16_p r5 = VectorShiftLeft<12>(r0, r1);
Definition at line 416 of file ppc-simd.h.
|
inline |
One round of AES encryption.
T1 | vector type |
T2 | vector type |
state | the state vector |
key | the subkey vector |
VectorEncrypt performs one round of AES encryption of state using subkey key. The return vector is the same type as vec1.
Definition at line 438 of file ppc-simd.h.
|
inline |
Final round of AES encryption.
T1 | vector type |
T2 | vector type |
state | the state vector |
key | the subkey vector |
VectorEncryptLast performs the final round of AES encryption of state using subkey key. The return vector is the same type as vec1.
Definition at line 458 of file ppc-simd.h.
|
inline |
One round of AES decryption.
T1 | vector type |
T2 | vector type |
state | the state vector |
key | the subkey vector |
VectorDecrypt performs one round of AES decryption of state using subkey key. The return vector is the same type as vec1.
Definition at line 478 of file ppc-simd.h.
|
inline |
Final round of AES decryption.
T1 | vector type |
T2 | vector type |
state | the state vector |
key | the subkey vector |
VectorDecryptLast performs the final round of AES decryption of state using subkey key. The return vector is the same type as vec1.
Definition at line 498 of file ppc-simd.h.
|
inline |
SHA256 Sigma functions.
func | function |
subfunc | sub-function |
T | vector type |
vec | the block to transform |
VectorSHA256 selects sigma0, sigma1, Sigma0, Sigma1 based on func and subfunc. The return vector is the same type as vec.
Definition at line 518 of file ppc-simd.h.
|
inline |
SHA512 Sigma functions.
func | function |
subfunc | sub-function |
T | vector type |
vec | the block to transform |
VectorSHA512 selects sigma0, sigma1, Sigma0, Sigma1 based on func and subfunc. The return vector is the same type as vec.
Definition at line 538 of file ppc-simd.h.