cryptutils

Cryptographic Software Utilities
git clone http://git.omkov.net/cryptutils
Log | Tree | Refs | README | LICENCE | Download

cryptutils/src/util/crypt.h (32 lines, 907 B) -rw-r--r-- blame download

012345678910111213141516171819202122232425262728293031
// util/crypt.h, version 0.1.2
// Crypt header file from libutil
// Copyright (C) 2021, Jakob Wakeling
// MIT Licence

#ifndef UTIL_CRYPT_H_RDY6J5JV
#define UTIL_CRYPT_H_RDY6J5JV

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/* Circular shift left */
#define ROL8(x, n)   (uint8_t)(((x) << (n)) | ((x) >>  (8 - (n))))
#define ROL16(x, n) (uint16_t)(((x) << (n)) | ((x) >> (16 - (n))))
#define ROL32(x, n) (uint32_t)(((x) << (n)) | ((x) >> (32 - (n))))
#define ROL64(x, n) (uint64_t)(((x) << (n)) | ((x) >> (64 - (n))))

/* Circular shift right */
#define ROR8(x, n)   (uint8_t)(((x) >> (n)) | ((x) <<  (8 - (n))))
#define ROR16(x, n) (uint16_t)(((x) >> (n)) | ((x) << (16 - (n))))
#define ROR32(x, n) (uint32_t)(((x) >> (n)) | ((x) << (32 - (n))))
#define ROR64(x, n) (uint64_t)(((x) >> (n)) | ((x) << (64 - (n))))

#ifdef __cplusplus
} // extern "C"
#endif

#endif // UTIL_CRYPT_H_RDY6J5JV