aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/rndriscos.c
diff options
context:
space:
mode:
authorStefan Bellon <[email protected]>2002-08-03 21:53:33 +0000
committerStefan Bellon <[email protected]>2002-08-03 21:53:33 +0000
commit5631db0402f9753a689e85e82e8d98d4bbcfa689 (patch)
tree9193e07ed24d83ae302fb832e2070d59b839905f /cipher/rndriscos.c
parentRISC OS changes due to dynload removal (diff)
downloadgnupg-5631db0402f9753a689e85e82e8d98d4bbcfa689.tar.gz
gnupg-5631db0402f9753a689e85e82e8d98d4bbcfa689.zip
RISC OS changes because of dynload removal
Diffstat (limited to '')
-rw-r--r--cipher/rndriscos.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/cipher/rndriscos.c b/cipher/rndriscos.c
index 3aa16d523..98142b313 100644
--- a/cipher/rndriscos.c
+++ b/cipher/rndriscos.c
@@ -22,51 +22,49 @@
#ifdef USE_RNDRISCOS
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
#include <string.h>
#include <kernel.h>
#include <swis.h>
#include "util.h"
-#include "algorithms.h"
static int init_device(void);
#define CryptRandom_Byte 0x51980
+static const char * const path[] = {
+ "GnuPG:CryptRandom",
+ "GnuPG: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)
{
- _kernel_swi_regs r;
+ int i;
/* Is CryptRandom already loaded? */
- r.r[0] = 18;
- r.r[1] = (int) "CryptRandom";
- if (!_kernel_swi(OS_Module, &r, &r))
+ if (!_swix(OS_Module, _INR(0,1), 18, "CryptRandom"))
return 1;
- /* Is it named CryptRand and inside GnuPG$Path? */
- r.r[0] = 1;
- r.r[1] = (int) "GnuPG:CryptRand";
- if (!_kernel_swi(OS_Module, &r, &r))
- return 1;
-
- /* Is it named CryptRandom and inside GnuPG$Path? */
- r.r[0] = 1;
- r.r[1] = (int) "GnuPG:CryptRandom";
- if (!_kernel_swi(OS_Module, &r, &r))
- 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,
@@ -75,8 +73,6 @@ rndriscos_gather_random(void (*add)(const void*, size_t, int), int requester,
static int initialized = 0;
int n;
byte buffer[768];
- _kernel_swi_regs r;
- _kernel_oserror *e;
if (!initialized)
initialized = init_device();
@@ -84,11 +80,9 @@ rndriscos_gather_random(void (*add)(const void*, size_t, int), int requester,
while (length) {
int nbytes = length < sizeof(buffer) ? length : sizeof(buffer);
- for (n = 0; n < nbytes; n++) {
- if (e = _kernel_swi(CryptRandom_Byte, &r, &r))
+ for (n = 0; n < nbytes; ++n)
+ if (_swix(CryptRandom_Byte, _OUT(0), &buffer[n]))
g10_log_fatal("CryptRandom module isn't working as expected!\n");
- buffer[n] = (byte) r.r[0];
- }
(*add)(buffer, n, requester);
length -= n;