aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/rndriscos.c
diff options
context:
space:
mode:
authorStefan Bellon <[email protected]>2002-10-31 16:58:47 +0000
committerStefan Bellon <[email protected]>2002-10-31 16:58:47 +0000
commit7dac918b6d0ff849d9ca76d863cca8006b1988ad (patch)
tree59511c4ab21a53ed51f477535038e0ba6089ffd0 /cipher/rndriscos.c
parent* build-packet.c (do_plaintext), encode.c (encode_sesskey, encode_simple, (diff)
downloadgnupg-7dac918b6d0ff849d9ca76d863cca8006b1988ad.tar.gz
gnupg-7dac918b6d0ff849d9ca76d863cca8006b1988ad.zip
added RISC OS module loading support
Diffstat (limited to '')
-rw-r--r--cipher/rndriscos.c41
1 files changed, 9 insertions, 32 deletions
diff --git a/cipher/rndriscos.c b/cipher/rndriscos.c
index 98142b313..ee35beadd 100644
--- a/cipher/rndriscos.c
+++ b/cipher/rndriscos.c
@@ -27,55 +27,32 @@
#include <swis.h>
#include "util.h"
-static int init_device(void);
-
#define CryptRandom_Byte 0x51980
-static const char * const path[] = {
+static const char * const cryptrandom_path[] = {
"GnuPG:CryptRandom",
"GnuPG:CryptRand",
- "System:Modules.CryptRandom"
+ "System:310.Modules.CryptRandom",
+ "System:310.Modules.CryptRand",
+ "System:Modules.CryptRandom",
"System:Modules.CryptRand",
NULL
};
/****************
- * Used to load the CryptRandom module if it isn't already loaded
- */
-static int
-init_device(void)
-{
- int i;
-
- /* Is CryptRandom already loaded? */
- if (!_swix(OS_Module, _INR(0,1), 18, "CryptRandom"))
- return 1;
-
- /* Check all the places where the module could be located */
- for (i=0; path[i]; ++i)
- if (!_swix(OS_Module, _INR(0,1), 1, path[i]))
- return 1;
-
- /* Can't find CryptRandom in the default locations */
- g10_log_fatal("Can't load module CryptRandom.\n");
-
- return 0; /* never reached, but don't throw a warning */
-}
-
-
-/****************
* Get the random bytes from module
*/
int
rndriscos_gather_random(void (*add)(const void*, size_t, int), int requester,
size_t length, int level)
{
- static int initialized = 0;
+ static int rndriscos_initialized = 0;
int n;
byte buffer[768];
- if (!initialized)
- initialized = init_device();
+ if (!rndriscos_initialized)
+ rndriscos_initialized = riscos_load_module("CryptRandom",
+ cryptrandom_path, 1);
while (length) {
int nbytes = length < sizeof(buffer) ? length : sizeof(buffer);
@@ -87,7 +64,7 @@ rndriscos_gather_random(void (*add)(const void*, size_t, int), int requester,
(*add)(buffer, n, requester);
length -= n;
}
- memset(buffer, 0, sizeof(buffer));
+ wipememory(buffer, sizeof(buffer)); /* burn the buffer */
return 0; /* success */
}