]>
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 | ||
da8fc25a | 10 | #include "e_os.h" |
0c61e299 | 11 | |
bc36ee62 | 12 | #if defined(OPENSSL_SYS_VMS) |
da8fc25a RS |
13 | # include <openssl/rand.h> |
14 | # include "rand_lcl.h" | |
0f113f3e MC |
15 | # include <descrip.h> |
16 | # include <jpidef.h> | |
17 | # include <ssdef.h> | |
18 | # include <starlet.h> | |
5fc2c689 | 19 | # include <efndef> |
0f113f3e MC |
20 | # ifdef __DECC |
21 | # pragma message disable DOLLARID | |
22 | # endif | |
0c61e299 | 23 | |
0f113f3e MC |
24 | /* |
25 | * Use 32-bit pointers almost everywhere. Define the type to which to cast a | |
26 | * pointer passed to an external function. | |
537c9823 | 27 | */ |
0f113f3e MC |
28 | # if __INITIAL_POINTER_SIZE == 64 |
29 | # define PTR_T __void_ptr64 | |
30 | # pragma pointer_size save | |
31 | # pragma pointer_size 32 | |
da8fc25a | 32 | # else |
0f113f3e | 33 | # define PTR_T void * |
da8fc25a | 34 | # endif |
0f113f3e MC |
35 | |
36 | static struct items_data_st { | |
5fc2c689 | 37 | short length, code; /* length is number of bytes */ |
0f113f3e | 38 | } items_data[] = { |
5fc2c689 RL |
39 | {4, JPI$_BUFIO}, |
40 | {4, JPI$_CPUTIM}, | |
41 | {4, JPI$_DIRIO}, | |
42 | {4, JPI$_IMAGECOUNT}, | |
43 | {8, JPI$_LAST_LOGIN_I}, | |
44 | {8, JPI$_LOGINTIM}, | |
45 | {4, JPI$_PAGEFLTS}, | |
46 | {4, JPI$_PID}, | |
47 | {4, JPI$_PPGCNT}, | |
48 | {4, JPI$_WSPEAK}, | |
49 | {4, JPI$_FINALEXC}, | |
da8fc25a | 50 | {0, 0} |
0f113f3e | 51 | }; |
537c9823 | 52 | |
0c61e299 | 53 | int RAND_poll(void) |
0f113f3e | 54 | { |
5fc2c689 | 55 | /* determine the number of items in the JPI array */ |
5fc2c689 | 56 | struct items_data_st item_entry; |
da8fc25a | 57 | int item_entry_count = OSSL_NELEM(items_data); |
5fc2c689 | 58 | /* Create the JPI itemlist array to hold item_data content */ |
0f113f3e MC |
59 | struct { |
60 | short length, code; | |
5fc2c689 | 61 | int *buffer; |
0f113f3e | 62 | int *retlen; |
da8fc25a | 63 | } item[item_entry_count], *pitem; |
0f113f3e | 64 | struct items_data_st *pitems_data; |
da8fc25a | 65 | int data_buffer[(item_entry_count * 2) + 4]; /* 8 bytes per entry max */ |
5fc2c689 RL |
66 | int iosb[2]; |
67 | int sys_time[2]; | |
68 | int *ptr; | |
69 | int i, j ; | |
70 | int tmp_length = 0; | |
71 | int total_length = 0; | |
73986238 | 72 | |
5fc2c689 | 73 | /* Setup itemlist for GETJPI */ |
da8fc25a RS |
74 | pitems_data = items_data; |
75 | for (pitem = item; pitems_data->length != 0; pitem++) { | |
0f113f3e | 76 | pitem->length = pitems_data->length; |
5fc2c689 RL |
77 | pitem->code = pitems_data->code; |
78 | pitem->buffer = &data_buffer[total_length]; | |
0f113f3e | 79 | pitem->retlen = 0; |
5fc2c689 | 80 | /* total_length is in longwords */ |
da8fc25a | 81 | total_length += pitems_data->length / 4; |
0f113f3e | 82 | pitems_data++; |
0f113f3e MC |
83 | } |
84 | pitem->length = pitem->code = 0; | |
73986238 | 85 | |
5fc2c689 | 86 | /* Fill data_buffer with various info bits from this process */ |
da8fc25a RS |
87 | if (sys$getjpiw(EFN$C_ENF, NULL, NULL, item, &iosb, 0, 0) != SS$_NORMAL) |
88 | return 0; | |
5fc2c689 | 89 | |
da8fc25a RS |
90 | /* Now twist that data to seed the SSL random number init */ |
91 | for (i = 0; i < total_length; i++) { | |
92 | sys$gettim((struct _generic_64 *)&sys_time[0]); | |
93 | srand(sys_time[0] * data_buffer[0] * data_buffer[1] + i); | |
5fc2c689 | 94 | |
da8fc25a RS |
95 | if (i == (total_length - 1)) { /* for JPI$_FINALEXC */ |
96 | ptr = &data_buffer[i]; | |
97 | for (j = 0; j < 4; j++) { | |
98 | data_buffer[i + j] = ptr[j]; | |
5fc2c689 | 99 | /* OK to use rand() just to scramble the seed */ |
da8fc25a RS |
100 | data_buffer[i + j] ^= (sys_time[0] ^ rand()); |
101 | tmp_length++; | |
5fc2c689 | 102 | } |
da8fc25a RS |
103 | } else { |
104 | /* OK to use rand() just to scramble the seed */ | |
105 | data_buffer[i] ^= (sys_time[0] ^ rand()); | |
0f113f3e MC |
106 | } |
107 | } | |
5fc2c689 | 108 | |
da8fc25a RS |
109 | total_length += (tmp_length - 1); |
110 | ||
111 | /* size of seed is total_length*4 bytes (64bytes) */ | |
112 | RAND_add((PTR_T)data_buffer, total_length * 4, total_length * 2); | |
0f113f3e | 113 | return 1; |
0c61e299 RL |
114 | } |
115 | ||
116 | #endif |