crypto: add patch for 5.15
authorwilliam.qiu <william.qiu@starfivetech.com>
Wed, 27 Apr 2022 09:03:14 +0000 (17:03 +0800)
committerwilliam.qiu <william.qiu@starfivetech.com>
Thu, 28 Apr 2022 05:54:49 +0000 (13:54 +0800)
crypto need this patch to work.

Signed-off-by: william.qiu <william.qiu@starfivetech.com>
Documentation/crypto/api-kpp.rst
crypto/Kconfig
crypto/Makefile
drivers/crypto/Kconfig
include/crypto/kpp.h
include/crypto/sha.h [new file with mode: 0755]

index 7d86ab9..7b2c0d4 100644 (file)
@@ -11,7 +11,7 @@ Key-agreement Protocol Primitives (KPP) Cipher API
    :doc: Generic Key-agreement Protocol Primitives API
 
 .. kernel-doc:: include/crypto/kpp.h
-   :functions: crypto_alloc_kpp crypto_free_kpp crypto_kpp_set_secret crypto_kpp_generate_public_key crypto_kpp_compute_shared_secret crypto_kpp_maxsize
+   :functions: crypto_alloc_kpp crypto_free_kpp crypto_kpp_set_params crypto_kpp_set_secret crypto_kpp_generate_public_key crypto_kpp_compute_shared_secret crypto_kpp_maxsize
 
 Key-agreement Protocol Primitives (KPP) Cipher Request Handle
 -------------------------------------------------------------
index c8bc811..3f745df 100644 (file)
@@ -201,7 +201,7 @@ config CRYPTO_AUTHENC
 
 config CRYPTO_TEST
        tristate "Testing module"
-       depends on m || EXPERT
+       depends on m
        select CRYPTO_MANAGER
        help
          Quick & dirty crypto test module.
@@ -210,6 +210,11 @@ config CRYPTO_SIMD
        tristate
        select CRYPTO_CRYPTD
 
+config CRYPTO_GLUE_HELPER_X86
+       tristate
+       depends on X86
+       select CRYPTO_SKCIPHER
+
 config CRYPTO_ENGINE
        tristate
 
@@ -242,16 +247,6 @@ config CRYPTO_ECDH
        help
          Generic implementation of the ECDH algorithm
 
-config CRYPTO_ECDSA
-       tristate "ECDSA (NIST P192, P256 etc.) algorithm"
-       select CRYPTO_ECC
-       select CRYPTO_AKCIPHER
-       select ASN1
-       help
-         Elliptic Curve Digital Signature Algorithm (NIST P192, P256 etc.)
-         is A NIST cryptographic standard algorithm. Only signature verification
-         is implemented.
-
 config CRYPTO_ECRDSA
        tristate "EC-RDSA (GOST 34.10) algorithm"
        select CRYPTO_ECC
@@ -777,7 +772,7 @@ config CRYPTO_POLY1305_X86_64
 
 config CRYPTO_POLY1305_MIPS
        tristate "Poly1305 authenticator algorithm (MIPS optimized)"
-       depends on MIPS
+       depends on CPU_MIPS32 || (CPU_MIPS64 && 64BIT)
        select CRYPTO_ARCH_HAVE_LIB_POLY1305
 
 config CRYPTO_MD4
@@ -827,6 +822,19 @@ config CRYPTO_MICHAEL_MIC
          should not be used for other purposes because of the weakness
          of the algorithm.
 
+config CRYPTO_RMD128
+       tristate "RIPEMD-128 digest algorithm"
+       select CRYPTO_HASH
+       help
+         RIPEMD-128 (ISO/IEC 10118-3:2004).
+
+         RIPEMD-128 is a 128-bit cryptographic hash function. It should only
+         be used as a secure replacement for RIPEMD. For other use cases,
+         RIPEMD-160 should be used.
+
+         Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
+         See <https://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
+
 config CRYPTO_RMD160
        tristate "RIPEMD-160 digest algorithm"
        select CRYPTO_HASH
