diff options
author | lloyd <lloyd@randombit.net> | 2008-11-23 18:42:39 +0000 |
---|---|---|
committer | lloyd <lloyd@randombit.net> | 2008-11-23 18:42:39 +0000 |
commit | 763d3a6d337dcd6339d6bd4858f84783274b3fec (patch) | |
tree | eff0532cb90033a8ecd1c9526bb709dafe3dc276 /src/entropy | |
parent | cf1dc543f142263917468c19249d6a3e920b17b2 (diff) |
Update BeOS entropy poller to also derive directly from EntropySource
and use xor_into_buf. Completely untested, though it looks clean besides
missing the BeOS headers+funcs if I try to compile on Linux.
Diffstat (limited to 'src/entropy')
-rw-r--r-- | src/entropy/beos_stats/es_beos.cpp | 55 | ||||
-rw-r--r-- | src/entropy/beos_stats/es_beos.h | 22 | ||||
-rw-r--r-- | src/entropy/beos_stats/info.txt | 4 |
3 files changed, 46 insertions, 35 deletions
diff --git a/src/entropy/beos_stats/es_beos.cpp b/src/entropy/beos_stats/es_beos.cpp index 80d5605d0..0fd9199bd 100644 --- a/src/entropy/beos_stats/es_beos.cpp +++ b/src/entropy/beos_stats/es_beos.cpp @@ -1,65 +1,80 @@ -/************************************************* -* BeOS EntropySource Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/** +* BeOS EntropySource Source File +* (C) 1999-2008 Jack Lloyd +*/ #include <botan/es_beos.h> +#include <botan/xor_buf.h> + #include <kernel/OS.h> #include <kernel/image.h> #include <interface/InterfaceDefs.h> namespace Botan { -/************************************************* -* BeOS Fast Poll * -*************************************************/ -void BeOS_EntropySource::do_fast_poll() +/** +* BeOS Fast Poll +*/ +u32bit BeOS_EntropySource::fast_poll(byte buf[], u32bit length) { + if(length == 0) + return 0; + + u32bit buf_i = 0; + system_info info_sys; get_system_info(&info_sys); - add_bytes(&info_sys, sizeof(system_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_sys); key_info info_key; get_key_info(&info_key); - add_bytes(&info_key, sizeof(key_info)); + buf_i = xor_into_buf(buf, buf_i, length, key_info); - add_bytes(idle_time()); + buf_i = xor_into_buf(buf, buf_i, length, idle_time()); + + return length; } -/************************************************* -* BeOS Slow Poll * -*************************************************/ -void BeOS_EntropySource::do_slow_poll() +/** +* BeOS slow poll +*/ +u32bit BeOS_EntropySource::slow_poll(byte buf[], u32bit length) { + if(length == 0) + return 0; + + u32bit buf_i = 0; team_info info_team; int32 cookie_team = 0; while(get_next_team_info(&cookie_team, &info_team) == B_OK) { - add_bytes(&info_team, sizeof(team_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_team); team_id id = info_team.team; int32 cookie = 0; thread_info info_thr; while(get_next_thread_info(id, &cookie, &info_thr) == B_OK) - add_bytes(&info_thr, sizeof(thread_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_thr); cookie = 0; image_info info_img; while(get_next_image_info(id, &cookie, &info_img) == B_OK) - add_bytes(&info_img, sizeof(image_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_img); cookie = 0; sem_info info_sem; while(get_next_sem_info(id, &cookie, &info_sem) == B_OK) - add_bytes(&info_sem, sizeof(sem_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_sem); cookie = 0; area_info info_area; while(get_next_area_info(id, &cookie, &info_area) == B_OK) - add_bytes(&info_area, sizeof(area_info)); + buf_i = xor_into_buf(buf, buf_i, length, info_area); } + + return length; } } diff --git a/src/entropy/beos_stats/es_beos.h b/src/entropy/beos_stats/es_beos.h index ec461780d..686ac5c38 100644 --- a/src/entropy/beos_stats/es_beos.h +++ b/src/entropy/beos_stats/es_beos.h @@ -1,25 +1,25 @@ -/************************************************* -* BeOS EntropySource Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ +/** +* BeOS EntropySource Header File +* (C) 1999-2008 Jack Lloyd +*/ #ifndef BOTAN_ENTROPY_SRC_BEOS_H__ #define BOTAN_ENTROPY_SRC_BEOS_H__ -#include <botan/buf_es.h> +#include <botan/entropy_src.h> namespace Botan { -/************************************************* -* BeOS Entropy Source * -*************************************************/ -class BOTAN_DLL BeOS_EntropySource : public Buffered_EntropySource +/** +* BeOS Entropy Source +*/ +class BOTAN_DLL BeOS_EntropySource : public EntropySource { private: std::string name() const { return "BeOS Statistics"; } - void do_fast_poll(); - void do_slow_poll(); + u32bit fast_poll(byte buf[], u32bit length); + u32bit slow_poll(byte buf[], u32bit length); }; } diff --git a/src/entropy/beos_stats/info.txt b/src/entropy/beos_stats/info.txt index 33badd5c3..a7e62cfb3 100644 --- a/src/entropy/beos_stats/info.txt +++ b/src/entropy/beos_stats/info.txt @@ -17,7 +17,3 @@ beos <libs> beos -> root,be </libs> - -<requires> -buf_es -</requires> |