Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
7f57b076
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看板
提交
7f57b076
编写于
5月 11, 2006
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New functions to get key types without dereferncing EVP_PKEY.
More error checking for RSA pmeth.
上级
7144c421
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
5 deletion
+46
-5
crypto/evp/evp.h
crypto/evp/evp.h
+2
-0
crypto/evp/p_lib.c
crypto/evp/p_lib.c
+10
-0
crypto/rsa/rsa.h
crypto/rsa/rsa.h
+6
-0
crypto/rsa/rsa_err.c
crypto/rsa/rsa_err.c
+6
-0
crypto/rsa/rsa_pmeth.c
crypto/rsa/rsa_pmeth.c
+22
-5
未找到文件。
crypto/evp/evp.h
浏览文件 @
7f57b076
...
@@ -717,6 +717,8 @@ int EVP_PKEY_encrypt_old(unsigned char *enc_key,
...
@@ -717,6 +717,8 @@ int EVP_PKEY_encrypt_old(unsigned char *enc_key,
const
unsigned
char
*
key
,
int
key_len
,
const
unsigned
char
*
key
,
int
key_len
,
EVP_PKEY
*
pub_key
);
EVP_PKEY
*
pub_key
);
int
EVP_PKEY_type
(
int
type
);
int
EVP_PKEY_type
(
int
type
);
int
EVP_PKEY_id
(
const
EVP_PKEY
*
pkey
);
int
EVP_PKEY_base_id
(
const
EVP_PKEY
*
pkey
);
int
EVP_PKEY_bits
(
EVP_PKEY
*
pkey
);
int
EVP_PKEY_bits
(
EVP_PKEY
*
pkey
);
int
EVP_PKEY_size
(
EVP_PKEY
*
pkey
);
int
EVP_PKEY_size
(
EVP_PKEY
*
pkey
);
int
EVP_PKEY_assign
(
EVP_PKEY
*
pkey
,
int
type
,
void
*
key
);
int
EVP_PKEY_assign
(
EVP_PKEY
*
pkey
,
int
type
,
void
*
key
);
...
...
crypto/evp/p_lib.c
浏览文件 @
7f57b076
...
@@ -297,6 +297,16 @@ int EVP_PKEY_type(int type)
...
@@ -297,6 +297,16 @@ int EVP_PKEY_type(int type)
return
NID_undef
;
return
NID_undef
;
}
}
int
EVP_PKEY_id
(
const
EVP_PKEY
*
pkey
)
{
return
pkey
->
type
;
}
int
EVP_PKEY_base_id
(
const
EVP_PKEY
*
pkey
)
{
return
EVP_PKEY_type
(
pkey
->
type
);
}
void
EVP_PKEY_free
(
EVP_PKEY
*
x
)
void
EVP_PKEY_free
(
EVP_PKEY
*
x
)
{
{
int
i
;
int
i
;
...
...
crypto/rsa/rsa.h
浏览文件 @
7f57b076
...
@@ -372,6 +372,8 @@ void ERR_load_RSA_strings(void);
...
@@ -372,6 +372,8 @@ void ERR_load_RSA_strings(void);
/* Function codes. */
/* Function codes. */
#define RSA_F_CHECK_PADDING_MD 140
#define RSA_F_CHECK_PADDING_MD 140
#define RSA_F_MEMORY_LOCK 100
#define RSA_F_MEMORY_LOCK 100
#define RSA_F_PKEY_RSA_CTRL 143
#define RSA_F_PKEY_RSA_CTRL_STR 144
#define RSA_F_PKEY_RSA_SIGN 142
#define RSA_F_PKEY_RSA_SIGN 142
#define RSA_F_PKEY_RSA_VERIFYRECOVER 141
#define RSA_F_PKEY_RSA_VERIFYRECOVER 141
#define RSA_F_RSA_BUILTIN_KEYGEN 129
#define RSA_F_RSA_BUILTIN_KEYGEN 129
...
@@ -433,12 +435,15 @@ void ERR_load_RSA_strings(void);
...
@@ -433,12 +435,15 @@ void ERR_load_RSA_strings(void);
#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
#define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
#define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
#define RSA_R_FIRST_OCTET_INVALID 133
#define RSA_R_FIRST_OCTET_INVALID 133
#define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144
#define RSA_R_INVALID_DIGEST 105
#define RSA_R_INVALID_DIGEST 105
#define RSA_R_INVALID_DIGEST_LENGTH 143
#define RSA_R_INVALID_DIGEST_LENGTH 143
#define RSA_R_INVALID_HEADER 137
#define RSA_R_INVALID_HEADER 137
#define RSA_R_INVALID_KEYBITS 145
#define RSA_R_INVALID_MESSAGE_LENGTH 131
#define RSA_R_INVALID_MESSAGE_LENGTH 131
#define RSA_R_INVALID_PADDING 138
#define RSA_R_INVALID_PADDING 138
#define RSA_R_INVALID_PADDING_MODE 141
#define RSA_R_INVALID_PADDING_MODE 141
#define RSA_R_INVALID_PSS_SALTLEN 146
#define RSA_R_INVALID_TRAILER 139
#define RSA_R_INVALID_TRAILER 139
#define RSA_R_INVALID_X931_DIGEST 142
#define RSA_R_INVALID_X931_DIGEST 142
#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
...
@@ -458,6 +463,7 @@ void ERR_load_RSA_strings(void);
...
@@ -458,6 +463,7 @@ void ERR_load_RSA_strings(void);
#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
#define RSA_R_UNKNOWN_PADDING_TYPE 118
#define RSA_R_UNKNOWN_PADDING_TYPE 118
#define RSA_R_VALUE_MISSING 147
#define RSA_R_WRONG_SIGNATURE_LENGTH 119
#define RSA_R_WRONG_SIGNATURE_LENGTH 119
#ifdef __cplusplus
#ifdef __cplusplus
...
...
crypto/rsa/rsa_err.c
浏览文件 @
7f57b076
...
@@ -72,6 +72,8 @@ static ERR_STRING_DATA RSA_str_functs[]=
...
@@ -72,6 +72,8 @@ static ERR_STRING_DATA RSA_str_functs[]=
{
{
{
ERR_FUNC
(
RSA_F_CHECK_PADDING_MD
),
"CHECK_PADDING_MD"
},
{
ERR_FUNC
(
RSA_F_CHECK_PADDING_MD
),
"CHECK_PADDING_MD"
},
{
ERR_FUNC
(
RSA_F_MEMORY_LOCK
),
"MEMORY_LOCK"
},
{
ERR_FUNC
(
RSA_F_MEMORY_LOCK
),
"MEMORY_LOCK"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_CTRL
),
"PKEY_RSA_CTRL"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_CTRL_STR
),
"PKEY_RSA_CTRL_STR"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_SIGN
),
"PKEY_RSA_SIGN"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_SIGN
),
"PKEY_RSA_SIGN"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_VERIFYRECOVER
),
"PKEY_RSA_VERIFYRECOVER"
},
{
ERR_FUNC
(
RSA_F_PKEY_RSA_VERIFYRECOVER
),
"PKEY_RSA_VERIFYRECOVER"
},
{
ERR_FUNC
(
RSA_F_RSA_BUILTIN_KEYGEN
),
"RSA_BUILTIN_KEYGEN"
},
{
ERR_FUNC
(
RSA_F_RSA_BUILTIN_KEYGEN
),
"RSA_BUILTIN_KEYGEN"
},
...
@@ -136,12 +138,15 @@ static ERR_STRING_DATA RSA_str_reasons[]=
...
@@ -136,12 +138,15 @@ static ERR_STRING_DATA RSA_str_reasons[]=
{
ERR_REASON
(
RSA_R_DMQ1_NOT_CONGRUENT_TO_D
),
"dmq1 not congruent to d"
},
{
ERR_REASON
(
RSA_R_DMQ1_NOT_CONGRUENT_TO_D
),
"dmq1 not congruent to d"
},
{
ERR_REASON
(
RSA_R_D_E_NOT_CONGRUENT_TO_1
),
"d e not congruent to 1"
},
{
ERR_REASON
(
RSA_R_D_E_NOT_CONGRUENT_TO_1
),
"d e not congruent to 1"
},
{
ERR_REASON
(
RSA_R_FIRST_OCTET_INVALID
)
,
"first octet invalid"
},
{
ERR_REASON
(
RSA_R_FIRST_OCTET_INVALID
)
,
"first octet invalid"
},
{
ERR_REASON
(
RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE
),
"illegal or unsupported padding mode"
},
{
ERR_REASON
(
RSA_R_INVALID_DIGEST
)
,
"invalid digest"
},
{
ERR_REASON
(
RSA_R_INVALID_DIGEST
)
,
"invalid digest"
},
{
ERR_REASON
(
RSA_R_INVALID_DIGEST_LENGTH
)
,
"invalid digest length"
},
{
ERR_REASON
(
RSA_R_INVALID_DIGEST_LENGTH
)
,
"invalid digest length"
},
{
ERR_REASON
(
RSA_R_INVALID_HEADER
)
,
"invalid header"
},
{
ERR_REASON
(
RSA_R_INVALID_HEADER
)
,
"invalid header"
},
{
ERR_REASON
(
RSA_R_INVALID_KEYBITS
)
,
"invalid keybits"
},
{
ERR_REASON
(
RSA_R_INVALID_MESSAGE_LENGTH
),
"invalid message length"
},
{
ERR_REASON
(
RSA_R_INVALID_MESSAGE_LENGTH
),
"invalid message length"
},
{
ERR_REASON
(
RSA_R_INVALID_PADDING
)
,
"invalid padding"
},
{
ERR_REASON
(
RSA_R_INVALID_PADDING
)
,
"invalid padding"
},
{
ERR_REASON
(
RSA_R_INVALID_PADDING_MODE
)
,
"invalid padding mode"
},
{
ERR_REASON
(
RSA_R_INVALID_PADDING_MODE
)
,
"invalid padding mode"
},
{
ERR_REASON
(
RSA_R_INVALID_PSS_SALTLEN
)
,
"invalid pss saltlen"
},
{
ERR_REASON
(
RSA_R_INVALID_TRAILER
)
,
"invalid trailer"
},
{
ERR_REASON
(
RSA_R_INVALID_TRAILER
)
,
"invalid trailer"
},
{
ERR_REASON
(
RSA_R_INVALID_X931_DIGEST
)
,
"invalid x931 digest"
},
{
ERR_REASON
(
RSA_R_INVALID_X931_DIGEST
)
,
"invalid x931 digest"
},
{
ERR_REASON
(
RSA_R_IQMP_NOT_INVERSE_OF_Q
)
,
"iqmp not inverse of q"
},
{
ERR_REASON
(
RSA_R_IQMP_NOT_INVERSE_OF_Q
)
,
"iqmp not inverse of q"
},
...
@@ -161,6 +166,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
...
@@ -161,6 +166,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
{
ERR_REASON
(
RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD
),
"the asn1 object identifier is not known for this md"
},
{
ERR_REASON
(
RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD
),
"the asn1 object identifier is not known for this md"
},
{
ERR_REASON
(
RSA_R_UNKNOWN_ALGORITHM_TYPE
),
"unknown algorithm type"
},
{
ERR_REASON
(
RSA_R_UNKNOWN_ALGORITHM_TYPE
),
"unknown algorithm type"
},
{
ERR_REASON
(
RSA_R_UNKNOWN_PADDING_TYPE
)
,
"unknown padding type"
},
{
ERR_REASON
(
RSA_R_UNKNOWN_PADDING_TYPE
)
,
"unknown padding type"
},
{
ERR_REASON
(
RSA_R_VALUE_MISSING
)
,
"value missing"
},
{
ERR_REASON
(
RSA_R_WRONG_SIGNATURE_LENGTH
),
"wrong signature length"
},
{
ERR_REASON
(
RSA_R_WRONG_SIGNATURE_LENGTH
),
"wrong signature length"
},
{
0
,
NULL
}
{
0
,
NULL
}
};
};
...
...
crypto/rsa/rsa_pmeth.c
浏览文件 @
7f57b076
...
@@ -362,34 +362,44 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
...
@@ -362,34 +362,44 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
return
0
;
return
0
;
if
(
p1
==
RSA_PKCS1_PSS_PADDING
)
if
(
p1
==
RSA_PKCS1_PSS_PADDING
)
{
{
if
(
ctx
->
operation
==
EVP_PKEY_OP_VERIFYRECOVER
)
if
(
!
(
ctx
->
operation
&
return
-
2
;
(
EVP_PKEY_OP_SIGN
|
EVP_PKEY_OP_VERIFY
)))
goto
bad_pad
;
if
(
!
rctx
->
md
)
if
(
!
rctx
->
md
)
rctx
->
md
=
EVP_sha1
();
rctx
->
md
=
EVP_sha1
();
}
}
if
(
p1
==
RSA_PKCS1_OAEP_PADDING
)
if
(
p1
==
RSA_PKCS1_OAEP_PADDING
)
{
{
if
(
!
(
ctx
->
operation
&
EVP_PKEY_OP_TYPE_CRYPT
))
if
(
!
(
ctx
->
operation
&
EVP_PKEY_OP_TYPE_CRYPT
))
return
-
2
;
goto
bad_pad
;
if
(
!
rctx
->
md
)
if
(
!
rctx
->
md
)
rctx
->
md
=
EVP_sha1
();
rctx
->
md
=
EVP_sha1
();
}
}
rctx
->
pad_mode
=
p1
;
rctx
->
pad_mode
=
p1
;
return
1
;
return
1
;
}
}
bad_pad:
RSAerr
(
RSA_F_PKEY_RSA_CTRL
,
RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE
);
return
-
2
;
return
-
2
;
case
EVP_PKEY_CTRL_RSA_PSS_SALTLEN
:
case
EVP_PKEY_CTRL_RSA_PSS_SALTLEN
:
if
(
p1
<
-
2
)
if
(
p1
<
-
2
)
return
-
2
;
return
-
2
;
if
(
rctx
->
pad_mode
!=
RSA_PKCS1_PSS_PADDING
)
if
(
rctx
->
pad_mode
!=
RSA_PKCS1_PSS_PADDING
)
{
RSAerr
(
RSA_F_PKEY_RSA_CTRL
,
RSA_R_INVALID_PSS_SALTLEN
);
return
-
2
;
return
-
2
;
}
rctx
->
saltlen
=
p1
;
rctx
->
saltlen
=
p1
;
return
1
;
return
1
;
case
EVP_PKEY_CTRL_RSA_KEYGEN_BITS
:
case
EVP_PKEY_CTRL_RSA_KEYGEN_BITS
:
if
(
p1
<
256
)
if
(
p1
<
256
)
{
RSAerr
(
RSA_F_PKEY_RSA_CTRL
,
RSA_R_INVALID_KEYBITS
);
return
-
2
;
return
-
2
;
}
rctx
->
nbits
=
p1
;
rctx
->
nbits
=
p1
;
return
1
;
return
1
;
...
@@ -418,11 +428,14 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
...
@@ -418,11 +428,14 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
static
int
pkey_rsa_ctrl_str
(
EVP_PKEY_CTX
*
ctx
,
static
int
pkey_rsa_ctrl_str
(
EVP_PKEY_CTX
*
ctx
,
const
char
*
type
,
const
char
*
value
)
const
char
*
type
,
const
char
*
value
)
{
{
if
(
!
value
)
{
RSAerr
(
RSA_F_PKEY_RSA_CTRL_STR
,
RSA_R_VALUE_MISSING
);
return
0
;
}
if
(
!
strcmp
(
type
,
"rsa_padding_mode"
))
if
(
!
strcmp
(
type
,
"rsa_padding_mode"
))
{
{
int
pm
;
int
pm
;
if
(
!
value
)
return
0
;
if
(
!
strcmp
(
value
,
"pkcs1"
))
if
(
!
strcmp
(
value
,
"pkcs1"
))
pm
=
RSA_PKCS1_PADDING
;
pm
=
RSA_PKCS1_PADDING
;
else
if
(
!
strcmp
(
value
,
"sslv23"
))
else
if
(
!
strcmp
(
value
,
"sslv23"
))
...
@@ -436,7 +449,11 @@ static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx,
...
@@ -436,7 +449,11 @@ static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx,
else
if
(
!
strcmp
(
value
,
"pss"
))
else
if
(
!
strcmp
(
value
,
"pss"
))
pm
=
RSA_PKCS1_PSS_PADDING
;
pm
=
RSA_PKCS1_PSS_PADDING
;
else
else
{
RSAerr
(
RSA_F_PKEY_RSA_CTRL_STR
,
RSA_R_UNKNOWN_PADDING_TYPE
);
return
-
2
;
return
-
2
;
}
return
EVP_PKEY_CTX_set_rsa_padding
(
ctx
,
pm
);
return
EVP_PKEY_CTX_set_rsa_padding
(
ctx
,
pm
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录