david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[crypto] Use standard bit-rotation functions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2012-03-21 14:13:15 +00:00
parent cf78afa5c5
commit c76afb3605
4 changed files with 11 additions and 37 deletions

View File

@ -28,20 +28,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
#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,

View File

@ -28,20 +28,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
#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,

View File

@ -28,20 +28,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
#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,

View File

@ -10,19 +10,23 @@ FILE_LICENCE ( GPL2_OR_LATER );
#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 ) ) );
}