Skip to content

Commit

Permalink
crypto: sha - split sha.h into sha1.h and sha2.h
Browse files Browse the repository at this point in the history
Currently <crypto/sha.h> contains declarations for both SHA-1 and SHA-2,
and <crypto/sha3.h> contains declarations for SHA-3.

This organization is inconsistent, but more importantly SHA-1 is no
longer considered to be cryptographically secure.  So to the extent
possible, SHA-1 shouldn't be grouped together with any of the other SHA
versions, and usage of it should be phased out.

Therefore, split <crypto/sha.h> into two headers <crypto/sha1.h> and
<crypto/sha2.h>, and make everyone explicitly specify whether they want
the declarations for SHA-1, SHA-2, or both.

This avoids making the SHA-1 declarations visible to files that don't
want anything to do with SHA-1.  It also prepares for potentially moving
sha1.h into a new insecure/ or dangerous/ directory.

Signed-off-by: Eric Biggers <[email protected]>
Acked-by: Ard Biesheuvel <[email protected]>
Acked-by: Jason A. Donenfeld <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed Nov 20, 2020
1 parent 5bdad82 commit a24d22b
Show file tree
Hide file tree
Showing 120 changed files with 205 additions and 155 deletions.
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha1-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define ASM_ARM_CRYPTO_SHA1_H

#include <linux/crypto.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>

extern int sha1_update_arm(struct shash_desc *desc, const u8 *data,
unsigned int len);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha1_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <asm/byteorder.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha1_neon_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <asm/neon.h>
#include <asm/simd.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha2-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha256_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <asm/simd.h>
#include <asm/neon.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha256_neon_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <crypto/internal/simd.h>
#include <linux/types.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <asm/byteorder.h>
#include <asm/simd.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha512-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <linux/crypto.h>
#include <linux/module.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha512-neon-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <linux/crypto.h>
#include <linux/module.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/aes-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <asm/simd.h>
#include <crypto/aes.h>
#include <crypto/ctr.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/internal/skcipher.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/sha1-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <asm/unaligned.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/sha2-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <asm/unaligned.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/sha256-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <asm/simd.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <linux/types.h>
#include <linux/string.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/sha512-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <asm/unaligned.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/simd.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/sha512-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <crypto/internal/hash.h>
#include <linux/types.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <asm/neon.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/cavium-octeon/crypto/octeon-sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include <linux/mm.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/module.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/cavium-octeon/crypto/octeon-sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#include <linux/mm.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/module.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/cavium-octeon/crypto/octeon-sha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include <linux/mm.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/module.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/crypto/sha1-spe-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <asm/byteorder.h>
#include <asm/switch_to.h>
#include <linux/hardirq.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/crypto/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <asm/byteorder.h>

void powerpc_sha_transform(u32 *state, const u8 *src);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/crypto/sha256-spe-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <asm/byteorder.h>
#include <asm/switch_to.h>
#include <linux/hardirq.h>
Expand Down
3 changes: 2 additions & 1 deletion arch/s390/crypto/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#define _CRYPTO_ARCH_S390_SHA_H

#include <linux/crypto.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/sha3.h>

/* must be big enough for the largest SHA variant */
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/crypto/sha1_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <asm/cpacf.h>

#include "sha.h"
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/crypto/sha256_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <asm/cpacf.h>

#include "sha.h"
Expand Down
1 change: 0 additions & 1 deletion arch/s390/crypto/sha3_256_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <crypto/sha.h>
#include <crypto/sha3.h>
#include <asm/cpacf.h>

Expand Down
1 change: 0 additions & 1 deletion arch/s390/crypto/sha3_512_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/cpufeature.h>
#include <crypto/sha.h>
#include <crypto/sha3.h>
#include <asm/cpacf.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/s390/crypto/sha512_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Author(s): Jan Glauber ([email protected])
*/
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/purgatory/purgatory.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <linux/kexec.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <asm/purgatory.h>

int verify_sha256_digest(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/crypto/sha1_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>

#include <asm/pstate.h>
#include <asm/elf.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/crypto/sha256_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>

#include <asm/pstate.h>
#include <asm/elf.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/crypto/sha512_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>

#include <asm/pstate.h>
#include <asm/elf.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/crypto/sha1_ssse3_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <asm/simd.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/crypto/sha256_ssse3_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <linux/string.h>
#include <asm/simd.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/crypto/sha512_ssse3_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <asm/simd.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/purgatory/purgatory.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

#include <linux/bug.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <asm/purgatory.h>

#include "../boot/string.h"
Expand Down
2 changes: 1 addition & 1 deletion crypto/asymmetric_keys/asym_tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <linux/tpm_command.h>
#include <crypto/akcipher.h>
#include <crypto/hash.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <asm/unaligned.h>
#include <keys/asymmetric-subtype.h>
#include <keys/trusted_tpm.h>
Expand Down
2 changes: 1 addition & 1 deletion crypto/sha1_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha1_base.h>
#include <asm/byteorder.h>

Expand Down
2 changes: 1 addition & 1 deletion crypto/sha256_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha256_base.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
Expand Down
2 changes: 1 addition & 1 deletion crypto/sha512_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <linux/init.h>
#include <linux/crypto.h>
#include <linux/types.h>
#include <crypto/sha.h>
#include <crypto/sha2.h>
#include <crypto/sha512_base.h>
#include <linux/percpu.h>
#include <asm/byteorder.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
#include <linux/completion.h>
#include <linux/uuid.h>
#include <crypto/chacha.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>

#include <asm/processor.h>
#include <linux/uaccess.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <linux/pm_runtime.h>
#include <crypto/md5.h>
#include <crypto/skcipher.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/hash.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/skcipher.h>
Expand Down
3 changes: 2 additions & 1 deletion drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <linux/pm_runtime.h>
#include <linux/scatterlist.h>
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/md5.h>
#include "sun8i-ce.h"

Expand Down
3 changes: 2 additions & 1 deletion drivers/crypto/allwinner/sun8i-ce/sun8i-ce.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include <crypto/internal/hash.h>
#include <crypto/md5.h>
#include <crypto/rng.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>

/* CE Registers */
#define CE_TDQ 0x00
Expand Down
3 changes: 2 additions & 1 deletion drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <linux/pm_runtime.h>
#include <linux/scatterlist.h>
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/md5.h>
#include "sun8i-ss.h"

Expand Down
Loading

0 comments on commit a24d22b

Please sign in to comment.