@@ -844,6 +852,30 @@ config CRYPTO_RMD160
          Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
          See <https://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
 
+config CRYPTO_RMD256
+       tristate "RIPEMD-256 digest algorithm"
+       select CRYPTO_HASH
+       help
+         RIPEMD-256 is an optional extension of RIPEMD-128 with a
+         256 bit hash. It is intended for applications that require
+         longer hash-results, without needing a larger security level
+         (than RIPEMD-128).
+
+         Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
+         See <https://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
+
+config CRYPTO_RMD320
+       tristate "RIPEMD-320 digest algorithm"
+       select CRYPTO_HASH
+       help
+         RIPEMD-320 is an optional extension of RIPEMD-160 with a
+         320 bit hash. It is intended for applications that require
+         longer hash-results, without needing a larger security level
+         (than RIPEMD-160).
+
+         Developed by Hans Dobbertin, Antoon Bosselaers and Bart Preneel.
+         See <https://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
+
 config CRYPTO_SHA1
        tristate "SHA1 digest algorithm"
        select CRYPTO_HASH
@@ -1019,6 +1051,19 @@ config CRYPTO_STREEBOG
          https://tc26.ru/upload/iblock/fed/feddbb4d26b685903faa2ba11aea43f6.pdf
          https://tools.ietf.org/html/rfc6986
 
+config CRYPTO_TGR192
+       tristate "Tiger digest algorithms"
+       select CRYPTO_HASH
+       help
+         Tiger hash algorithm 192, 160 and 128-bit hashes
+
+         Tiger is a hash function optimized for 64-bit processors while
+         still having decent performance on 32-bit processors.
+         Tiger was developed by Ross Anderson and Eli Biham.
+
+         See also:
+         <https://www.cs.technion.ac.il/~biham/Reports/Tiger/>.
+
 config CRYPTO_WP512
        tristate "Whirlpool digest algorithms"
        select CRYPTO_HASH
@@ -1088,6 +1133,7 @@ config CRYPTO_AES_NI_INTEL
        select CRYPTO_LIB_AES
        select CRYPTO_ALGAPI
        select CRYPTO_SKCIPHER
+       select CRYPTO_GLUE_HELPER_X86 if 64BIT
        select CRYPTO_SIMD
        help
          Use Intel AES-NI instructions for AES algorithm.
@@ -1210,7 +1256,6 @@ config CRYPTO_BLOWFISH_X86_64
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
        select CRYPTO_BLOWFISH_COMMON
-       imply CRYPTO_CTR
        help
          Blowfish cipher algorithm (x86_64), by Bruce Schneier.
 
@@ -1223,6 +1268,7 @@ config CRYPTO_BLOWFISH_X86_64
 
 config CRYPTO_CAMELLIA
        tristate "Camellia cipher algorithms"
+       depends on CRYPTO
        select CRYPTO_ALGAPI
        help
          Camellia cipher algorithms module.
@@ -1238,8 +1284,9 @@ config CRYPTO_CAMELLIA
 config CRYPTO_CAMELLIA_X86_64
        tristate "Camellia cipher algorithm (x86_64)"
        depends on X86 && 64BIT
+       depends on CRYPTO
        select CRYPTO_SKCIPHER
-       imply CRYPTO_CTR
+       select CRYPTO_GLUE_HELPER_X86
        help
          Camellia cipher algorithm module (x86_64).
 
@@ -1254,10 +1301,12 @@ config CRYPTO_CAMELLIA_X86_64
 config CRYPTO_CAMELLIA_AESNI_AVX_X86_64
        tristate "Camellia cipher algorithm (x86_64/AES-NI/AVX)"
        depends on X86 && 64BIT
+       depends on CRYPTO
        select CRYPTO_SKCIPHER
        select CRYPTO_CAMELLIA_X86_64
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SIMD
-       imply CRYPTO_XTS
+       select CRYPTO_XTS
        help
          Camellia cipher algorithm module (x86_64/AES-NI/AVX).
 
