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
 /**
165
 /**
166
  * Enable entropy gathering
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
 	rtc_hook_isr();
172
 	rtc_hook_isr();
172
 	enable_irq ( RTC_IRQ );
173
 	enable_irq ( RTC_IRQ );
173
 	rtc_enable_int();
174
 	rtc_enable_int();
175
+
176
+	return 0;
174
 }
177
 }
175
 
178
 
176
 /**
179
 /**

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

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

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

61
 /**
61
 /**
62
  * Enable entropy gathering
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
  * Disable entropy gathering
69
  * Disable entropy gathering

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

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

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

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

Loading…
Cancel
Save