diff options
author | David Sterba <dsterba@suse.com> | 2017-03-14 19:30:47 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-03-16 17:02:44 +0100 |
commit | 4ddd6055c333932b561046ad1d41234d773246d2 (patch) | |
tree | 45a829b666959aab5878870e670735c99ea804f6 /tests/sha-private.h | |
parent | 1d684ec0e0c3663a140e362f5c7397134c4030f7 (diff) |
btrfs-progs: tests: add SHA256
In order to drop dependency on SSL library to compute MD5 in fssum,
we'll use the reference implementation from RFC 6234.
The checksum is not in a cryptographically sensitive context, but we're
going to skip MD5 and SHA-1 anyway.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests/sha-private.h')
-rw-r--r-- | tests/sha-private.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/sha-private.h b/tests/sha-private.h new file mode 100644 index 00000000..6e9c4520 --- /dev/null +++ b/tests/sha-private.h @@ -0,0 +1,28 @@ +/************************ 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 */ |