@@ -1272,6 +1321,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX_X86_64
 config CRYPTO_CAMELLIA_AESNI_AVX2_X86_64
        tristate "Camellia cipher algorithm (x86_64/AES-NI/AVX2)"
        depends on X86 && 64BIT
+       depends on CRYPTO
        select CRYPTO_CAMELLIA_AESNI_AVX_X86_64
        help
          Camellia cipher algorithm module (x86_64/AES-NI/AVX2).
@@ -1287,6 +1337,7 @@ config CRYPTO_CAMELLIA_AESNI_AVX2_X86_64
 config CRYPTO_CAMELLIA_SPARC64
        tristate "Camellia cipher algorithm (SPARC64)"
        depends on SPARC64
+       depends on CRYPTO
        select CRYPTO_ALGAPI
        select CRYPTO_SKCIPHER
        help
@@ -1321,7 +1372,6 @@ config CRYPTO_CAST5_AVX_X86_64
        select CRYPTO_CAST5
        select CRYPTO_CAST_COMMON
        select CRYPTO_SIMD
-       imply CRYPTO_CTR
        help
          The CAST5 encryption algorithm (synonymous with CAST-128) is
          described in RFC2144.
@@ -1343,9 +1393,9 @@ config CRYPTO_CAST6_AVX_X86_64
        select CRYPTO_SKCIPHER
        select CRYPTO_CAST6
        select CRYPTO_CAST_COMMON
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SIMD
-       imply CRYPTO_XTS
-       imply CRYPTO_CTR
+       select CRYPTO_XTS
        help
          The CAST6 encryption algorithm (synonymous with CAST-256) is
          described in RFC2612.
@@ -1375,7 +1425,6 @@ config CRYPTO_DES3_EDE_X86_64
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
        select CRYPTO_LIB_DES
-       imply CRYPTO_CTR
        help
          Triple DES EDE (FIPS 46-3) algorithm.
 
@@ -1405,6 +1454,18 @@ config CRYPTO_KHAZAD
          See also:
          <http://www.larc.usp.br/~pbarreto/KhazadPage.html>
 
+config CRYPTO_SALSA20
+       tristate "Salsa20 stream cipher algorithm"
+       select CRYPTO_SKCIPHER
+       help
+         Salsa20 stream cipher algorithm.
+
+         Salsa20 is a stream cipher submitted to eSTREAM, the ECRYPT
+         Stream Cipher Project. See <https://www.ecrypt.eu.org/stream/>
+
+         The Salsa20 stream cipher algorithm is designed by Daniel J.
+         Bernstein <djb@cr.yp.to>. See <https://cr.yp.to/snuffle.html>
+
 config CRYPTO_CHACHA20
        tristate "ChaCha stream cipher algorithms"
        select CRYPTO_LIB_CHACHA_GENERIC
@@ -1465,7 +1526,8 @@ config CRYPTO_SERPENT
          Serpent cipher algorithm, by Anderson, Biham & Knudsen.
 
          Keys are allowed to be from 0 to 256 bits in length, in steps
-         of 8 bits.
+         of 8 bits.  Also includes the 'Tnepres' algorithm, a reversed
+         variant of Serpent for compatibility with old kerneli.org code.
 
          See also:
          <https://www.cl.cam.ac.uk/~rja14/serpent.html>
@@ -1474,9 +1536,9 @@ config CRYPTO_SERPENT_SSE2_X86_64
        tristate "Serpent cipher algorithm (x86_64/SSE2)"
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SERPENT
        select CRYPTO_SIMD
-       imply CRYPTO_CTR
        help
          Serpent cipher algorithm, by Anderson, Biham & Knudsen.
 
@@ -1493,9 +1555,9 @@ config CRYPTO_SERPENT_SSE2_586
        tristate "Serpent cipher algorithm (i586/SSE2)"
        depends on X86 && !64BIT
        select CRYPTO_SKCIPHER
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SERPENT
        select CRYPTO_SIMD
-       imply CRYPTO_CTR
        help
          Serpent cipher algorithm, by Anderson, Biham & Knudsen.
 
