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

RISC OS changes because of dynload removal

This commit is contained in:
Stefan Bellon 2002-08-03 21:53:33 +00:00
parent 582f0d5d98
commit 5631db0402
7 changed files with 28 additions and 102 deletions

View file

@ -1,10 +1,8 @@
2002-08-03 Stefan Bellon <sbellon@sbellon.de>
* idea-stub.c (idea_get_info): RISC OS' Norcroft C needs a cast.
* random.c (getfnc_gather_random): Added RISC OS support.
* rndriscos.c: Removed dynload code.
* rndriscos.c: Removed dynload code and tidied up a bit.
2002-08-03 Werner Koch <wk@gnupg.org>

View file

@ -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;