diff options
author | Christian Beier <dontmind@freeshell.org> | 2015-02-05 14:11:46 +0100 |
---|---|---|
committer | Christian Beier <dontmind@freeshell.org> | 2015-02-05 14:11:46 +0100 |
commit | 069f8a284622867cee86aa4c1639df110a315f04 (patch) | |
tree | 25fce6a4b0310cd2dcfe5cc189885b1235e449c4 /common/sha-private.h | |
parent | cf03f71780ace5db61f194bbe6c832f32fbc10f8 (diff) | |
parent | 99bd5d7ca48dec0a4c1aca4cdbe7b5fb2bea2bbf (diff) | |
download | libtdevnc-069f8a284622867cee86aa4c1639df110a315f04.tar.gz libtdevnc-069f8a284622867cee86aa4c1639df110a315f04.zip |
Merge pull request #63 from LibVNC/sha1rework
Replace SHA1 implementation with the one from RFC 6234.
Diffstat (limited to 'common/sha-private.h')
-rw-r--r-- | common/sha-private.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/sha-private.h b/common/sha-private.h new file mode 100644 index 0000000..9ccc8dd --- /dev/null +++ b/common/sha-private.h @@ -0,0 +1,29 @@ +/************************ sha-private.h ************************/ +/***************** See RFC 6234 for details. *******************/ +#ifndef _SHA_PRIVATE__H +#define _SHA_PRIVATE__H +/* + * These definitions are defined in FIPS 180-3, section 4.1. + * Ch() and Maj() are defined identically in sections 4.1.1, + * 4.1.2, and 4.1.3. + * + * The definitions used in FIPS 180-3 are as follows: + */ + +#ifndef USE_MODIFIED_MACROS +#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) +#else /* USE_MODIFIED_MACROS */ +/* + * The following definitions are equivalent and potentially faster. + */ + +#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) +#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) + +#endif /* USE_MODIFIED_MACROS */ + +#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) + +#endif /* _SHA_PRIVATE__H */ + |