Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
095ce353
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,发现更多精彩内容 >>
提交
095ce353
编写于
6月 05, 1999
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change so PEM private key read routines can handle PKCS#8 transparently.
上级
e7871ffa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
6 deletion
+35
-6
crypto/pem/pem_lib.c
crypto/pem/pem_lib.c
+35
-6
未找到文件。
crypto/pem/pem_lib.c
浏览文件 @
095ce353
...
...
@@ -64,6 +64,7 @@
#include <openssl/rand.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/pkcs12.h>
#ifndef NO_DES
#include <openssl/des.h>
#endif
...
...
@@ -71,6 +72,7 @@
const
char
*
PEM_version
=
"PEM"
OPENSSL_VERSION_PTEXT
;
#define MIN_LENGTH 4
#define PEM_BUFSIZE 1024
static
int
def_callback
(
char
*
buf
,
int
num
,
int
w
);
static
int
load_iv
(
unsigned
char
**
fromp
,
unsigned
char
*
to
,
int
num
);
...
...
@@ -183,10 +185,14 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
))
||
((
strcmp
(
nm
,
PEM_STRING_DSA
)
==
0
)
&&
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
))
||
((
strcmp
(
nm
,
PEM_STRING_PKCS8
)
==
0
)
&&
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
))
||
((
strcmp
(
nm
,
PEM_STRING_PKCS8INF
)
==
0
)
&&
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
))
||
((
strcmp
(
nm
,
PEM_STRING_X509_OLD
)
==
0
)
&&
(
strcmp
(
name
,
PEM_STRING_X509
)
==
0
))
||
((
strcmp
(
nm
,
PEM_STRING_X509_REQ_OLD
)
==
0
)
&&
(
strcmp
(
name
,
PEM_STRING_X509_REQ
)
==
0
))
(
strcmp
(
name
,
PEM_STRING_X509_REQ
)
==
0
))
)
break
;
Free
(
nm
);
...
...
@@ -196,15 +202,39 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
if
(
!
PEM_get_EVP_CIPHER_INFO
(
header
,
&
cipher
))
goto
err
;
if
(
!
PEM_do_header
(
&
cipher
,
data
,
&
len
,
cb
))
goto
err
;
p
=
data
;
if
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
)
{
if
(
strcmp
(
name
,
PEM_STRING_EVP_PKEY
)
==
0
)
{
if
(
strcmp
(
nm
,
PEM_STRING_RSA
)
==
0
)
ret
=
d2i
(
EVP_PKEY_RSA
,
x
,
&
p
,
len
);
else
if
(
strcmp
(
nm
,
PEM_STRING_DSA
)
==
0
)
ret
=
d2i
(
EVP_PKEY_DSA
,
x
,
&
p
,
len
);
else
if
(
strcmp
(
nm
,
PEM_STRING_PKCS8INF
)
==
0
)
{
PKCS8_PRIV_KEY_INFO
*
p8inf
;
p8inf
=
d2i_PKCS8_PRIV_KEY_INFO
(
(
PKCS8_PRIV_KEY_INFO
**
)
x
,
&
p
,
len
);
ret
=
(
char
*
)
EVP_PKCS82PKEY
(
p8inf
);
PKCS8_PRIV_KEY_INFO_free
(
p8inf
);
}
else
if
(
strcmp
(
nm
,
PEM_STRING_PKCS8
)
==
0
)
{
PKCS8_PRIV_KEY_INFO
*
p8inf
;
X509_SIG
*
p8
;
int
klen
;
char
psbuf
[
PEM_BUFSIZE
];
p8
=
d2i_X509_SIG
((
X509_SIG
**
)
x
,
&
p
,
len
);
if
(
!
p8
)
goto
p8err
;
if
(
cb
)
klen
=
cb
(
psbuf
,
PEM_BUFSIZE
,
0
);
else
klen
=
def_callback
(
psbuf
,
PEM_BUFSIZE
,
0
);
if
(
klen
<=
0
)
{
PEMerr
(
PEM_F_PEM_ASN1_READ_BIO
,
PEM_R_BAD_PASSWORD_READ
);
goto
err
;
}
p8inf
=
M_PKCS8_decrypt
(
p8
,
psbuf
,
klen
);
X509_SIG_free
(
p8
);
if
(
!
p8inf
)
goto
p8err
;
ret
=
(
char
*
)
EVP_PKCS82PKEY
(
p8inf
);
PKCS8_PRIV_KEY_INFO_free
(
p8inf
);
}
else
ret
=
d2i
(
x
,
&
p
,
len
);
}
else
ret
=
d2i
(
x
,
&
p
,
len
);
p8err:
if
(
ret
==
NULL
)
PEMerr
(
PEM_F_PEM_ASN1_READ_BIO
,
ERR_R_ASN1_LIB
);
err:
...
...
@@ -242,7 +272,6 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
int
dsize
=
0
,
i
,
j
,
ret
=
0
;
unsigned
char
*
p
,
*
data
=
NULL
;
const
char
*
objstr
=
NULL
;
#define PEM_BUFSIZE 1024
char
buf
[
PEM_BUFSIZE
];
unsigned
char
key
[
EVP_MAX_KEY_LENGTH
];
unsigned
char
iv
[
EVP_MAX_IV_LENGTH
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录