Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
5c62f68e
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5c62f68e
编写于
2月 28, 2002
作者:
R
Richard Levitte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated AEP engine, submitted by Diarmuid O'Neill <Diarmuid.ONeill@aep.ie>
上级
0d22b5da
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
51 addition
and
7 deletion
+51
-7
crypto/engine/hw_aep.c
crypto/engine/hw_aep.c
+49
-7
crypto/engine/hw_aep_err.c
crypto/engine/hw_aep_err.c
+1
-0
crypto/engine/hw_aep_err.h
crypto/engine/hw_aep_err.h
+1
-0
未找到文件。
crypto/engine/hw_aep.c
浏览文件 @
5c62f68e
...
...
@@ -81,6 +81,8 @@ typedef int pid_t;
#endif
#define AEP_LIB_NAME "aep engine"
#define FAIL_TO_SW 0x10101010
#include "hw_aep_err.c"
static
int
aep_init
(
ENGINE
*
e
);
...
...
@@ -233,6 +235,8 @@ static AEP_U32 rand_block_bytes = 0;
static
const
char
*
engine_aep_id
=
"aep"
;
static
const
char
*
engine_aep_name
=
"Aep hardware engine support"
;
static
int
max_key_len
=
2176
;
/* This internal function is used by ENGINE_aep() and possibly by the
* "dynamic" ENGINE support too */
...
...
@@ -557,15 +561,25 @@ static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
const
BIGNUM
*
m
,
BN_CTX
*
ctx
)
{
int
to_return
=
0
;
int
r_len
=
0
;
AEP_CONNECTION_HNDL
hConnection
;
AEP_RV
rv
;
r_len
=
BN_num_bits
(
m
);
/* Perform in software if modulus is too large for hardware. */
if
(
r_len
>
max_key_len
){
AEPHKerr
(
AEPHK_F_AEP_MOD_EXP
,
AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL
);
return
BN_mod_exp
(
r
,
a
,
p
,
m
,
ctx
);
}
/*Grab a connection from the pool*/
rv
=
aep_get_connection
(
&
hConnection
);
if
(
rv
!=
AEP_R_OK
)
{
AEPHKerr
(
AEPHK_F_AEP_MOD_EXP
,
AEPHK_R_GET_HANDLE_FAILED
);
goto
err
;
return
BN_mod_exp
(
r
,
a
,
p
,
m
,
ctx
)
;
}
/*To the card with the mod exp*/
...
...
@@ -574,8 +588,8 @@ static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
if
(
rv
!=
AEP_R_OK
)
{
AEPHKerr
(
AEPHK_F_AEP_MOD_EXP
,
AEPHK_R_MOD_EXP_FAILED
);
rv
=
aep_
return
_connection
(
hConnection
);
goto
err
;
rv
=
aep_
close
_connection
(
hConnection
);
return
BN_mod_exp
(
r
,
a
,
p
,
m
,
ctx
)
;
}
/*Return the connection to the pool*/
...
...
@@ -603,7 +617,7 @@ static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
if
(
rv
!=
AEP_R_OK
)
{
AEPHKerr
(
AEPHK_F_AEP_MOD_EXP_CRT
,
AEPHK_R_GET_HANDLE_FAILED
);
goto
err
;
return
FAIL_TO_SW
;
}
/*To the card with the mod exp*/
...
...
@@ -612,8 +626,8 @@ static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
if
(
rv
!=
AEP_R_OK
)
{
AEPHKerr
(
AEPHK_F_AEP_MOD_EXP_CRT
,
AEPHK_R_MOD_EXP_CRT_FAILED
);
rv
=
aep_
return
_connection
(
hConnection
);
goto
err
;
rv
=
aep_
close
_connection
(
hConnection
);
return
FAIL_TO_SW
;
}
/*Return the connection to the pool*/
...
...
@@ -730,7 +744,13 @@ static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
if
(
rsa
->
q
&&
rsa
->
dmp1
&&
rsa
->
dmq1
&&
rsa
->
iqmp
)
{
rv
=
aep_mod_exp_crt
(
r0
,
I
,
rsa
->
p
,
rsa
->
q
,
rsa
->
dmp1
,
rsa
->
dmq1
,
rsa
->
iqmp
,
ctx
);
if
(
rv
!=
AEP_R_OK
)
if
(
rv
==
FAIL_TO_SW
){
const
RSA_METHOD
*
meth
=
RSA_PKCS1_SSLeay
();
to_return
=
(
*
meth
->
rsa_mod_exp
)(
r0
,
I
,
rsa
);
goto
err
;
}
else
if
(
rv
!=
AEP_R_OK
)
goto
err
;
}
else
...
...
@@ -930,6 +950,28 @@ static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection)
return
AEP_R_OK
;
}
static
int
aep_close_connection
(
unsigned
int
hConnection
)
{
int
count
;
CRYPTO_w_lock
(
CRYPTO_LOCK_ENGINE
);
/*Find the connection item that matches this connection handle*/
for
(
count
=
0
;
count
<
MAX_PROCESS_CONNECTIONS
;
count
++
)
{
if
(
aep_app_conn_table
[
count
].
conn_hndl
==
hConnection
)
{
aep_app_conn_table
[
count
].
conn_state
=
NotConnected
;
close
(
aep_app_conn_table
[
count
].
conn_hndl
);
break
;
}
}
CRYPTO_w_unlock
(
CRYPTO_LOCK_ENGINE
);
return
AEP_R_OK
;
}
static
AEP_RV
aep_close_all_connections
(
int
use_engine_lock
,
int
*
in_use
)
{
int
count
;
...
...
crypto/engine/hw_aep_err.c
浏览文件 @
5c62f68e
...
...
@@ -94,6 +94,7 @@ static ERR_STRING_DATA AEPHK_str_reasons[]=
{
AEPHK_R_OK
,
"ok"
},
{
AEPHK_R_RETURN_CONNECTION_FAILED
,
"return connection failed"
},
{
AEPHK_R_SETBNCALLBACK_FAILURE
,
"setbncallback failure"
},
{
AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL
,
"size too large or too small"
},
{
AEPHK_R_UNIT_FAILURE
,
"unit failure"
},
{
0
,
NULL
}
};
...
...
crypto/engine/hw_aep_err.h
浏览文件 @
5c62f68e
...
...
@@ -92,6 +92,7 @@ static void ERR_AEPHK_error(int function, int reason, char *file, int line);
#define AEPHK_R_OK 112
#define AEPHK_R_RETURN_CONNECTION_FAILED 113
#define AEPHK_R_SETBNCALLBACK_FAILURE 114
#define AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL 116
#define AEPHK_R_UNIT_FAILURE 115
#ifdef __cplusplus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录