diff options
| author | Michael Brown | 2012-03-05 17:13:07 +0100 |
|---|---|---|
| committer | Michael Brown | 2012-03-06 00:23:45 +0100 |
| commit | fb6a33360fd99b19f557a1721475da9d4dd6b05c (patch) | |
| tree | 13f60dd57b2c69da5220d095e9575b2466fd6b9c /src/include | |
| parent | [tls] Formalise the definition of a TLS cipher suite (diff) | |
| download | ipxe-fb6a33360fd99b19f557a1721475da9d4dd6b05c.tar.gz ipxe-fb6a33360fd99b19f557a1721475da9d4dd6b05c.tar.xz ipxe-fb6a33360fd99b19f557a1721475da9d4dd6b05c.zip | |
[rng] Allow hash_df() to accept multiple underlying hash algorithms
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ipxe/entropy.h | 13 | ||||
| -rw-r--r-- | src/include/ipxe/hash_df.h | 18 |
2 files changed, 15 insertions, 16 deletions
diff --git a/src/include/ipxe/entropy.h b/src/include/ipxe/entropy.h index 8a1974a1e..7208ac87a 100644 --- a/src/include/ipxe/entropy.h +++ b/src/include/ipxe/entropy.h @@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <assert.h> #include <ipxe/api.h> #include <ipxe/hash_df.h> +#include <ipxe/sha1.h> #include <config/entropy.h> /** @@ -99,6 +100,15 @@ int get_noise ( noise_sample_t *noise ); extern int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp, size_t tmp_len ); +/** Use SHA-1 as the underlying hash algorithm for Hash_df + * + * Hash_df using SHA-1 is an Approved algorithm in ANS X9.82. + */ +#define entropy_hash_df_algorithm sha1_algorithm + +/** Underlying hash algorithm output length (in bytes) */ +#define ENTROPY_HASH_DF_OUTLEN_BYTES SHA1_DIGEST_SIZE + /** * Obtain entropy input * @@ -192,7 +202,8 @@ get_entropy_input ( unsigned int min_entropy_bits, void *data, size_t min_len, return min_len; } else if ( tmp_len > max_len ) { linker_assert ( ( tmp == tmp_buf ), data_inplace ); - hash_df ( tmp, tmp_len, data, max_len ); + hash_df ( &entropy_hash_df_algorithm, tmp, tmp_len, + data, max_len ); return max_len; } else { /* (Data is already in-place.) */ diff --git a/src/include/ipxe/hash_df.h b/src/include/ipxe/hash_df.h index 003e5ceff..607a4a610 100644 --- a/src/include/ipxe/hash_df.h +++ b/src/include/ipxe/hash_df.h @@ -10,21 +10,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <stdint.h> -#include <ipxe/sha1.h> +#include <ipxe/crypto.h> -/** Use SHA-1 as the underlying hash algorithm - * - * Hash_df using SHA-1 is an Approved algorithm in ANS X9.82. - */ -#define hash_df_algorithm sha1_algorithm - -/** Underlying hash algorithm output length (in bytes) */ -#define HASH_DF_OUTLEN_BYTES SHA1_DIGEST_SIZE - -/** Underlying hash algorithm context size (in bytes) */ -#define HASH_DF_CTX_SIZE SHA1_CTX_SIZE - -extern void hash_df ( const void *input, size_t input_len, void *output, - size_t output_len ); +extern void hash_df ( struct digest_algorithm *hash, const void *input, + size_t input_len, void *output, size_t output_len ); #endif /* _IPXE_HASH_DF_H */ |
