1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

added RISC OS module loading support

This commit is contained in:
Stefan Bellon 2002-10-31 16:58:47 +00:00
parent 20c99d180a
commit 7dac918b6d
19 changed files with 395 additions and 133 deletions

View file

@ -1,3 +1,8 @@
2002-10-31 Stefan Bellon <sbellon@sbellon.de>
* rndriscos.c (rndriscos_gather_random): Use riscos_load_module()
to load CryptRandom module.
2002-10-12 Werner Koch <wk@gnupg.org>
* rndunix.c (my_popen): Make sure that stdin and stderr are

View file

@ -27,42 +27,18 @@
#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
*/
@ -70,12 +46,13 @@ 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 */
}