]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[rng] Allow entropy_enable() to return an error
authorMichael Brown <mcb30@ipxe.org>
Sun, 18 Mar 2012 16:45:04 +0000 (16:45 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sun, 18 Mar 2012 17:05:37 +0000 (17:05 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/interface/pcbios/rtc_entropy.c
src/crypto/entropy.c
src/include/ipxe/entropy.h
src/include/ipxe/null_entropy.h
src/tests/entropy_sample.c

index 03189659ebd5b34491774f7cba695ceebbdae82f..257cf08a0085d9e6ca013f6f1ca4f71d6b304e35 100644 (file)
@@ -165,12 +165,15 @@ static void rtc_disable_int ( void ) {
 /**
  * Enable entropy gathering
  *
+ * @ret rc             Return status code
  */
-static void rtc_entropy_enable ( void ) {
+static int rtc_entropy_enable ( void ) {
 
        rtc_hook_isr();
        enable_irq ( RTC_IRQ );
        rtc_enable_int();
+
+       return 0;
 }
 
 /**
index cb3d54d8feba9a4b0b28d25fc80747696d8406ef..03e7290a3afbe21334a870527156001b33c8bb83 100644 (file)
@@ -422,7 +422,8 @@ int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp,
        int rc;
 
        /* Enable entropy gathering */
-       entropy_enable();
+       if ( ( rc = entropy_enable() ) != 0 )
+               return rc;
 
        /* Perform mandatory startup tests, if not yet performed */
        for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {
index 02dde2f1d7c0dfe2849ad7bebca48cbd21ec145f..50ba4fc637b0387cc7b741d05de34ee34def126e 100644 (file)
@@ -61,8 +61,9 @@ typedef uint8_t entropy_sample_t;
 /**
  * Enable entropy gathering
  *
+ * @ret rc             Return status code
  */
-void entropy_enable ( void );
+int entropy_enable ( void );
 
 /**
  * Disable entropy gathering
index 0bfec802d49dfe82e4d1f4849883f8260d8af5bd..646d1a17e0f1d97992d8ce34e9e0366879be6075 100644 (file)
@@ -19,9 +19,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define ENTROPY_PREFIX_null __null_
 #endif
 
-static inline __always_inline void
+static inline __always_inline int
 ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
        /* Do nothing */
+       return 0;
 }
 
 static inline __always_inline void
index e00bb484eef66f2ac16c71e5a50cce3e0fd33ba2..9e75b4e9bacd93a089115b4dfb2b471a8381a1ad 100644 (file)
@@ -48,7 +48,8 @@ static void entropy_sample_test_exec ( void ) {
        for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {
 
                /* Collect one block of samples */
-               entropy_enable();
+               rc = entropy_enable();
+               ok ( rc == 0 );
                for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
                        rc = get_noise ( &samples[j] );
                        ok ( rc == 0 );