Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
2aa2a577
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
大约 1 年 前同步成功
通知
9
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2aa2a577
编写于
6月 02, 2008
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix indentation.
上级
c451bd82
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
48 deletion
+60
-48
engines/e_capi.c
engines/e_capi.c
+60
-48
未找到文件。
engines/e_capi.c
浏览文件 @
2aa2a577
...
...
@@ -235,7 +235,7 @@ static int rsa_capi_idx = -1;
static
int
dsa_capi_idx
=
-
1
;
static
int
capi_ctrl
(
ENGINE
*
e
,
int
cmd
,
long
i
,
void
*
p
,
void
(
*
f
)(
void
))
{
{
int
ret
=
1
;
CAPI_CTX
*
ctx
;
BIO
*
out
;
...
...
@@ -319,7 +319,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
BIO_free
(
out
);
return
ret
;
}
}
static
RSA_METHOD
capi_rsa_method
=
{
...
...
@@ -392,7 +392,6 @@ static int capi_init(ENGINE *e)
static
int
capi_destroy
(
ENGINE
*
e
)
{
ERR_unload_CAPI_strings
();
return
1
;
}
...
...
@@ -693,7 +692,8 @@ int capi_rsa_sign(int dtype, const unsigned char *m, unsigned int m_len,
return
-
1
;
}
/* Convert the signature type to a CryptoAPI algorithm ID */
switch
(
dtype
)
{
switch
(
dtype
)
{
case
NID_sha1
:
alg
=
CALG_SHA1
;
break
;
...
...
@@ -718,37 +718,43 @@ int capi_rsa_sign(int dtype, const unsigned char *m, unsigned int m_len,
/* Create the hash object */
if
(
!
CryptCreateHash
(
capi_key
->
hprov
,
alg
,
0
,
0
,
&
hash
))
{
if
(
!
CryptCreateHash
(
capi_key
->
hprov
,
alg
,
0
,
0
,
&
hash
))
{
CAPIerr
(
CAPI_F_CAPI_RSA_SIGN
,
CAPI_R_CANT_CREATE_HASH_OBJECT
);
capi_addlasterror
();
return
-
1
;
}
}
/* Set the hash value to the value passed */
if
(
!
CryptSetHashParam
(
hash
,
HP_HASHVAL
,
(
unsigned
char
*
)
m
,
0
))
{
if
(
!
CryptSetHashParam
(
hash
,
HP_HASHVAL
,
(
unsigned
char
*
)
m
,
0
))
{
CAPIerr
(
CAPI_F_CAPI_RSA_SIGN
,
CAPI_R_CANT_SET_HASH_VALUE
);
capi_addlasterror
();
goto
err
;
}
}
/* Finally sign it */
slen
=
RSA_size
(
rsa
);
if
(
!
CryptSignHash
(
hash
,
capi_key
->
keyspec
,
NULL
,
0
,
sigret
,
&
slen
))
{
if
(
!
CryptSignHash
(
hash
,
capi_key
->
keyspec
,
NULL
,
0
,
sigret
,
&
slen
))
{
CAPIerr
(
CAPI_F_CAPI_RSA_SIGN
,
CAPI_R_ERROR_SIGNING_HASH
);
capi_addlasterror
();
goto
err
;
}
else
{
}
else
{
ret
=
1
;
/* Inplace byte reversal of signature */
for
(
i
=
0
;
i
<
slen
/
2
;
i
++
)
{
for
(
i
=
0
;
i
<
slen
/
2
;
i
++
)
{
unsigned
char
c
;
c
=
sigret
[
i
];
sigret
[
i
]
=
sigret
[
slen
-
i
-
1
];
sigret
[
slen
-
i
-
1
]
=
c
;
}
}
*
siglen
=
slen
;
}
}
/* Now cleanup */
...
...
@@ -757,11 +763,11 @@ err:
CryptDestroyHash
(
hash
);
return
ret
;
}
}
int
capi_rsa_priv_dec
(
int
flen
,
const
unsigned
char
*
from
,
unsigned
char
*
to
,
RSA
*
rsa
,
int
padding
)
{
{
int
i
;
unsigned
char
*
tmpbuf
;
CAPI_KEY
*
capi_key
;
...
...
@@ -809,7 +815,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
OPENSSL_free
(
tmpbuf
);
return
flen
;
}
}
static
int
capi_rsa_free
(
RSA
*
rsa
)
{
...
...
@@ -851,18 +857,20 @@ static DSA_SIG *capi_dsa_do_sign(const unsigned char *digest, int dlen,
}
/* Create the hash object */
if
(
!
CryptCreateHash
(
capi_key
->
hprov
,
CALG_SHA1
,
0
,
0
,
&
hash
))
{
if
(
!
CryptCreateHash
(
capi_key
->
hprov
,
CALG_SHA1
,
0
,
0
,
&
hash
))
{
CAPIerr
(
CAPI_F_CAPI_DSA_DO_SIGN
,
CAPI_R_CANT_CREATE_HASH_OBJECT
);
capi_addlasterror
();
return
NULL
;
}
}
/* Set the hash value to the value passed */
if
(
!
CryptSetHashParam
(
hash
,
HP_HASHVAL
,
(
unsigned
char
*
)
digest
,
0
))
{
if
(
!
CryptSetHashParam
(
hash
,
HP_HASHVAL
,
(
unsigned
char
*
)
digest
,
0
))
{
CAPIerr
(
CAPI_F_CAPI_DSA_DO_SIGN
,
CAPI_R_CANT_SET_HASH_VALUE
);
capi_addlasterror
();
goto
err
;
}
}
/* Finally sign it */
...
...
@@ -1035,29 +1043,29 @@ static int capi_list_containers(CAPI_CTX *ctx, BIO *out)
for
(
idx
=
0
;;
idx
++
)
{
clen
=
buflen
;
cname
[
0
]
=
0
;
if
(
idx
==
0
)
flags
=
CRYPT_FIRST
;
else
flags
=
0
;
if
(
!
CryptGetProvParam
(
hprov
,
PP_ENUMCONTAINERS
,
cname
,
&
clen
,
flags
))
{
err
=
GetLastError
();
if
(
err
==
ERROR_NO_MORE_ITEMS
)
goto
done
;
CAPIerr
(
CAPI_F_CAPI_LIST_CONTAINERS
,
CAPI_R_ENUMCONTAINERS_ERROR
);
capi_adderror
(
err
);
goto
err
;
}
CAPI_trace
(
ctx
,
"Container name %s, len=%d, index=%d, flags=%d
\n
"
,
cname
,
clen
,
idx
,
flags
);
if
(
!
cname
[
0
]
&&
(
clen
==
buflen
))
{
CAPI_trace
(
ctx
,
"Enumerate bug: using workaround
\n
"
);
clen
=
buflen
;
cname
[
0
]
=
0
;
if
(
idx
==
0
)
flags
=
CRYPT_FIRST
;
else
flags
=
0
;
if
(
!
CryptGetProvParam
(
hprov
,
PP_ENUMCONTAINERS
,
cname
,
&
clen
,
flags
))
{
err
=
GetLastError
();
if
(
err
==
ERROR_NO_MORE_ITEMS
)
goto
done
;
}
BIO_printf
(
out
,
"%d. %s
\n
"
,
idx
,
cname
);
CAPIerr
(
CAPI_F_CAPI_LIST_CONTAINERS
,
CAPI_R_ENUMCONTAINERS_ERROR
);
capi_adderror
(
err
);
goto
err
;
}
CAPI_trace
(
ctx
,
"Container name %s, len=%d, index=%d, flags=%d
\n
"
,
cname
,
clen
,
idx
,
flags
);
if
(
!
cname
[
0
]
&&
(
clen
==
buflen
))
{
CAPI_trace
(
ctx
,
"Enumerate bug: using workaround
\n
"
);
goto
done
;
}
BIO_printf
(
out
,
"%d. %s
\n
"
,
idx
,
cname
);
}
err:
...
...
@@ -1258,8 +1266,9 @@ static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, HCERTSTORE h
switch
(
ctx
->
lookup_method
)
{
case
CAPI_LU_SUBSTR
:
return
CertFindCertificateInStore
(
hstore
,
X509_ASN_ENCODING
,
0
,
CERT_FIND_SUBJECT_STR_A
,
id
,
NULL
);
return
CertFindCertificateInStore
(
hstore
,
X509_ASN_ENCODING
,
0
,
CERT_FIND_SUBJECT_STR_A
,
id
,
NULL
);
case
CAPI_LU_FNAME
:
for
(;;)
{
...
...
@@ -1288,7 +1297,7 @@ static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const char *contname, char *provnam
CAPI_KEY
*
key
;
key
=
OPENSSL_malloc
(
sizeof
(
CAPI_KEY
));
CAPI_trace
(
ctx
,
"capi_get_key, contname=%s, provname=%s, type=%d
\n
"
,
contname
,
provname
,
ptype
);
contname
,
provname
,
ptype
);
if
(
!
CryptAcquireContext
(
&
key
->
hprov
,
contname
,
provname
,
ptype
,
0
))
{
CAPIerr
(
CAPI_F_CAPI_GET_KEY
,
CAPI_R_CRYPTACQUIRECONTEXT_ERROR
);
...
...
@@ -1323,7 +1332,8 @@ static CAPI_KEY *capi_get_cert_key(CAPI_CTX *ctx, PCCERT_CONTEXT cert)
if
(
!
provname
||
!
contname
)
return
0
;
key
=
capi_get_key
(
ctx
,
contname
,
provname
,
pinfo
->
dwProvType
,
pinfo
->
dwKeySpec
);
key
=
capi_get_key
(
ctx
,
contname
,
provname
,
pinfo
->
dwProvType
,
pinfo
->
dwKeySpec
);
err:
if
(
pinfo
)
...
...
@@ -1357,7 +1367,8 @@ CAPI_KEY *capi_find_key(CAPI_CTX *ctx, const char *id)
break
;
case
CAPI_LU_CONTNAME
:
key
=
capi_get_key
(
ctx
,
id
,
ctx
->
cspname
,
ctx
->
csptype
,
ctx
->
keytype
);
key
=
capi_get_key
(
ctx
,
id
,
ctx
->
cspname
,
ctx
->
csptype
,
ctx
->
keytype
);
break
;
}
...
...
@@ -1416,7 +1427,8 @@ static int capi_ctx_set_provname(CAPI_CTX *ctx, LPSTR pname, DWORD type, int che
if
(
check
)
{
HCRYPTPROV
hprov
;
if
(
!
CryptAcquireContext
(
&
hprov
,
NULL
,
pname
,
type
,
CRYPT_VERIFYCONTEXT
))
if
(
!
CryptAcquireContext
(
&
hprov
,
NULL
,
pname
,
type
,
CRYPT_VERIFYCONTEXT
))
{
CAPIerr
(
CAPI_F_CAPI_CTX_SET_PROVNAME
,
CAPI_R_CRYPTACQUIRECONTEXT_ERROR
);
capi_addlasterror
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录