LRNG: Backport to 4.19 kernel
- Required to fix compilation of LRNG on 4.19 kernel Change-Id: I6a25f657d3ab2ee3f9e44cbe5a9c0314d6ca905f Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
parent
e2659e1cdf
commit
273ac0f0f8
@ -38,7 +38,7 @@ static int lrng_kcapi_drng_seed_helper(void *drng, const u8 *inbuf,
|
||||
struct crypto_shash *hash_tfm = lrng_drng_info->hash_tfm;
|
||||
SHASH_DESC_ON_STACK(shash, hash_tfm);
|
||||
u32 digestsize;
|
||||
u8 digest[HASH_MAX_DIGESTSIZE] __aligned(8);
|
||||
u8 digest[64] __aligned(8);
|
||||
int ret;
|
||||
|
||||
if (!hash_tfm)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/preempt.h>
|
||||
#include <asm/irq_regs.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <crypto/hash.h>
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/preempt.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/utsname.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
@ -32,6 +32,7 @@ int __init rand_initialize(void)
|
||||
{
|
||||
return lrng_rand_initialize();
|
||||
}
|
||||
early_initcall(rand_initialize);
|
||||
|
||||
bool lrng_ready_list_has_sleeper(void)
|
||||
{
|
||||
|
@ -6,8 +6,7 @@
|
||||
#ifndef _LRNG_INTERNAL_H
|
||||
#define _LRNG_INTERNAL_H
|
||||
|
||||
#include <crypto/sha1.h>
|
||||
#include <crypto/sha2.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
@ -15,6 +14,11 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#define arch_get_random_seed_long_early arch_get_random_seed_long
|
||||
#define arch_get_random_long_early arch_get_random_long
|
||||
|
||||
#define kfree_sensitive kzfree
|
||||
|
||||
/*************************** General LRNG parameter ***************************/
|
||||
|
||||
/* Security strength of LRNG -- this must match DRNG security strength */
|
||||
|
@ -30,7 +30,7 @@ static void lrng_sha1_block_fn(struct sha1_state *sctx, const u8 *src,
|
||||
u32 temp[SHA1_WORKSPACE_WORDS];
|
||||
|
||||
while (blocks--) {
|
||||
sha1_transform(sctx->state, src, temp);
|
||||
sha_transform(sctx->state, src, temp);
|
||||
src += SHA1_BLOCK_SIZE;
|
||||
}
|
||||
memzero_explicit(temp, sizeof(temp));
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/lrng.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <linux/sha256.h>
|
||||
|
||||
#include "lrng_sha.h"
|
||||
|
||||
|
@ -112,4 +112,15 @@ extern int crypto_sha512_update(struct shash_desc *desc, const u8 *data,
|
||||
|
||||
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 sha_init(__u32 *buf);
|
||||
void sha_transform(__u32 *digest, const char *data, __u32 *W);
|
||||
|
||||
#endif
|
||||
|
@ -636,3 +636,6 @@ config GENERIC_LIB_CMPDI2
|
||||
|
||||
config GENERIC_LIB_UCMPDI2
|
||||
bool
|
||||
|
||||
config CRYPTO_LIB_SHA256
|
||||
tristate
|
||||
|
@ -291,3 +291,6 @@ obj-$(CONFIG_GENERIC_LIB_LSHRDI3) += lshrdi3.o
|
||||
obj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o
|
||||
obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o
|
||||
obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
|
||||
libsha256-y := sha256.o
|
||||
|
Loading…
Reference in New Issue
Block a user