Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
89c53672
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
89c53672
编写于
7月 21, 2004
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make rand_win.c UNICODE savvy.
上级
64ba6cf2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
41 deletion
+61
-41
crypto/rand/rand_win.c
crypto/rand/rand_win.c
+61
-41
未找到文件。
crypto/rand/rand_win.c
浏览文件 @
89c53672
...
...
@@ -125,7 +125,7 @@
* http://developer.intel.com/design/security/rng/redist_license.htm
*/
#define PROV_INTEL_SEC 22
#define INTEL_DEF_PROV
TEXT("Intel Hardware Cryptographic Service Provider")
#define INTEL_DEF_PROV
L"Intel Hardware Cryptographic Service Provider"
static
void
readtimer
(
void
);
static
void
readscreen
(
void
);
...
...
@@ -152,7 +152,7 @@ typedef struct tagCURSORINFO
#define CURSOR_SHOWING 0x00000001
#endif
/* CURSOR_SHOWING */
typedef
BOOL
(
WINAPI
*
CRYPTACQUIRECONTEXT
)(
HCRYPTPROV
*
,
LPCTSTR
,
LPCT
STR
,
typedef
BOOL
(
WINAPI
*
CRYPTACQUIRECONTEXT
W
)(
HCRYPTPROV
*
,
LPCWSTR
,
LPCW
STR
,
DWORD
,
DWORD
);
typedef
BOOL
(
WINAPI
*
CRYPTGENRANDOM
)(
HCRYPTPROV
,
DWORD
,
BYTE
*
);
typedef
BOOL
(
WINAPI
*
CRYPTRELEASECONTEXT
)(
HCRYPTPROV
,
DWORD
);
...
...
@@ -194,7 +194,7 @@ int RAND_poll(void)
HWND
h
;
HMODULE
advapi
,
kernel
,
user
,
netapi
;
CRYPTACQUIRECONTEXT
acquire
=
0
;
CRYPTACQUIRECONTEXT
W
acquire
=
0
;
CRYPTGENRANDOM
gen
=
0
;
CRYPTRELEASECONTEXT
release
=
0
;
#if 1
/* There was previously a problem with NETSTATGET. Currently, this
...
...
@@ -213,6 +213,9 @@ int RAND_poll(void)
GetVersionEx
(
&
osverinfo
)
;
#if defined(OPENSSL_SYS_WINCE) && WCEPLATFORM!=MS_HPC_PRO
#ifndef CryptAcquireContext
#define CryptAcquireContext CryptAcquireContextW
#endif
/* poll the CryptoAPI PRNG */
/* The CryptoAPI returns sizeof(buf) bytes of randomness */
if
(
CryptAcquireContext
(
&
hProvider
,
0
,
0
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
))
...
...
@@ -223,21 +226,35 @@ int RAND_poll(void)
}
#endif
#ifndef OPENSSL_SYS_WINCE
/*
* None of below libraries are present on Windows CE, which is
* why we #ifndef the whole section. This also excuses us from
* handling the GetProcAddress issue. The trouble is that in
* real Win32 API GetProcAddress is available in ANSI flavor
* only. In WinCE on the other hand GetProcAddress is a macro
* most commonly defined as GetProcAddressW, which accepts
* Unicode argument. If we were to call GetProcAddress under
* WinCE, I'd recommend to either redefine GetProcAddress as
* GetProcAddressA (there seem to be one in common CE spec) or
* implement own shim routine, which would accept ANSI argument
* and expand it to Unicode.
*/
/* load functions dynamically - not available on all systems */
advapi
=
LoadLibrary
(
TEXT
(
"ADVAPI32.DLL"
));
kernel
=
LoadLibrary
(
TEXT
(
"KERNEL32.DLL"
));
user
=
LoadLibrary
(
TEXT
(
"USER32.DLL"
));
netapi
=
LoadLibrary
(
TEXT
(
"NETAPI32.DLL"
));
#ifndef OPENSSL_SYS_WINCE
#if 1
/* There was previously a problem with NETSTATGET. Currently, this
* section is still experimental, but if all goes well, this conditional
* will be removed
*/
if
(
netapi
)
{
netstatget
=
(
NETSTATGET
)
GetProcAddress
(
netapi
,
TEXT
(
"NetStatisticsGet"
)
);
netfree
=
(
NETFREE
)
GetProcAddress
(
netapi
,
TEXT
(
"NetApiBufferFree"
)
);
netstatget
=
(
NETSTATGET
)
GetProcAddress
(
netapi
,
"NetStatisticsGet"
);
netfree
=
(
NETFREE
)
GetProcAddress
(
netapi
,
"NetApiBufferFree"
);
}
if
(
netstatget
&&
netfree
)
...
...
@@ -264,9 +281,7 @@ int RAND_poll(void)
if
(
netapi
)
FreeLibrary
(
netapi
);
#endif
/* 1 */
#endif
/* !OPENSSL_SYS_WINCE */
#ifndef OPENSSL_SYS_WINCE
/* It appears like this can cause an exception deep within ADVAPI32.DLL
* at random times on Windows 2000. Reported by Jeffrey Altman.
* Only use it on NT.
...
...
@@ -321,16 +336,20 @@ int RAND_poll(void)
free(buf);
}
#endif
#endif
/* !OPENSSL_SYS_WINCE */
if
(
advapi
)
{
acquire
=
(
CRYPTACQUIRECONTEXT
)
GetProcAddress
(
advapi
,
TEXT
(
"CryptAcquireContextA"
));
/*
* If it's available, then it's available in both ANSI
* and UNICODE flavors even in Win9x, documentation says.
* We favor Unicode...
*/
acquire
=
(
CRYPTACQUIRECONTEXTW
)
GetProcAddress
(
advapi
,
"CryptAcquireContextW"
);
gen
=
(
CRYPTGENRANDOM
)
GetProcAddress
(
advapi
,
TEXT
(
"CryptGenRandom"
)
);
"CryptGenRandom"
);
release
=
(
CRYPTRELEASECONTEXT
)
GetProcAddress
(
advapi
,
TEXT
(
"CryptReleaseContext"
)
);
"CryptReleaseContext"
);
}
if
(
acquire
&&
gen
&&
release
)
...
...
@@ -367,26 +386,15 @@ int RAND_poll(void)
if
(
advapi
)
FreeLibrary
(
advapi
);
/* timer data */
readtimer
();
/* memory usage statistics */
GlobalMemoryStatus
(
&
m
);
RAND_add
(
&
m
,
sizeof
(
m
),
1
);
/* process ID */
w
=
GetCurrentProcessId
();
RAND_add
(
&
w
,
sizeof
(
w
),
1
);
if
(
user
)
{
GETCURSORINFO
cursor
;
GETFOREGROUNDWINDOW
win
;
GETQUEUESTATUS
queue
;
win
=
(
GETFOREGROUNDWINDOW
)
GetProcAddress
(
user
,
TEXT
(
"GetForegroundWindow"
)
);
cursor
=
(
GETCURSORINFO
)
GetProcAddress
(
user
,
TEXT
(
"GetCursorInfo"
)
);
queue
=
(
GETQUEUESTATUS
)
GetProcAddress
(
user
,
TEXT
(
"GetQueueStatus"
)
);
win
=
(
GETFOREGROUNDWINDOW
)
GetProcAddress
(
user
,
"GetForegroundWindow"
);
cursor
=
(
GETCURSORINFO
)
GetProcAddress
(
user
,
"GetCursorInfo"
);
queue
=
(
GETQUEUESTATUS
)
GetProcAddress
(
user
,
"GetQueueStatus"
);
if
(
win
)
{
...
...
@@ -458,19 +466,19 @@ int RAND_poll(void)
MODULEENTRY32
m
;
snap
=
(
CREATETOOLHELP32SNAPSHOT
)
GetProcAddress
(
kernel
,
TEXT
(
"CreateToolhelp32Snapshot"
)
);
GetProcAddress
(
kernel
,
"CreateToolhelp32Snapshot"
);
close_snap
=
(
CLOSETOOLHELP32SNAPSHOT
)
GetProcAddress
(
kernel
,
TEXT
(
"CloseToolhelp32Snapshot"
)
);
heap_first
=
(
HEAP32FIRST
)
GetProcAddress
(
kernel
,
TEXT
(
"Heap32First"
)
);
heap_next
=
(
HEAP32NEXT
)
GetProcAddress
(
kernel
,
TEXT
(
"Heap32Next"
)
);
heaplist_first
=
(
HEAP32LIST
)
GetProcAddress
(
kernel
,
TEXT
(
"Heap32ListFirst"
)
);
heaplist_next
=
(
HEAP32LIST
)
GetProcAddress
(
kernel
,
TEXT
(
"Heap32ListNext"
)
);
process_first
=
(
PROCESS32
)
GetProcAddress
(
kernel
,
TEXT
(
"Process32First"
)
);
process_next
=
(
PROCESS32
)
GetProcAddress
(
kernel
,
TEXT
(
"Process32Next"
)
);
thread_first
=
(
THREAD32
)
GetProcAddress
(
kernel
,
TEXT
(
"Thread32First"
)
);
thread_next
=
(
THREAD32
)
GetProcAddress
(
kernel
,
TEXT
(
"Thread32Next"
)
);
module_first
=
(
MODULE32
)
GetProcAddress
(
kernel
,
TEXT
(
"Module32First"
)
);
module_next
=
(
MODULE32
)
GetProcAddress
(
kernel
,
TEXT
(
"Module32Next"
)
);
GetProcAddress
(
kernel
,
"CloseToolhelp32Snapshot"
);
heap_first
=
(
HEAP32FIRST
)
GetProcAddress
(
kernel
,
"Heap32First"
);
heap_next
=
(
HEAP32NEXT
)
GetProcAddress
(
kernel
,
"Heap32Next"
);
heaplist_first
=
(
HEAP32LIST
)
GetProcAddress
(
kernel
,
"Heap32ListFirst"
);
heaplist_next
=
(
HEAP32LIST
)
GetProcAddress
(
kernel
,
"Heap32ListNext"
);
process_first
=
(
PROCESS32
)
GetProcAddress
(
kernel
,
"Process32First"
);
process_next
=
(
PROCESS32
)
GetProcAddress
(
kernel
,
"Process32Next"
);
thread_first
=
(
THREAD32
)
GetProcAddress
(
kernel
,
"Thread32First"
);
thread_next
=
(
THREAD32
)
GetProcAddress
(
kernel
,
"Thread32Next"
);
module_first
=
(
MODULE32
)
GetProcAddress
(
kernel
,
"Module32First"
);
module_next
=
(
MODULE32
)
GetProcAddress
(
kernel
,
"Module32Next"
);
if
(
snap
&&
heap_first
&&
heap_next
&&
heaplist_first
&&
heaplist_next
&&
process_first
&&
process_next
&&
...
...
@@ -546,6 +554,18 @@ int RAND_poll(void)
FreeLibrary
(
kernel
);
}
#endif
/* !OPENSSL_SYS_WINCE */
/* timer data */
readtimer
();
/* memory usage statistics */
GlobalMemoryStatus
(
&
m
);
RAND_add
(
&
m
,
sizeof
(
m
),
1
);
/* process ID */
w
=
GetCurrentProcessId
();
RAND_add
(
&
w
,
sizeof
(
w
),
1
);
#if 0
printf("Exiting RAND_poll\n");
...
...
@@ -607,7 +627,7 @@ static void readtimer(void)
DWORD
w
;
LARGE_INTEGER
l
;
static
int
have_perfc
=
1
;
#if defined(_MSC_VER) &&
!defined(OPENSSL_SYS_WINCE
)
#if defined(_MSC_VER) &&
defined(_M_X86
)
static
int
have_tsc
=
1
;
DWORD
cyclecount
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录