]>
Commit | Line | Data |
---|---|---|
0f113f3e | 1 | /* |
b1322259 | 2 | * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. |
0c61e299 | 3 | * |
b1322259 RS |
4 | * Licensed under the OpenSSL license (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
0c61e299 RL |
8 | */ |
9 | ||
10 | #include <openssl/rand.h> | |
11 | #include "rand_lcl.h" | |
12 | ||
bc36ee62 | 13 | #if defined(OPENSSL_SYS_VMS) |
0c61e299 | 14 | |
0f113f3e MC |
15 | # include <descrip.h> |
16 | # include <jpidef.h> | |
17 | # include <ssdef.h> | |
18 | # include <starlet.h> | |
19 | # ifdef __DECC | |
20 | # pragma message disable DOLLARID | |
21 | # endif | |
0c61e299 | 22 | |
0f113f3e MC |
23 | /* |
24 | * Use 32-bit pointers almost everywhere. Define the type to which to cast a | |
25 | * pointer passed to an external function. | |
537c9823 | 26 | */ |
0f113f3e MC |
27 | # if __INITIAL_POINTER_SIZE == 64 |
28 | # define PTR_T __void_ptr64 | |
29 | # pragma pointer_size save | |
30 | # pragma pointer_size 32 | |
31 | # else /* __INITIAL_POINTER_SIZE == 64 */ | |
32 | # define PTR_T void * | |
33 | # endif /* __INITIAL_POINTER_SIZE == 64 [else] */ | |
34 | ||
35 | static struct items_data_st { | |
36 | short length, code; /* length is amount of bytes */ | |
37 | } items_data[] = { | |
38 | { | |
39 | 4, JPI$_BUFIO | |
40 | }, | |
41 | { | |
42 | 4, JPI$_CPUTIM | |
43 | }, | |
44 | { | |
45 | 4, JPI$_DIRIO | |
46 | }, | |
47 | { | |
48 | 8, JPI$_LOGINTIM | |
49 | }, | |
50 | { | |
51 | 4, JPI$_PAGEFLTS | |
52 | }, | |
53 | { | |
54 | 4, JPI$_PID | |
55 | }, | |
56 | { | |
57 | 4, JPI$_WSSIZE | |
58 | }, | |
59 | { | |
60 | 0, 0 | |
61 | } | |
62 | }; | |
537c9823 | 63 | |
0c61e299 | 64 | int RAND_poll(void) |
0f113f3e MC |
65 | { |
66 | long pid, iosb[2]; | |
67 | int status = 0; | |
68 | struct { | |
69 | short length, code; | |
70 | long *buffer; | |
71 | int *retlen; | |
72 | } item[32], *pitem; | |
73 | unsigned char data_buffer[256]; | |
74 | short total_length = 0; | |
75 | struct items_data_st *pitems_data; | |
73986238 | 76 | |
0f113f3e MC |
77 | pitems_data = items_data; |
78 | pitem = item; | |
73986238 | 79 | |
0f113f3e MC |
80 | /* Setup */ |
81 | while (pitems_data->length && (total_length + pitems_data->length <= 256)) { | |
82 | pitem->length = pitems_data->length; | |
83 | pitem->code = pitems_data->code; | |
84 | pitem->buffer = (long *)&data_buffer[total_length]; | |
85 | pitem->retlen = 0; | |
86 | total_length += pitems_data->length; | |
87 | pitems_data++; | |
88 | pitem ++; | |
89 | } | |
90 | pitem->length = pitem->code = 0; | |
73986238 | 91 | |
0f113f3e MC |
92 | /* |
93 | * Scan through all the processes in the system and add entropy with | |
94 | * results from the processes that were possible to look at. | |
95 | * However, view the information as only half trustable. | |
96 | */ | |
97 | pid = -1; /* search context */ | |
98 | while ((status = sys$getjpiw(0, &pid, 0, item, iosb, 0, 0)) | |
99 | != SS$_NOMOREPROC) { | |
100 | if (status == SS$_NORMAL) { | |
101 | RAND_add((PTR_T) data_buffer, total_length, total_length / 2); | |
102 | } | |
103 | } | |
104 | sys$gettim(iosb); | |
105 | RAND_add((PTR_T) iosb, sizeof(iosb), sizeof(iosb) / 2); | |
106 | return 1; | |
0c61e299 RL |
107 | } |
108 | ||
109 | #endif |