Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
5de603ab
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,发现更多精彩内容 >>
提交
5de603ab
编写于
5月 16, 2000
作者:
B
Ben Laurie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Typesafety Thought Police part 3.
上级
f2716dad
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
64 addition
and
53 deletion
+64
-53
apps/pkcs12.c
apps/pkcs12.c
+10
-9
crypto/asn1/p7_lib.c
crypto/asn1/p7_lib.c
+2
-0
crypto/pkcs12/p12_crt.c
crypto/pkcs12/p12_crt.c
+5
-4
crypto/pkcs12/p12_decr.c
crypto/pkcs12/p12_decr.c
+2
-0
crypto/pkcs12/p12_kiss.c
crypto/pkcs12/p12_kiss.c
+7
-6
crypto/pkcs12/p12_npas.c
crypto/pkcs12/p12_npas.c
+9
-9
crypto/pkcs12/pkcs12.h
crypto/pkcs12/pkcs12.h
+3
-25
crypto/pkcs7/pkcs7.h
crypto/pkcs7/pkcs7.h
+4
-0
crypto/x509/x509.h
crypto/x509/x509.h
+22
-0
未找到文件。
apps/pkcs12.c
浏览文件 @
5de603ab
...
...
@@ -362,7 +362,7 @@ int MAIN(int argc, char **argv)
if
(
export_cert
)
{
EVP_PKEY
*
key
;
STACK_OF
(
PKCS12_SAFEBAG
)
*
bags
;
STACK
*
safes
;
STACK
_OF
(
PKCS7
)
*
safes
;
PKCS12_SAFEBAG
*
bag
;
PKCS8_PRIV_KEY_INFO
*
p8
;
PKCS7
*
authsafe
;
...
...
@@ -468,8 +468,8 @@ int MAIN(int argc, char **argv)
goto
end
;
}
safes
=
sk_new
(
NULL
);
sk_
push
(
safes
,
(
char
*
)
authsafe
);
safes
=
sk_
PKCS7_
new
(
NULL
);
sk_
PKCS7_push
(
safes
,
authsafe
);
/* Make a shrouded key bag */
p8
=
EVP_PKEY2PKCS8
(
key
);
...
...
@@ -484,13 +484,13 @@ int MAIN(int argc, char **argv)
/* Turn it into unencrypted safe bag */
authsafe
=
PKCS12_pack_p7data
(
bags
);
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
sk_
push
(
safes
,
(
char
*
)
authsafe
);
sk_
PKCS7_push
(
safes
,
authsafe
);
p12
=
PKCS12_init
(
NID_pkcs7_data
);
M_PKCS12_pack_authsafes
(
p12
,
safes
);
sk_
pop_free
(
safes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
safes
,
PKCS7_free
);
PKCS12_set_mac
(
p12
,
mpass
,
-
1
,
NULL
,
0
,
maciter
,
NULL
);
...
...
@@ -573,13 +573,14 @@ int MAIN(int argc, char **argv)
int
dump_certs_keys_p12
(
BIO
*
out
,
PKCS12
*
p12
,
char
*
pass
,
int
passlen
,
int
options
,
char
*
pempass
)
{
STACK
*
asafes
;
STACK
_OF
(
PKCS7
)
*
asafes
;
STACK_OF
(
PKCS12_SAFEBAG
)
*
bags
;
int
i
,
bagnid
;
PKCS7
*
p7
;
if
(
!
(
asafes
=
M_PKCS12_unpack_authsafes
(
p12
)))
return
0
;
for
(
i
=
0
;
i
<
sk_num
(
asafes
);
i
++
)
{
p7
=
(
PKCS7
*
)
sk
_value
(
asafes
,
i
);
for
(
i
=
0
;
i
<
sk_
PKCS7_
num
(
asafes
);
i
++
)
{
p7
=
sk_PKCS7
_value
(
asafes
,
i
);
bagnid
=
OBJ_obj2nid
(
p7
->
type
);
if
(
bagnid
==
NID_pkcs7_data
)
{
bags
=
M_PKCS12_unpack_p7data
(
p7
);
...
...
@@ -600,7 +601,7 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
}
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
}
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
1
;
}
...
...
crypto/asn1/p7_lib.c
浏览文件 @
5de603ab
...
...
@@ -293,3 +293,5 @@ void PKCS7_content_free(PKCS7 *a)
a
->
d
.
ptr
=
NULL
;
}
IMPLEMENT_STACK_OF
(
PKCS7
)
IMPLEMENT_ASN1_SET_OF
(
PKCS7
)
crypto/pkcs12/p12_crt.c
浏览文件 @
5de603ab
...
...
@@ -66,7 +66,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
{
PKCS12
*
p12
;
STACK_OF
(
PKCS12_SAFEBAG
)
*
bags
;
STACK
*
safes
;
STACK
_OF
(
PKCS7
)
*
safes
;
PKCS12_SAFEBAG
*
bag
;
PKCS8_PRIV_KEY_INFO
*
p8
;
PKCS7
*
authsafe
;
...
...
@@ -121,7 +121,8 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
if
(
!
authsafe
)
return
NULL
;
if
(
!
(
safes
=
sk_new
(
NULL
))
||
!
sk_push
(
safes
,
(
char
*
)
authsafe
))
{
if
(
!
(
safes
=
sk_PKCS7_new
(
NULL
))
||
!
sk_PKCS7_push
(
safes
,
authsafe
))
{
PKCS12err
(
PKCS12_F_PKCS12_CREATE
,
ERR_R_MALLOC_FAILURE
);
return
NULL
;
}
...
...
@@ -142,7 +143,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
/* Turn it into unencrypted safe bag */
if
(
!
(
authsafe
=
PKCS12_pack_p7data
(
bags
)))
return
NULL
;
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
if
(
!
sk_
push
(
safes
,
(
char
*
)
authsafe
))
{
if
(
!
sk_
PKCS7_push
(
safes
,
authsafe
))
{
PKCS12err
(
PKCS12_F_PKCS12_CREATE
,
ERR_R_MALLOC_FAILURE
);
return
NULL
;
}
...
...
@@ -151,7 +152,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
if
(
!
M_PKCS12_pack_authsafes
(
p12
,
safes
))
return
NULL
;
sk_
pop_free
(
safes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
safes
,
PKCS7_free
);
if
(
!
PKCS12_set_mac
(
p12
,
pass
,
-
1
,
NULL
,
0
,
mac_iter
,
NULL
))
return
NULL
;
...
...
crypto/pkcs12/p12_decr.c
浏览文件 @
5de603ab
...
...
@@ -183,3 +183,5 @@ ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(),
Free
(
in
);
return
oct
;
}
IMPLEMENT_PKCS12_STACK_OF
(
PKCS7
)
crypto/pkcs12/p12_kiss.c
浏览文件 @
5de603ab
...
...
@@ -147,15 +147,16 @@ int PKCS12_parse (PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
static
int
parse_pk12
(
PKCS12
*
p12
,
const
char
*
pass
,
int
passlen
,
EVP_PKEY
**
pkey
,
X509
**
cert
,
STACK_OF
(
X509
)
**
ca
)
{
STACK
*
asafes
;
STACK
_OF
(
PKCS7
)
*
asafes
;
STACK_OF
(
PKCS12_SAFEBAG
)
*
bags
;
int
i
,
bagnid
;
PKCS7
*
p7
;
ASN1_OCTET_STRING
*
keyid
=
NULL
;
char
keymatch
=
0
;
if
(
!
(
asafes
=
M_PKCS12_unpack_authsafes
(
p12
)))
return
0
;
for
(
i
=
0
;
i
<
sk_num
(
asafes
);
i
++
)
{
p7
=
(
PKCS7
*
)
sk
_value
(
asafes
,
i
);
for
(
i
=
0
;
i
<
sk_
PKCS7_
num
(
asafes
);
i
++
)
{
p7
=
sk_PKCS7
_value
(
asafes
,
i
);
bagnid
=
OBJ_obj2nid
(
p7
->
type
);
if
(
bagnid
==
NID_pkcs7_data
)
{
bags
=
M_PKCS12_unpack_p7data
(
p7
);
...
...
@@ -163,18 +164,18 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen,
bags
=
M_PKCS12_unpack_p7encdata
(
p7
,
pass
,
passlen
);
}
else
continue
;
if
(
!
bags
)
{
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
0
;
}
if
(
!
parse_bags
(
bags
,
pass
,
passlen
,
pkey
,
cert
,
ca
,
&
keyid
,
&
keymatch
))
{
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
0
;
}
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
}
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
if
(
keyid
)
M_ASN1_OCTET_STRING_free
(
keyid
);
return
1
;
}
...
...
crypto/pkcs12/p12_npas.c
浏览文件 @
5de603ab
...
...
@@ -105,7 +105,7 @@ return 1;
static
int
newpass_p12
(
PKCS12
*
p12
,
char
*
oldpass
,
char
*
newpass
)
{
STACK
*
asafes
,
*
newsafes
;
STACK
_OF
(
PKCS7
)
*
asafes
,
*
newsafes
;
STACK_OF
(
PKCS12_SAFEBAG
)
*
bags
;
int
i
,
bagnid
,
pbe_nid
,
pbe_iter
,
pbe_saltlen
;
PKCS7
*
p7
,
*
p7new
;
...
...
@@ -114,9 +114,9 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
unsigned
int
maclen
;
if
(
!
(
asafes
=
M_PKCS12_unpack_authsafes
(
p12
)))
return
0
;
if
(
!
(
newsafes
=
sk_new
(
NULL
)))
return
0
;
for
(
i
=
0
;
i
<
sk_num
(
asafes
);
i
++
)
{
p7
=
(
PKCS7
*
)
sk
_value
(
asafes
,
i
);
if
(
!
(
newsafes
=
sk_
PKCS7_
new
(
NULL
)))
return
0
;
for
(
i
=
0
;
i
<
sk_
PKCS7_
num
(
asafes
);
i
++
)
{
p7
=
sk_PKCS7
_value
(
asafes
,
i
);
bagnid
=
OBJ_obj2nid
(
p7
->
type
);
if
(
bagnid
==
NID_pkcs7_data
)
{
bags
=
M_PKCS12_unpack_p7data
(
p7
);
...
...
@@ -126,12 +126,12 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
&
pbe_nid
,
&
pbe_iter
,
&
pbe_saltlen
);
}
else
continue
;
if
(
!
bags
)
{
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
0
;
}
if
(
!
newpass_bags
(
bags
,
oldpass
,
newpass
))
{
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
0
;
}
/* Repack bag in same form with new password */
...
...
@@ -140,12 +140,12 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
pbe_saltlen
,
pbe_iter
,
bags
);
sk_PKCS12_SAFEBAG_pop_free
(
bags
,
PKCS12_SAFEBAG_free
);
if
(
!
p7new
)
{
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
return
0
;
}
sk_
push
(
newsafes
,
(
char
*
)
p7new
);
sk_
PKCS7_push
(
newsafes
,
p7new
);
}
sk_
pop_free
(
asafes
,
(
void
(
*
)(
void
*
))
PKCS7_free
);
sk_
PKCS7_pop_free
(
asafes
,
PKCS7_free
);
/* Repack safe: save old safe in case of error */
...
...
crypto/pkcs12/pkcs12.h
浏览文件 @
5de603ab
...
...
@@ -66,27 +66,6 @@
extern
"C"
{
#endif
#define DECLARE_PKCS12_STACK_OF(type) \
STACK_OF(type) *PKCS12_decrypt_d2i_##type(struct X509_algor_st *algor, \
type *(*d2i)(type **, \
unsigned char **, \
long), \
void (*free_func)(type *), \
const char *pass, int passlen, \
ASN1_STRING *oct, int seq);
#define IMPLEMENT_PKCS12_STACK_OF(type) \
STACK_OF(type) *PKCS12_decrypt_d2i_##type(struct X509_algor_st *algor, \
type *(*d2i)(type **, \
unsigned char **, \
long), \
void (*free_func)(type *), \
const char *pass, int passlen, \
ASN1_STRING *oct, int seq) \
{ return (STACK_OF(type) *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i, \
(void(*)(void *))free_func, \
pass,passlen,oct,seq); }
#define PKCS12_KEY_ID 1
#define PKCS12_IV_ID 2
#define PKCS12_MAC_ID 3
...
...
@@ -188,13 +167,12 @@ ASN1_seq_unpack_PKCS12_SAFEBAG ((p7)->d.data->data, p7->d.data->length, \
d2i_PKCS12_SAFEBAG, PKCS12_SAFEBAG_free)
#define M_PKCS12_pack_authsafes(p12, safes) \
ASN1_seq_pack
((safes), (int (*)())
i2d_PKCS7,\
ASN1_seq_pack
_PKCS7((safes),
i2d_PKCS7,\
&(p12)->authsafes->d.data->data, &(p12)->authsafes->d.data->length)
#define M_PKCS12_unpack_authsafes(p12) \
ASN1_seq_unpack((p12)->authsafes->d.data->data, \
(p12)->authsafes->d.data->length, (char *(*)())d2i_PKCS7, \
PKCS7_free)
ASN1_seq_unpack_PKCS7((p12)->authsafes->d.data->data, \
(p12)->authsafes->d.data->length, d2i_PKCS7, PKCS7_free)
#define M_PKCS12_unpack_p7encdata(p7, pass, passlen) \
PKCS12_decrypt_d2i_PKCS12_SAFEBAG ((p7)->d.encrypted->enc_data->algorithm,\
...
...
crypto/pkcs7/pkcs7.h
浏览文件 @
5de603ab
...
...
@@ -213,6 +213,10 @@ typedef struct pkcs7_st
}
d
;
}
PKCS7
;
DECLARE_STACK_OF
(
PKCS7
)
DECLARE_ASN1_SET_OF
(
PKCS7
)
DECLARE_PKCS12_STACK_OF
(
PKCS7
)
#define PKCS7_OP_SET_DETACHED_SIGNATURE 1
#define PKCS7_OP_GET_DETACHED_SIGNATURE 2
...
...
crypto/x509/x509.h
浏览文件 @
5de603ab
...
...
@@ -92,6 +92,28 @@ extern "C" {
#undef X509_NAME
#endif
/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
#define DECLARE_PKCS12_STACK_OF(type) \
STACK_OF(type) *PKCS12_decrypt_d2i_##type(struct X509_algor_st *algor, \
type *(*d2i)(type **, \
unsigned char **, \
long), \
void (*free_func)(type *), \
const char *pass, int passlen, \
ASN1_STRING *oct, int seq);
#define IMPLEMENT_PKCS12_STACK_OF(type) \
STACK_OF(type) *PKCS12_decrypt_d2i_##type(struct X509_algor_st *algor, \
type *(*d2i)(type **, \
unsigned char **, \
long), \
void (*free_func)(type *), \
const char *pass, int passlen, \
ASN1_STRING *oct, int seq) \
{ return (STACK_OF(type) *)PKCS12_decrypt_d2i(algor,(char *(*)())d2i, \
(void(*)(void *))free_func, \
pass,passlen,oct,seq); }
#define X509_FILETYPE_PEM 1
#define X509_FILETYPE_ASN1 2
#define X509_FILETYPE_DEFAULT 3
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录