Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: openssl/crypto/rand/rand_os2.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/crypto/rand/rand_nw.c ('k') | openssl/crypto/rand/rand_unix.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/rand/rand_os2.c */ 1 /* crypto/rand/rand_os2.c */
2 /* ==================================================================== 2 /* ====================================================================
3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ULONG ulTimeLow; /* Low 32 bits of time stamp */ 71 ULONG ulTimeLow; /* Low 32 bits of time stamp */
72 ULONG ulTimeHigh; /* High 32 bits of time stamp */ 72 ULONG ulTimeHigh; /* High 32 bits of time stamp */
73 ULONG ulIdleLow; /* Low 32 bits of idle time */ 73 ULONG ulIdleLow; /* Low 32 bits of idle time */
74 ULONG ulIdleHigh; /* High 32 bits of idle time */ 74 ULONG ulIdleHigh; /* High 32 bits of idle time */
75 ULONG ulBusyLow; /* Low 32 bits of busy time */ 75 ULONG ulBusyLow; /* Low 32 bits of busy time */
76 ULONG ulBusyHigh; /* High 32 bits of busy time */ 76 ULONG ulBusyHigh; /* High 32 bits of busy time */
77 ULONG ulIntrLow; /* Low 32 bits of interrupt time */ 77 ULONG ulIntrLow; /* Low 32 bits of interrupt time */
78 ULONG ulIntrHigh; /* High 32 bits of interrupt time */ 78 ULONG ulIntrHigh; /* High 32 bits of interrupt time */
79 } CPUUTIL; 79 } CPUUTIL;
80 80
81 #ifndef __KLIBC__
81 APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; 82 APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL;
82 APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _re s_, PVOID buf, ULONG bufsz) = NULL; 83 APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _re s_, PVOID buf, ULONG bufsz) = NULL;
84 #endif
83 HMODULE hDoscalls = 0; 85 HMODULE hDoscalls = 0;
84 86
85 int RAND_poll(void) 87 int RAND_poll(void)
86 { 88 {
87 char failed_module[20]; 89 char failed_module[20];
88 QWORD qwTime; 90 QWORD qwTime;
89 ULONG SysVars[QSV_FOREGROUND_PROCESS]; 91 ULONG SysVars[QSV_FOREGROUND_PROCESS];
90 92
91 if (hDoscalls == 0) { 93 if (hDoscalls == 0) {
92 ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS ", &hDoscalls); 94 ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS ", &hDoscalls);
93 95
96 #ifndef __KLIBC__
94 if (rc == 0) { 97 if (rc == 0) {
95 rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); 98 rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall);
96 99
97 if (rc) 100 if (rc)
98 DosPerfSysCall = NULL; 101 DosPerfSysCall = NULL;
99 102
100 rc = DosQueryProcAddr(hDoscalls, 368, NULL, (PFN *)&DosQuerySysState ); 103 rc = DosQueryProcAddr(hDoscalls, 368, NULL, (PFN *)&DosQuerySysState );
101 104
102 if (rc) 105 if (rc)
103 DosQuerySysState = NULL; 106 DosQuerySysState = NULL;
104 } 107 }
108 #endif
105 } 109 }
106 110
107 /* Sample the hi-res timer, runs at around 1.1 MHz */ 111 /* Sample the hi-res timer, runs at around 1.1 MHz */
108 DosTmrQueryTime(&qwTime); 112 DosTmrQueryTime(&qwTime);
109 RAND_add(&qwTime, sizeof(qwTime), 2); 113 RAND_add(&qwTime, sizeof(qwTime), 2);
110 114
111 /* Sample a bunch of system variables, includes various process & memory sta tistics */ 115 /* Sample a bunch of system variables, includes various process & memory sta tistics */
112 DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars)); 116 DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars));
113 RAND_add(SysVars, sizeof(SysVars), 4); 117 RAND_add(SysVars, sizeof(SysVars), 4);
114 118
115 /* If available, sample CPU registers that count at CPU MHz 119 /* If available, sample CPU registers that count at CPU MHz
116 * Only fairly new CPUs (PPro & K6 onwards) & OS/2 versions support this 120 * Only fairly new CPUs (PPro & K6 onwards) & OS/2 versions support this
117 */ 121 */
118 if (DosPerfSysCall) { 122 if (DosPerfSysCall) {
119 CPUUTIL util; 123 CPUUTIL util;
120 124
121 if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) { 125 if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) {
122 RAND_add(&util, sizeof(util), 10); 126 RAND_add(&util, sizeof(util), 10);
123 } 127 }
124 else { 128 else {
129 #ifndef __KLIBC__
125 DosPerfSysCall = NULL; 130 DosPerfSysCall = NULL;
131 #endif
126 } 132 }
127 } 133 }
128 134
129 /* DosQuerySysState() gives us a huge quantity of process, thread, memory & handle stats */ 135 /* DosQuerySysState() gives us a huge quantity of process, thread, memory & handle stats */
130 if (DosQuerySysState) { 136 if (DosQuerySysState) {
131 char *buffer = OPENSSL_malloc(256 * 1024); 137 char *buffer = OPENSSL_malloc(256 * 1024);
132 138
133 if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) { 139 if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) {
134 /* First 4 bytes in buffer is a pointer to the thread count 140 /* First 4 bytes in buffer is a pointer to the thread count
135 * there should be at least 1 byte of entropy per thread 141 * there should be at least 1 byte of entropy per thread
136 */ 142 */
137 RAND_add(buffer, 256 * 1024, **(ULONG **)buffer); 143 RAND_add(buffer, 256 * 1024, **(ULONG **)buffer);
138 } 144 }
139 145
140 OPENSSL_free(buffer); 146 OPENSSL_free(buffer);
141 return 1; 147 return 1;
142 } 148 }
143 149
144 return 0; 150 return 0;
145 } 151 }
146 152
147 #endif /* OPENSSL_SYS_OS2 */ 153 #endif /* OPENSSL_SYS_OS2 */
OLDNEW
« no previous file with comments | « openssl/crypto/rand/rand_nw.c ('k') | openssl/crypto/rand/rand_unix.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698