ANDROID: fips140: remove CONFIG_CRYPTO_FIPS140 option
There is no good reason for the CRYPTO_FIPS140 kconfig option to exist separately from CRYPTO_FIPS140_MOD. It existed mainly to guard some code in the module loader that was needed only for loading the fips140 module. However, that code has been removed, since an alternate solution that doesn't require changes to the module loader was found. The remaining references to CRYPTO_FIPS140 are in: - scripts/module.lds.S. But the guarded code only affects building the fips140 module, so CRYPTO_FIPS140_MOD should be used here instead. - lib/crypto/, for guarding the Android vendor hooks required by the fips140 module. However, Android vendor hooks are already guarded by ANDROID_VENDOR_HOOKS. The extra guard by CRYPTO_FIPS140 isn't useful, especially since CRYPTO_FIPS140 was effectively hardcoded to y anyway. It did have the side effect of making the hooks be guarded by arm64, which excluded them from builds of arch/x86/purgatory/. However, a cleaner way to accomplish that is to check for __DISABLE_EXPORTS, which handles both arch/x86/purgatory/ and fips140.ko itself. Bug: 188620248 Change-Id: Ic6141cd2a553540c2bf95774e71de7310926e3ce Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
committed by
Matthias Männich
parent
320dfca58a
commit
d4966a8203
@@ -33,15 +33,9 @@ config CRYPTO_FIPS
|
|||||||
certification. You should say no unless you know what
|
certification. You should say no unless you know what
|
||||||
this is.
|
this is.
|
||||||
|
|
||||||
# CRYPTO_FIPS140 just enables the support in the kernel for loading fips140.ko.
|
|
||||||
# The module still needs to be built and loaded if you need FIPS 140 compliance.
|
|
||||||
config CRYPTO_FIPS140
|
|
||||||
def_bool y
|
|
||||||
depends on MODULES && ARM64 && ARM64_MODULE_PLTS
|
|
||||||
|
|
||||||
config CRYPTO_FIPS140_MOD
|
config CRYPTO_FIPS140_MOD
|
||||||
bool "Enable FIPS 140 cryptographic module"
|
bool "Enable FIPS 140 cryptographic module"
|
||||||
depends on LTO_CLANG && CRYPTO_FIPS140
|
depends on MODULES && ARM64 && ARM64_MODULE_PLTS && LTO_CLANG
|
||||||
help
|
help
|
||||||
This option enables building a loadable module fips140.ko, which
|
This option enables building a loadable module fips140.ko, which
|
||||||
contains various crypto algorithms that are also built into vmlinux.
|
contains various crypto algorithms that are also built into vmlinux.
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ int aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key,
|
|||||||
u32 rc, i, j;
|
u32 rc, i, j;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
#if defined(CONFIG_CRYPTO_FIPS140) && !defined(BUILD_FIPS140_KO)
|
#ifndef __DISABLE_EXPORTS
|
||||||
err = -(MAX_ERRNO + 1);
|
err = -(MAX_ERRNO + 1);
|
||||||
trace_android_vh_aes_expandkey(ctx, in_key, key_len, &err);
|
trace_android_vh_aes_expandkey(ctx, in_key, key_len, &err);
|
||||||
if (err != -(MAX_ERRNO + 1))
|
if (err != -(MAX_ERRNO + 1))
|
||||||
@@ -269,7 +269,7 @@ void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
|
|||||||
int rounds = 6 + ctx->key_length / 4;
|
int rounds = 6 + ctx->key_length / 4;
|
||||||
u32 st0[4], st1[4];
|
u32 st0[4], st1[4];
|
||||||
int round;
|
int round;
|
||||||
#if defined(CONFIG_CRYPTO_FIPS140) && !defined(BUILD_FIPS140_KO)
|
#ifndef __DISABLE_EXPORTS
|
||||||
int hook_inuse = 0;
|
int hook_inuse = 0;
|
||||||
|
|
||||||
trace_android_vh_aes_encrypt(ctx, out, in, &hook_inuse);
|
trace_android_vh_aes_encrypt(ctx, out, in, &hook_inuse);
|
||||||
@@ -327,7 +327,7 @@ void aes_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in)
|
|||||||
int rounds = 6 + ctx->key_length / 4;
|
int rounds = 6 + ctx->key_length / 4;
|
||||||
u32 st0[4], st1[4];
|
u32 st0[4], st1[4];
|
||||||
int round;
|
int round;
|
||||||
#if defined(CONFIG_CRYPTO_FIPS140) && !defined(BUILD_FIPS140_KO)
|
#ifndef __DISABLE_EXPORTS
|
||||||
int hook_inuse = 0;
|
int hook_inuse = 0;
|
||||||
|
|
||||||
trace_android_vh_aes_decrypt(ctx, out, in, &hook_inuse);
|
trace_android_vh_aes_decrypt(ctx, out, in, &hook_inuse);
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ void sha256(const u8 *data, unsigned int len, u8 *out)
|
|||||||
{
|
{
|
||||||
struct sha256_state sctx;
|
struct sha256_state sctx;
|
||||||
|
|
||||||
#if defined(CONFIG_CRYPTO_FIPS140) && !defined(BUILD_FIPS140_KO)
|
#ifndef __DISABLE_EXPORTS
|
||||||
int hook_inuse = 0;
|
int hook_inuse = 0;
|
||||||
|
|
||||||
trace_android_vh_sha256(data, len, out, &hook_inuse);
|
trace_android_vh_sha256(data, len, out, &hook_inuse);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ SECTIONS {
|
|||||||
|
|
||||||
__patchable_function_entries : { *(__patchable_function_entries) }
|
__patchable_function_entries : { *(__patchable_function_entries) }
|
||||||
|
|
||||||
#ifdef CONFIG_CRYPTO_FIPS140
|
#ifdef CONFIG_CRYPTO_FIPS140_MOD
|
||||||
/*
|
/*
|
||||||
* The FIPS140 module incorporates copies of builtin code, which gets
|
* The FIPS140 module incorporates copies of builtin code, which gets
|
||||||
* integrity checked at module load time, and registered in a way that
|
* integrity checked at module load time, and registered in a way that
|
||||||
|
|||||||
Reference in New Issue
Block a user