libmoost
/home/mhx/git/github/libmoost/src/digest/rfc6234/sha-private.h
Go to the documentation of this file.
00001 /************************ sha-private.h ************************/
00002 /***************** See RFC 6234 for details. *******************/
00003 #ifndef _SHA_PRIVATE__H
00004 #define _SHA_PRIVATE__H
00005 /*
00006  * These definitions are defined in FIPS 180-3, section 4.1.
00007  * Ch() and Maj() are defined identically in sections 4.1.1,
00008  * 4.1.2, and 4.1.3.
00009  *
00010  * The definitions used in FIPS 180-3 are as follows:
00011  */
00012 
00013 #ifndef USE_MODIFIED_MACROS
00014 #define SHA_Ch(x,y,z)        (((x) & (y)) ^ ((~(x)) & (z)))
00015 #define SHA_Maj(x,y,z)       (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
00016 #else /* USE_MODIFIED_MACROS */
00017 /*
00018  * The following definitions are equivalent and potentially faster.
00019  */
00020 
00021 #define SHA_Ch(x, y, z)      (((x) & ((y) ^ (z))) ^ (z))
00022 #define SHA_Maj(x, y, z)     (((x) & ((y) | (z))) | ((y) & (z)))
00023 
00024 #endif /* USE_MODIFIED_MACROS */
00025 
00026 #define SHA_Parity(x, y, z)  ((x) ^ (y) ^ (z))
00027 
00028 #endif /* _SHA_PRIVATE__H */