]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/rand/rand_vms.c
Run util/openssl-format-source -v -c .
[thirdparty/openssl.git] / crypto / rand / rand_vms.c
CommitLineData
73986238 1/* crypto/rand/rand_vms.c -*- mode:C; c-file-style: "eay" -*- */
0f113f3e
MC
2/*
3 * Written by Richard Levitte <richard@levitte.org> for the OpenSSL project
4 * 2000.
0c61e299
RL
5 */
6/* ====================================================================
7 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
0f113f3e 14 * notice, this list of conditions and the following disclaimer.
0c61e299
RL
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@openssl.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include <openssl/rand.h>
61#include "rand_lcl.h"
62
bc36ee62 63#if defined(OPENSSL_SYS_VMS)
0c61e299 64
0f113f3e
MC
65# include <descrip.h>
66# include <jpidef.h>
67# include <ssdef.h>
68# include <starlet.h>
69# ifdef __DECC
70# pragma message disable DOLLARID
71# endif
0c61e299 72
0f113f3e
MC
73/*
74 * Use 32-bit pointers almost everywhere. Define the type to which to cast a
75 * pointer passed to an external function.
537c9823 76 */
0f113f3e
MC
77# if __INITIAL_POINTER_SIZE == 64
78# define PTR_T __void_ptr64
79# pragma pointer_size save
80# pragma pointer_size 32
81# else /* __INITIAL_POINTER_SIZE == 64 */
82# define PTR_T void *
83# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
84
85static struct items_data_st {
86 short length, code; /* length is amount of bytes */
87} items_data[] = {
88 {
89 4, JPI$_BUFIO
90 },
91 {
92 4, JPI$_CPUTIM
93 },
94 {
95 4, JPI$_DIRIO
96 },
97 {
98 8, JPI$_LOGINTIM
99 },
100 {
101 4, JPI$_PAGEFLTS
102 },
103 {
104 4, JPI$_PID
105 },
106 {
107 4, JPI$_WSSIZE
108 },
109 {
110 0, 0
111 }
112};
537c9823 113
0c61e299 114int RAND_poll(void)
0f113f3e
MC
115{
116 long pid, iosb[2];
117 int status = 0;
118 struct {
119 short length, code;
120 long *buffer;
121 int *retlen;
122 } item[32], *pitem;
123 unsigned char data_buffer[256];
124 short total_length = 0;
125 struct items_data_st *pitems_data;
73986238 126
0f113f3e
MC
127 pitems_data = items_data;
128 pitem = item;
73986238 129
0f113f3e
MC
130 /* Setup */
131 while (pitems_data->length && (total_length + pitems_data->length <= 256)) {
132 pitem->length = pitems_data->length;
133 pitem->code = pitems_data->code;
134 pitem->buffer = (long *)&data_buffer[total_length];
135 pitem->retlen = 0;
136 total_length += pitems_data->length;
137 pitems_data++;
138 pitem ++;
139 }
140 pitem->length = pitem->code = 0;
73986238 141
0f113f3e
MC
142 /*
143 * Scan through all the processes in the system and add entropy with
144 * results from the processes that were possible to look at.
145 * However, view the information as only half trustable.
146 */
147 pid = -1; /* search context */
148 while ((status = sys$getjpiw(0, &pid, 0, item, iosb, 0, 0))
149 != SS$_NOMOREPROC) {
150 if (status == SS$_NORMAL) {
151 RAND_add((PTR_T) data_buffer, total_length, total_length / 2);
152 }
153 }
154 sys$gettim(iosb);
155 RAND_add((PTR_T) iosb, sizeof(iosb), sizeof(iosb) / 2);
156 return 1;
0c61e299
RL
157}
158
159#endif