Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/stand/prekern prekern: add warnings upon prob...



details:   https://anonhg.NetBSD.org/src/rev/d0101a50896e
branches:  trunk
changeset: 379023:d0101a50896e
user:      khorben <khorben%NetBSD.org@localhost>
date:      Tue May 04 21:13:38 2021 +0000

description:
prekern: add warnings upon problems collecting entropy

As submitted on port-amd64@ (part 3/3)

Tested on NetBSD/amd64.

diffstat:

 sys/arch/amd64/stand/prekern/prng.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (37 lines):

diff -r b70f335ba14f -r d0101a50896e sys/arch/amd64/stand/prekern/prng.c
--- a/sys/arch/amd64/stand/prekern/prng.c       Tue May 04 21:10:25 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/prng.c       Tue May 04 21:13:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prng.c,v 1.4 2021/05/04 21:10:25 khorben Exp $ */
+/*     $NetBSD: prng.c,v 1.5 2021/05/04 21:13:38 khorben Exp $ */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -84,6 +84,7 @@ prng_get_entropy_file(SHA512_CTX *ctx)
        uint8_t digest[SHA1_DIGEST_LENGTH];
        rndsave_t *rndsave;
        SHA1_CTX sig;
+       size_t count = 0;
 
        biml =
            (struct btinfo_modulelist *)prng_lookup_bootinfo(BTINFO_MODULELIST);
@@ -117,7 +118,10 @@ prng_get_entropy_file(SHA512_CTX *ctx)
                }
 
                SHA512_Update(ctx, rndsave->data, sizeof(rndsave->data));
+               count++;
        }
+       if (count == 0)
+               print_state(STATE_WARNING, "No entropy file could be loaded");
 }
 
 /*
@@ -168,6 +172,8 @@ prng_init(void)
                cpuid(0x01, 0x00, descs);
                has_rdrand = (descs[2] & CPUID2_RDRAND) != 0;
        }
+       if (!has_rdseed && !has_rdrand)
+               print_state(STATE_WARNING, "No CPU entropy feature detected");
 
        SHA512_Init(&ctx);
        prng_get_entropy_file(&ctx);



Home | Main Index | Thread Index | Old Index