Re: [PATCH net 1/3] selftests: net: tls: check if FIPS mode is enabled

From: Jakub Kicinski
Date: Thu Jun 08 2023 - 22:17:18 EST


On Wed, 7 Jun 2023 14:43:00 -0300 Magali Lemes wrote:
> FIXTURE(tls)
> {
> - int fd, cfd;
> + int fd, cfd, fips_enabled;

put bool fips_non_compliant into the variant, and mark down
the cases which need to be skipped. There is fewer variants
than tests

> bool notls;
> };
>
> @@ -309,7 +309,22 @@ FIXTURE_SETUP(tls)
> {
> struct tls_crypto_info_keys tls12;
> int one = 1;
> - int ret;
> + int ret, res;
> + FILE *f;
> +
> + self->fips_enabled = 0;
> + f = fopen("/proc/sys/crypto/fips_enabled", "r");
> + if (f) {
> + res = fscanf(f, "%d", &self->fips_enabled);
> + if (res != 1)
> + ksft_print_msg("ERROR: Couldn't read /proc/sys/crypto/fips_enabled\n");
> + fclose(f);
> + }

Cache the fips_enabled in a static global variable, no point reading
it every time.
--
pw-bot: cr