Fix randomizer

Relying on the system randomizer for unit tests leads to cases where we
don't get deterministic results, which causes inconsistent results.
These random results don't need to be secure, so reimplement as a simple
linear feedback shift register[1].  This makes our unit tests now
produce the same output every time we call generate.

Note, this change showed a weakness in our testing, where timestamps
relied on different rules for ir->cper versus cper->ir.  hour 24 should
be allowed.

[1] https://en.wikipedia.org/wiki/Linear-feedback_shift_register

Change-Id: I0756b086c8ea5fb934e450f5d33e3ae0036868b3
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/generator/sections/gen-section-nvidia.c b/generator/sections/gen-section-nvidia.c
index a06f545..83b8845 100644
--- a/generator/sections/gen-section-nvidia.c
+++ b/generator/sections/gen-section-nvidia.c
@@ -26,8 +26,6 @@
 		"MCF",	     "GPU-STATUS",    "GPU-CONTNMT",   "SMMU",
 	};
 
-	init_random();
-
 	//Create random bytes.
 	int numRegs = 6;
 	size_t size = offsetof(EFI_NVIDIA_ERROR_DATA, Register) +
@@ -45,7 +43,8 @@
 	nvidia_error->Severity %= 4;
 
 	//Signature.
-	int idx_random = rand() % (sizeof(signatures) / sizeof(signatures[0]));
+	int idx_random =
+		cper_rand() % (sizeof(signatures) / sizeof(signatures[0]));
 	strncpy(nvidia_error->Signature, signatures[idx_random],
 		sizeof(nvidia_error->Signature) - 1);
 	nvidia_error->Signature[sizeof(nvidia_error->Signature) - 1] = '\0';