@@ -1512,10 +1574,10 @@ config CRYPTO_SERPENT_AVX_X86_64
        tristate "Serpent cipher algorithm (x86_64/AVX)"
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SERPENT
        select CRYPTO_SIMD
-       imply CRYPTO_XTS
-       imply CRYPTO_CTR
+       select CRYPTO_XTS
        help
          Serpent cipher algorithm, by Anderson, Biham & Knudsen.
 
@@ -1547,7 +1609,6 @@ config CRYPTO_SERPENT_AVX2_X86_64
 config CRYPTO_SM4
        tristate "SM4 cipher algorithm"
        select CRYPTO_ALGAPI
-       select CRYPTO_LIB_SM4
        help
          SM4 cipher algorithms (OSCCA GB/T 32907-2016).
 
@@ -1570,49 +1631,6 @@ config CRYPTO_SM4
 
          If unsure, say N.
 
-config CRYPTO_SM4_AESNI_AVX_X86_64
-       tristate "SM4 cipher algorithm (x86_64/AES-NI/AVX)"
-       depends on X86 && 64BIT
-       select CRYPTO_SKCIPHER
-       select CRYPTO_SIMD
-       select CRYPTO_ALGAPI
-       select CRYPTO_LIB_SM4
-       help
-         SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX).
-
-         SM4 (GBT.32907-2016) is a cryptographic standard issued by the
-         Organization of State Commercial Administration of China (OSCCA)
-         as an authorized cryptographic algorithms for the use within China.
-
-         This is SM4 optimized implementation using AES-NI/AVX/x86_64
-         instruction set for block cipher. Through two affine transforms,
-         we can use the AES S-Box to simulate the SM4 S-Box to achieve the
-         effect of instruction acceleration.
-
-         If unsure, say N.
-
-config CRYPTO_SM4_AESNI_AVX2_X86_64
-       tristate "SM4 cipher algorithm (x86_64/AES-NI/AVX2)"
-       depends on X86 && 64BIT
-       select CRYPTO_SKCIPHER
-       select CRYPTO_SIMD
-       select CRYPTO_ALGAPI
-       select CRYPTO_LIB_SM4
-       select CRYPTO_SM4_AESNI_AVX_X86_64
-       help
-         SM4 cipher algorithms (OSCCA GB/T 32907-2016) (x86_64/AES-NI/AVX2).
-
-         SM4 (GBT.32907-2016) is a cryptographic standard issued by the
-         Organization of State Commercial Administration of China (OSCCA)
-         as an authorized cryptographic algorithms for the use within China.
-
-         This is SM4 optimized implementation using AES-NI/AVX2/x86_64
-         instruction set for block cipher. Through two affine transforms,
-         we can use the AES S-Box to simulate the SM4 S-Box to achieve the
-         effect of instruction acceleration.
-
-         If unsure, say N.
-
 config CRYPTO_TEA
        tristate "TEA, XTEA and XETA cipher algorithms"
        depends on CRYPTO_USER_API_ENABLE_OBSOLETE
@@ -1657,7 +1675,6 @@ config CRYPTO_TWOFISH_586
        depends on (X86 || UML_X86) && !64BIT
        select CRYPTO_ALGAPI
        select CRYPTO_TWOFISH_COMMON
-       imply CRYPTO_CTR
        help
          Twofish cipher algorithm.
 
@@ -1674,7 +1691,6 @@ config CRYPTO_TWOFISH_X86_64
        depends on (X86 || UML_X86) && 64BIT
        select CRYPTO_ALGAPI
        select CRYPTO_TWOFISH_COMMON
-       imply CRYPTO_CTR
        help
          Twofish cipher algorithm (x86_64).
 
@@ -1692,6 +1708,7 @@ config CRYPTO_TWOFISH_X86_64_3WAY
        select CRYPTO_SKCIPHER
        select CRYPTO_TWOFISH_COMMON
        select CRYPTO_TWOFISH_X86_64
