Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sha-private.h Source File

sha-private.h

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 /*************************** sha-private.h ***************************/
00005 /********************** See RFC 4634 for details *********************/
00006 #ifndef _SHA_PRIVATE__H
00007 #define _SHA_PRIVATE__H
00008 /*
00009 * These definitions are defined in FIPS-180-2, section 4.1.
00010 * Ch() and Maj() are defined identically in sections 4.1.1,
00011 * 4.1.2 and 4.1.3.
00012 *
00013 * The definitions used in FIPS-180-2 are as follows:
00014 */
00015 
00016 #ifndef USE_MODIFIED_MACROS
00017 #define SHA_Ch(x,y,z)        (((x) & (y)) ^ ((~(x)) & (z)))
00018 #define SHA_Maj(x,y,z)       (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
00019 
00020 #else /* USE_MODIFIED_MACROS */
00021 /*
00022 * The following definitions are equivalent and potentially faster.
00023 */
00024 
00025 #define SHA_Ch(x, y, z)      (((x) & ((y) ^ (z))) ^ (z))
00026 #define SHA_Maj(x, y, z)     (((x) & ((y) | (z))) | ((y) & (z)))
00027 
00028 #endif /* USE_MODIFIED_MACROS */
00029 
00030 #define SHA_Parity(x, y, z)  ((x) ^ (y) ^ (z))
00031 
00032 #endif /* _SHA_PRIVATE__H */
00033