1
/* rndriscos.c - raw random number for RISC OS
2
* Copyright (C) 2001 Free Software Foundation, Inc.
4
* This file is part of GnuPG.
6
* GnuPG is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* GnuPG is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
30
static int init_device(void);
32
#define CryptRandom_Byte 0x51980
34
static const char * const path[] = {
37
"System:Modules.CryptRandom"
38
"System:Modules.CryptRand",
43
* Used to load the CryptRandom module if it isn't already loaded
50
/* Is CryptRandom already loaded? */
51
if (!_swix(OS_Module, _INR(0,1), 18, "CryptRandom"))
54
/* Check all the places where the module could be located */
55
for (i=0; path[i]; ++i)
56
if (!_swix(OS_Module, _INR(0,1), 1, path[i]))
59
/* Can't find CryptRandom in the default locations */
60
g10_log_fatal("Can't load module CryptRandom.\n");
62
return 0; /* never reached, but don't throw a warning */
67
* Get the random bytes from module
70
rndriscos_gather_random(void (*add)(const void*, size_t, int), int requester,
71
size_t length, int level)
73
static int initialized = 0;
78
initialized = init_device();
81
int nbytes = length < sizeof(buffer) ? length : sizeof(buffer);
83
for (n = 0; n < nbytes; ++n)
84
if (_swix(CryptRandom_Byte, _OUT(0), &buffer[n]))
85
g10_log_fatal("CryptRandom module isn't working as expected!\n");
87
(*add)(buffer, n, requester);
90
memset(buffer, 0, sizeof(buffer));
92
return 0; /* success */
95
#endif /*USE_RNDRISCOS */