Browse Source

[rng] Allow entropy_enable() to return an error

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
196f0bb081

+ 4
- 1
src/arch/i386/interface/pcbios/rtc_entropy.c View File

@@ -165,12 +165,15 @@ static void rtc_disable_int ( void ) {
165 165
 /**
166 166
  * Enable entropy gathering
167 167
  *
168
+ * @ret rc		Return status code
168 169
  */
169
-static void rtc_entropy_enable ( void ) {
170
+static int rtc_entropy_enable ( void ) {
170 171
 
171 172
 	rtc_hook_isr();
172 173
 	enable_irq ( RTC_IRQ );
173 174
 	rtc_enable_int();
175
+
176
+	return 0;
174 177
 }
175 178
 
176 179
 /**

+ 2
- 1
src/crypto/entropy.c View File

@@ -422,7 +422,8 @@ int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp,
422 422
 	int rc;
423 423
 
424 424
 	/* Enable entropy gathering */
425
-	entropy_enable();
425
+	if ( ( rc = entropy_enable() ) != 0 )
426
+		return rc;
426 427
 
427 428
 	/* Perform mandatory startup tests, if not yet performed */
428 429
 	for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {

+ 2
- 1
src/include/ipxe/entropy.h View File

@@ -61,8 +61,9 @@ typedef uint8_t entropy_sample_t;
61 61
 /**
62 62
  * Enable entropy gathering
63 63
  *
64
+ * @ret rc		Return status code
64 65
  */
65
-void entropy_enable ( void );
66
+int entropy_enable ( void );
66 67
 
67 68
 /**
68 69
  * Disable entropy gathering

+ 2
- 1
src/include/ipxe/null_entropy.h View File

@@ -19,9 +19,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
19 19
 #define ENTROPY_PREFIX_null __null_
20 20
 #endif
21 21
 
22
-static inline __always_inline void
22
+static inline __always_inline int
23 23
 ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
24 24
 	/* Do nothing */
25
+	return 0;
25 26
 }
26 27
 
27 28
 static inline __always_inline void

+ 2
- 1
src/tests/entropy_sample.c View File

@@ -48,7 +48,8 @@ static void entropy_sample_test_exec ( void ) {
48 48
 	for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {
49 49
 
50 50
 		/* Collect one block of samples */
51
-		entropy_enable();
51
+		rc = entropy_enable();
52
+		ok ( rc == 0 );
52 53
 		for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
53 54
 			rc = get_noise ( &samples[j] );
54 55
 			ok ( rc == 0 );

Loading…
Cancel
Save