#include <string.h>
#include <byteswap.h>
#include <assert.h>
+#include <ipxe/rotate.h>
#include <ipxe/crypto.h>
#include <ipxe/md5.h>
-/**
- * Rotate dword left
- *
- * @v dword Dword
- * @v rotate Amount of rotation
- */
-static inline __attribute__ (( always_inline )) uint32_t
-rol32 ( uint32_t dword, unsigned int rotate ) {
- return ( ( dword << rotate ) | ( dword >> ( 32 - rotate ) ) );
-}
-
/** MD5 variables */
struct md5_variables {
/* This layout matches that of struct md5_digest_data,
#include <string.h>
#include <byteswap.h>
#include <assert.h>
+#include <ipxe/rotate.h>
#include <ipxe/crypto.h>
#include <ipxe/sha1.h>
-/**
- * Rotate dword left
- *
- * @v dword Dword
- * @v rotate Amount of rotation
- */
-static inline __attribute__ (( always_inline )) uint32_t
-rol32 ( uint32_t dword, unsigned int rotate ) {
- return ( ( dword << rotate ) | ( dword >> ( 32 - rotate ) ) );
-}
-
/** SHA-1 variables */
struct sha1_variables {
/* This layout matches that of struct sha1_digest_data,
#include <string.h>
#include <byteswap.h>
#include <assert.h>
+#include <ipxe/rotate.h>
#include <ipxe/crypto.h>
#include <ipxe/sha256.h>
-/**
- * Rotate dword right
- *
- * @v dword Dword
- * @v rotate Amount of rotation
- */
-static inline __attribute__ (( always_inline )) uint32_t
-ror32 ( uint32_t dword, unsigned int rotate ) {
- return ( ( dword >> rotate ) | ( dword << ( 32 - rotate ) ) );
-}
-
/** SHA-256 variables */
struct sha256_variables {
/* This layout matches that of struct sha256_digest_data,
#include <stdint.h>
-static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) {
+static inline __attribute__ (( always_inline )) uint32_t
+rol32 ( uint32_t data, unsigned int rotation ) {
return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
}
-static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) {
+static inline __attribute__ (( always_inline )) uint32_t
+ror32 ( uint32_t data, unsigned int rotation ) {
return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
}
-static inline uint64_t rol64 ( uint64_t data, unsigned int rotation ) {
+static inline __attribute__ (( always_inline )) uint64_t
+rol64 ( uint64_t data, unsigned int rotation ) {
return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) );
}
-static inline uint64_t ror64 ( uint64_t data, unsigned int rotation ) {
+static inline __attribute__ (( always_inline )) uint64_t
+ror64 ( uint64_t data, unsigned int rotation ) {
return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) );
}