|
@@ -14,7 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
14
|
14
|
#include <assert.h>
|
15
|
15
|
#include <ipxe/api.h>
|
16
|
16
|
#include <ipxe/hash_df.h>
|
17
|
|
-#include <ipxe/sha1.h>
|
|
17
|
+#include <ipxe/sha256.h>
|
18
|
18
|
#include <config/entropy.h>
|
19
|
19
|
|
20
|
20
|
/**
|
|
@@ -100,14 +100,14 @@ int get_noise ( noise_sample_t *noise );
|
100
|
100
|
extern int get_entropy_input_tmp ( unsigned int num_samples,
|
101
|
101
|
uint8_t *tmp, size_t tmp_len );
|
102
|
102
|
|
103
|
|
-/** Use SHA-1 as the underlying hash algorithm for Hash_df
|
|
103
|
+/** Use SHA-256 as the underlying hash algorithm for Hash_df
|
104
|
104
|
*
|
105
|
|
- * Hash_df using SHA-1 is an Approved algorithm in ANS X9.82.
|
|
105
|
+ * Hash_df using SHA-256 is an Approved algorithm in ANS X9.82.
|
106
|
106
|
*/
|
107
|
|
-#define entropy_hash_df_algorithm sha1_algorithm
|
|
107
|
+#define entropy_hash_df_algorithm sha256_algorithm
|
108
|
108
|
|
109
|
109
|
/** Underlying hash algorithm output length (in bytes) */
|
110
|
|
-#define ENTROPY_HASH_DF_OUTLEN_BYTES SHA1_DIGEST_SIZE
|
|
110
|
+#define ENTROPY_HASH_DF_OUTLEN_BYTES SHA256_DIGEST_SIZE
|
111
|
111
|
|
112
|
112
|
/**
|
113
|
113
|
* Obtain entropy input
|
|
@@ -166,6 +166,13 @@ get_entropy_input ( unsigned int min_entropy_bits, void *data, size_t min_len,
|
166
|
166
|
linker_assert ( __builtin_constant_p ( num_samples ),
|
167
|
167
|
num_samples_not_constant );
|
168
|
168
|
|
|
169
|
+ /* (Unnumbered). The output length of the hash function shall
|
|
170
|
+ * meet or exceed the security strength indicated by the
|
|
171
|
+ * min_entropy parameter.
|
|
172
|
+ */
|
|
173
|
+ linker_assert ( ( ( 8 * ENTROPY_HASH_DF_OUTLEN_BYTES ) >=
|
|
174
|
+ min_entropy_bits ), hash_df_algorithm_too_weak );
|
|
175
|
+
|
169
|
176
|
/* 1. If ( min_length > max_length ), then return ( FAILURE, Null ) */
|
170
|
177
|
linker_assert ( ( min_len <= max_len ), min_len_greater_than_max_len );
|
171
|
178
|
|