-uint8_t *SwapEndian64(uint8_t *src, size_t len){
- static uint8_t temp[64]={0};
- for (uint8_t block=0; block < (uint8_t)len/8; block++){
- for (size_t i = 0; i < 8; i++){
- temp[i+(8*block)] = src[(7-i)+(8*block)];
+uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize){
+ static uint8_t buf[64];
+ memset(buf, 0x00, 64);
+ uint8_t *tmp = buf;
+ for (uint8_t block=0; block < (uint8_t)(len/blockSize); block++){
+ for (size_t i = 0; i < blockSize; i++){
+ tmp[i+(blockSize*block)] = src[(blockSize-1-i)+(blockSize*block)];
+ }
+ }
+ return tmp;
+}
+
+// takes a uint8_t src array, for len items and reverses the byte order in blocksizes (8,16,32,64),
+// returns: the dest array contains the reordered src array.
+void SwapEndian64ex(const uint8_t *src, const size_t len, const uint8_t blockSize, uint8_t *dest){
+ for (uint8_t block=0; block < (uint8_t)(len/blockSize); block++){
+ for (size_t i = 0; i < blockSize; i++){
+ dest[i+(blockSize*block)] = src[(blockSize-1-i)+(blockSize*block)];