Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
28847dd1
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,发现更多精彩内容 >>
提交
28847dd1
编写于
4月 09, 1999
作者:
U
Ulf Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test PKCS#1 v1.5 padding as well.
上级
a5a47e4a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
13 deletion
+52
-13
crypto/rsa/rsa_oaep_test.c
crypto/rsa/rsa_oaep_test.c
+42
-11
rsaref/rsaref.c
rsaref/rsaref.c
+10
-2
未找到文件。
crypto/rsa/rsa_oaep_test.c
浏览文件 @
28847dd1
/* test vectors from p1ovect1.txt */
#include <stdio.h>
#include <string.h>
#include "e_os.h"
#include "rsa.h"
#include "err.h"
#define SetKey \
key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
...
...
@@ -182,6 +184,15 @@ int key3(RSA *key, unsigned char *c)
SetKey
;
}
int
pad_unknown
()
{
unsigned
long
l
;
while
((
l
=
ERR_get_error
())
!=
0
)
if
(
ERR_GET_REASON
(
l
)
==
RSA_R_UNKNOWN_PADDING_TYPE
)
return
(
1
);
return
(
0
);
}
int
main
()
{
int
err
=
0
;
...
...
@@ -195,11 +206,6 @@ int main()
int
clen
=
0
;
int
num
;
#ifdef RSAref
printf
(
"No OAEP support with RSAref - skipping test
\n
"
);
return
0
;
#endif
plen
=
sizeof
(
ptext_ex
)
-
1
;
for
(
v
=
0
;
v
<
3
;
v
++
)
...
...
@@ -217,11 +223,37 @@ int main()
break
;
}
num
=
RSA_public_encrypt
(
plen
,
ptext_ex
,
ctext
,
key
,
RSA_PKCS1_PADDING
);
if
(
num
!=
clen
)
{
printf
(
"PKCS#1 v1.5 encryption failed!
\n
"
);
err
=
1
;
goto
oaep
;
}
num
=
RSA_private_decrypt
(
num
,
ctext
,
ptext
,
key
,
RSA_PKCS1_PADDING
);
if
(
num
!=
plen
||
memcmp
(
ptext
,
ptext_ex
,
num
)
!=
0
)
{
printf
(
"PKCS#1 v1.5 decryption failed!
\n
"
);
err
=
1
;
}
else
printf
(
"PKCS #1 v1.5 encryption/decryption ok
\n
"
);
oaep:
ERR_clear_error
();
num
=
RSA_public_encrypt
(
plen
,
ptext_ex
,
ctext
,
key
,
RSA_PKCS1_OAEP_PADDING
);
if
(
num
==
-
1
&&
pad_unknown
())
{
printf
(
"No OAEP support
\n
"
);
goto
next
;
}
if
(
num
!=
clen
)
{
printf
(
"
E
ncryption failed!
\n
"
);
printf
(
"
OAEP e
ncryption failed!
\n
"
);
err
=
1
;
goto
next
;
}
...
...
@@ -230,14 +262,14 @@ int main()
RSA_PKCS1_OAEP_PADDING
);
if
(
num
!=
plen
||
memcmp
(
ptext
,
ptext_ex
,
num
)
!=
0
)
{
printf
(
"
D
ecryption failed!
\n
"
);
printf
(
"
OAEP d
ecryption failed!
\n
"
);
err
=
1
;
goto
next
;
}
if
(
memcmp
(
ctext
,
ctext_ex
,
num
)
==
0
)
{
printf
(
"
V
ector %d passed!
\n
"
,
v
);
printf
(
"
OAEP test v
ector %d passed!
\n
"
,
v
);
goto
next
;
}
...
...
@@ -249,12 +281,11 @@ int main()
if
(
num
!=
plen
||
memcmp
(
ptext
,
ptext_ex
,
num
)
!=
0
)
{
printf
(
"
Decryption
failed!
\n
"
);
printf
(
"
OAEP decryption (test vector data)
failed!
\n
"
);
err
=
1
;
}
else
printf
(
"Encryption/decryption successful!
\n
"
);
printf
(
"OAEP encryption/decryption ok
\n
"
);
next:
RSA_free
(
key
);
}
...
...
rsaref/rsaref.c
浏览文件 @
28847dd1
...
...
@@ -283,6 +283,11 @@ int padding;
int
i
,
outlen
=
-
1
;
RSArefPrivateKey
RSAkey
;
if
(
padding
!=
RSA_PKCS1_PADDING
)
{
RSAREFerr
(
RSAREF_F_RSA_REF_PRIVATE_ENCRYPT
,
RSA_R_UNKNOWN_PADDING_TYPE
);
goto
err
;
}
if
(
!
RSAref_Private_eay2ref
(
rsa
,
&
RSAkey
))
goto
err
;
if
((
i
=
RSAPrivateEncrypt
(
to
,
&
outlen
,
from
,
len
,
&
RSAkey
))
!=
0
)
...
...
@@ -328,9 +333,12 @@ int padding;
RSARandomState
rnd
;
unsigned
char
buf
[
16
];
if
(
padding
==
RSA_PKCS1_OAEP_PADDING
)
if
(
padding
!=
RSA_PKCS1_PADDING
&&
padding
!=
RSA_SSLV23_PADDING
)
{
RSAREFerr
(
RSAREF_F_RSA_REF_PUBLIC_ENCRYPT
,
RSA_R_UNKNOWN_PADDING_TYPE
);
goto
err
;
}
R_RandomInit
(
&
rnd
);
R_GetRandomBytesNeeded
((
unsigned
int
*
)
&
i
,
&
rnd
);
while
(
i
>
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录