^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #undef TRACE_SYSTEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define TRACE_SYSTEM fips140
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #define TRACE_INCLUDE_PATH trace/hooks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #if !defined(_TRACE_HOOK_FIPS140_H) || defined(TRACE_HEADER_MULTI_READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define _TRACE_HOOK_FIPS140_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/tracepoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <trace/hooks/vendor_hooks.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifdef __GENKSYMS__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct crypto_aes_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* struct crypto_aes_ctx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <crypto/aes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #endif /* __GENKSYMS__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * These hooks exist only for the benefit of the FIPS140 crypto module, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * uses them to swap out the underlying implementation with one that is integrity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * checked as per FIPS 140 requirements. No other uses are allowed or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) DECLARE_HOOK(android_vh_sha256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) TP_PROTO(const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) unsigned int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u8 *out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int *hook_inuse),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) TP_ARGS(data, len, out, hook_inuse));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) DECLARE_HOOK(android_vh_aes_expandkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) TP_PROTO(struct crypto_aes_ctx *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) const u8 *in_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned int key_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int *err),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) TP_ARGS(ctx, in_key, key_len, err));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) DECLARE_HOOK(android_vh_aes_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) TP_PROTO(const struct crypto_aes_ctx *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) u8 *out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) const u8 *in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int *hook_inuse),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) TP_ARGS(ctx, out, in, hook_inuse));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) DECLARE_HOOK(android_vh_aes_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) TP_PROTO(const struct crypto_aes_ctx *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u8 *out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) const u8 *in,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int *hook_inuse),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) TP_ARGS(ctx, out, in, hook_inuse));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #endif /* _TRACE_HOOK_FIPS140_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* This part must be outside protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #include <trace/define_trace.h>