+       select CRYPTO_GLUE_HELPER_X86
        help
          Twofish cipher algorithm (x86_64, 3-way parallel).
 
@@ -1710,11 +1727,11 @@ config CRYPTO_TWOFISH_AVX_X86_64
        tristate "Twofish cipher algorithm (x86_64/AVX)"
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
+       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SIMD
        select CRYPTO_TWOFISH_COMMON
        select CRYPTO_TWOFISH_X86_64
        select CRYPTO_TWOFISH_X86_64_3WAY
-       imply CRYPTO_XTS
        help
          Twofish cipher algorithm (x86_64/AVX).
 
@@ -1812,7 +1829,7 @@ config CRYPTO_DRBG_HMAC
        bool
        default y
        select CRYPTO_HMAC
-       select CRYPTO_SHA512
+       select CRYPTO_SHA256
 
 config CRYPTO_DRBG_HASH
        bool "Enable Hash DRBG"
@@ -1928,6 +1945,7 @@ config CRYPTO_USER_API_AKCIPHER
 config CRYPTO_USER_API_KPP
        tristate "User-space interface for key protocol primitives algorithms"
        depends on NET
+       select CRYPTO_DH
        select CRYPTO_KPP2
        select CRYPTO_USER_API
        help
index 81401bb..ceac908 100644 (file)
@@ -55,12 +55,6 @@ sm2_generic-y += sm2.o
 
 obj-$(CONFIG_CRYPTO_SM2) += sm2_generic.o
 
-$(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h
-$(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h
-ecdsa_generic-y += ecdsa.o
-ecdsa_generic-y += ecdsasignature.asn1.o
-obj-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o
-
 crypto_acompress-y := acompress.o
 crypto_acompress-y += scompress.o
 obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o
@@ -78,7 +72,10 @@ obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
+obj-$(CONFIG_CRYPTO_RMD128) += rmd128.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
+obj-$(CONFIG_CRYPTO_RMD256) += rmd256.o
+obj-$(CONFIG_CRYPTO_RMD320) += rmd320.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
 obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o
@@ -87,6 +84,7 @@ obj-$(CONFIG_CRYPTO_SM3) += sm3_generic.o
 obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns)  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
+obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
 obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
 obj-$(CONFIG_CRYPTO_BLAKE2S) += blake2s_generic.o
 obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
@@ -148,6 +146,7 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_SEED) += seed.o
+obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o
 obj-$(CONFIG_CRYPTO_CHACHA20) += chacha_generic.o
 obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
index 51690e7..4c2082d 100644 (file)
@@ -430,6 +430,24 @@ config CRYPTO_DEV_OMAP_DES
 
 endif # CRYPTO_DEV_OMAP
 
+config CRYPTO_DEV_PICOXCELL
+       tristate "Support for picoXcell IPSEC and Layer2 crypto engines"
+       depends on (ARCH_PICOXCELL || COMPILE_TEST) && HAVE_CLK
+       select CRYPTO_AEAD
+       select CRYPTO_AES
+       select CRYPTO_AUTHENC
+       select CRYPTO_SKCIPHER
+       select CRYPTO_LIB_DES
+       select CRYPTO_CBC
+       select CRYPTO_ECB
+       select CRYPTO_SEQIV
+       help
+         This option enables support for the hardware offload engines in the
+         Picochip picoXcell SoC devices. Select this for IPSEC ESP offload
+         and for 3gpp Layer 2 ciphering support.
+
+         Saying m here will build a module named picoxcell_crypto.
+
 config CRYPTO_DEV_SAHARA
        tristate "Support for SAHARA crypto accelerator"
        depends on ARCH_MXC && OF
@@ -796,6 +814,21 @@ config CRYPTO_DEV_ZYNQMP_AES
          accelerator. Select this if you want to use the ZynqMP module
          for AES algorithms.
 
+config CRYPTO_DEV_MEDIATEK
+       tristate "MediaTek's EIP97 Cryptographic Engine driver"
+       depends on (ARM && ARCH_MEDIATEK) || COMPILE_TEST
+       select CRYPTO_LIB_AES
+       select CRYPTO_AEAD
+       select CRYPTO_SKCIPHER
+       select CRYPTO_SHA1
+       select CRYPTO_SHA256
+       select CRYPTO_SHA512
+       select CRYPTO_HMAC
+       help
+         This driver allows you to utilize the hardware crypto accelerator
+         EIP97 which can be found on the MT7623 MT2701, MT8521p, etc ....
+         Select this if you want to use it for AES/SHA1/SHA2 algorithms.
+
 source "drivers/crypto/chelsio/Kconfig"
 
 source "drivers/crypto/virtio/Kconfig"
index f8fd500..a44a99d 100644 (file)
@@ -46,6 +46,9 @@ struct crypto_kpp {
 /**
  * struct kpp_alg - generic key-agreement protocol primitives
  *
+ * @set_param:         Function allows the caller to set the parameters
+ *                     separately from the key. The format of the parameters
+ *                     is protocol specific.
  * @set_secret:                Function invokes the protocol specific function to
  *                     store the secret private key along with parameters.
  *                     The implementation knows how to decode the buffer
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
new file mode 100755 (executable)
index 0000000..4ff3da8
--- /dev/null
@@ -0,0 +1,167 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common values for SHA algorithms
+ */
+
+#ifndef _CRYPTO_SHA_H
+#define _CRYPTO_SHA_H
+
+#include <linux/types.h>
+
+#define SHA1_DIGEST_SIZE        20
+#define SHA1_BLOCK_SIZE         64
+
+#define SHA224_DIGEST_SIZE     28
+#define SHA224_BLOCK_SIZE      64
+
+#define SHA256_DIGEST_SIZE      32
+#define SHA256_BLOCK_SIZE       64
+
+#define SHA384_DIGEST_SIZE      48
+#define SHA384_BLOCK_SIZE       128
+
+#define SHA512_DIGEST_SIZE      64
+#define SHA512_BLOCK_SIZE       128
+
+#define SHA1_H0                0x67452301UL
+#define SHA1_H1                0xefcdab89UL
+#define SHA1_H2                0x98badcfeUL
+#define SHA1_H3                0x10325476UL
+#define SHA1_H4                0xc3d2e1f0UL
+
+#define SHA224_H0      0xc1059ed8UL
+#define SHA224_H1      0x367cd507UL
+#define SHA224_H2      0x3070dd17UL
+#define SHA224_H3      0xf70e5939UL
+#define SHA224_H4      0xffc00b31UL
+#define SHA224_H5      0x68581511UL
+#define SHA224_H6      0x64f98fa7UL
+#define SHA224_H7      0xbefa4fa4UL
+
+#define SHA256_H0      0x6a09e667UL
+#define SHA256_H1      0xbb67ae85UL
+#define SHA256_H2      0x3c6ef372UL
+#define SHA256_H3      0xa54ff53aUL
+#define SHA256_H4      0x510e527fUL
+#define SHA256_H5      0x9b05688cUL
+#define SHA256_H6      0x1f83d9abUL
+#define SHA256_H7      0x5be0cd19UL
+
+#define SHA384_H0      0xcbbb9d5dc1059ed8ULL
+#define SHA384_H1      0x629a292a367cd507ULL
+#define SHA384_H2      0x9159015a3070dd17ULL
+#define SHA384_H3      0x152fecd8f70e5939ULL
+#define SHA384_H4      0x67332667ffc00b31ULL
+#define SHA384_H5      0x8eb44a8768581511ULL
+#define SHA384_H6      0xdb0c2e0d64f98fa7ULL
+#define SHA384_H7      0x47b5481dbefa4fa4ULL
+
+#define SHA512_H0      0x6a09e667f3bcc908ULL
+#define SHA512_H1      0xbb67ae8584caa73bULL
+#define SHA512_H2      0x3c6ef372fe94f82bULL
+#define SHA512_H3      0xa54ff53a5f1d36f1ULL
+#define SHA512_H4      0x510e527fade682d1ULL
+#define SHA512_H5      0x9b05688c2b3e6c1fULL
+#define SHA512_H6      0x1f83d9abfb41bd6bULL
+#define SHA512_H7      0x5be0cd19137e2179ULL
+
+extern const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE];
+
+extern const u8 sha224_zero_message_hash[SHA224_DIGEST_SIZE];
+
+extern const u8 sha256_zero_message_hash[SHA256_DIGEST_SIZE];
+
+extern const u8 sha384_zero_message_hash[SHA384_DIGEST_SIZE];
+
+extern const u8 sha512_zero_message_hash[SHA512_DIGEST_SIZE];
+
+struct sha1_state {
+       u32 state[SHA1_DIGEST_SIZE / 4];
+       u64 count;
+       u8 buffer[SHA1_BLOCK_SIZE];
+};
+
+struct sha256_state {
+       u32 state[SHA256_DIGEST_SIZE / 4];
+       u64 count;
+       u8 buf[SHA256_BLOCK_SIZE];
+};
+
+struct sha512_state {
+       u64 state[SHA512_DIGEST_SIZE / 8];
+       u64 count[2];
+       u8 buf[SHA512_BLOCK_SIZE];
+};
+
+struct shash_desc;
+
+extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
+                             unsigned int len);
+
+extern int crypto_sha1_finup(struct shash_desc *desc, const u8 *data,
+                            unsigned int len, u8 *hash);
+
+extern int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
+                             unsigned int len);
+
+extern int crypto_sha256_finup(struct shash_desc *desc, const u8 *data,
+                              unsigned int len, u8 *hash);
+
+extern int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
+                             unsigned int len);
+
+extern int crypto_sha512_finup(struct shash_desc *desc, const u8 *data,
+                              unsigned int len, u8 *hash);
+
+/*
+ * An implementation of SHA-1's compression function.  Don't use in new code!
+ * You shouldn't be using SHA-1, and even if you *have* to use SHA-1, this isn't
+ * the correct way to hash something with SHA-1 (use crypto_shash instead).
+ */
+#define SHA1_DIGEST_WORDS      (SHA1_DIGEST_SIZE / 4)
+#define SHA1_WORKSPACE_WORDS   16
+void sha1_init(__u32 *buf);
+void sha1_transform(__u32 *digest, const char *data, __u32 *W);
+
+/*
+ * Stand-alone implementation of the SHA256 algorithm. It is designed to
+ * have as little dependencies as possible so it can be used in the
+ * kexec_file purgatory. In other cases you should generally use the
+ * hash APIs from include/crypto/hash.h. Especially when hashing large
+ * amounts of data as those APIs may be hw-accelerated.
+ *
+ * For details see lib/crypto/sha256.c
+ */
+
+static inline void sha256_init(struct sha256_state *sctx)
+{
+       sctx->state[0] = SHA256_H0;
+       sctx->state[1] = SHA256_H1;
+       sctx->state[2] = SHA256_H2;
+       sctx->state[3] = SHA256_H3;
+       sctx->state[4] = SHA256_H4;
+       sctx->state[5] = SHA256_H5;
+       sctx->state[6] = SHA256_H6;
+       sctx->state[7] = SHA256_H7;
+       sctx->count = 0;
+}
+void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
+void sha256_final(struct sha256_state *sctx, u8 *out);
+void sha256(const u8 *data, unsigned int len, u8 *out);
+
+static inline void sha224_init(struct sha256_state *sctx)
+{
+       sctx->state[0] = SHA224_H0;
+       sctx->state[1] = SHA224_H1;
+       sctx->state[2] = SHA224_H2;
+       sctx->state[3] = SHA224_H3;
+       sctx->state[4] = SHA224_H4;
+       sctx->state[5] = SHA224_H5;
+       sctx->state[6] = SHA224_H6;
+       sctx->state[7] = SHA224_H7;
+       sctx->count = 0;
+}
+void sha224_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
+void sha224_final(struct sha256_state *sctx, u8 *out);
+
+#endif