Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
b53e0769
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看板
提交
b53e0769
编写于
7月 01, 2009
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update from 1.0.0-stable
上级
0e698584
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
63 addition
and
54 deletion
+63
-54
crypto/engine/eng_cryptodev.c
crypto/engine/eng_cryptodev.c
+63
-54
未找到文件。
crypto/engine/eng_cryptodev.c
浏览文件 @
b53e0769
...
@@ -75,9 +75,6 @@ static u_int32_t cryptodev_asymfeat = 0;
...
@@ -75,9 +75,6 @@ static u_int32_t cryptodev_asymfeat = 0;
static
int
get_asym_dev_crypto
(
void
);
static
int
get_asym_dev_crypto
(
void
);
static
int
open_dev_crypto
(
void
);
static
int
open_dev_crypto
(
void
);
static
int
get_dev_crypto
(
void
);
static
int
get_dev_crypto
(
void
);
static
int
cryptodev_max_iv
(
int
cipher
);
static
int
cryptodev_key_length_valid
(
int
cipher
,
int
len
);
static
int
cipher_nid_to_cryptodev
(
int
nid
);
static
int
get_cryptodev_ciphers
(
const
int
**
cnids
);
static
int
get_cryptodev_ciphers
(
const
int
**
cnids
);
static
int
get_cryptodev_digests
(
const
int
**
cnids
);
static
int
get_cryptodev_digests
(
const
int
**
cnids
);
static
int
cryptodev_usable_ciphers
(
const
int
**
nids
);
static
int
cryptodev_usable_ciphers
(
const
int
**
nids
);
...
@@ -130,9 +127,12 @@ static struct {
...
@@ -130,9 +127,12 @@ static struct {
int
ivmax
;
int
ivmax
;
int
keylen
;
int
keylen
;
}
ciphers
[]
=
{
}
ciphers
[]
=
{
{
CRYPTO_ARC4
,
NID_rc4
,
0
,
16
,
},
{
CRYPTO_DES_CBC
,
NID_des_cbc
,
8
,
8
,
},
{
CRYPTO_DES_CBC
,
NID_des_cbc
,
8
,
8
,
},
{
CRYPTO_3DES_CBC
,
NID_des_ede3_cbc
,
8
,
24
,
},
{
CRYPTO_3DES_CBC
,
NID_des_ede3_cbc
,
8
,
24
,
},
{
CRYPTO_AES_CBC
,
NID_aes_128_cbc
,
16
,
16
,
},
{
CRYPTO_AES_CBC
,
NID_aes_128_cbc
,
16
,
16
,
},
{
CRYPTO_AES_CBC
,
NID_aes_192_cbc
,
16
,
24
,
},
{
CRYPTO_AES_CBC
,
NID_aes_256_cbc
,
16
,
32
,
},
{
CRYPTO_BLF_CBC
,
NID_bf_cbc
,
8
,
16
,
},
{
CRYPTO_BLF_CBC
,
NID_bf_cbc
,
8
,
16
,
},
{
CRYPTO_CAST_CBC
,
NID_cast5_cbc
,
8
,
16
,
},
{
CRYPTO_CAST_CBC
,
NID_cast5_cbc
,
8
,
16
,
},
{
CRYPTO_SKIPJACK_CBC
,
NID_undef
,
0
,
0
,
},
{
CRYPTO_SKIPJACK_CBC
,
NID_undef
,
0
,
0
,
},
...
@@ -202,50 +202,6 @@ get_asym_dev_crypto(void)
...
@@ -202,50 +202,6 @@ get_asym_dev_crypto(void)
return
fd
;
return
fd
;
}
}
/*
* XXXX this needs to be set for each alg - and determined from
* a running card.
*/
static
int
cryptodev_max_iv
(
int
cipher
)
{
int
i
;
for
(
i
=
0
;
ciphers
[
i
].
id
;
i
++
)
if
(
ciphers
[
i
].
id
==
cipher
)
return
(
ciphers
[
i
].
ivmax
);
return
(
0
);
}
/*
* XXXX this needs to be set for each alg - and determined from
* a running card. For now, fake it out - but most of these
* for real devices should return 1 for the supported key
* sizes the device can handle.
*/
static
int
cryptodev_key_length_valid
(
int
cipher
,
int
len
)
{
int
i
;
for
(
i
=
0
;
ciphers
[
i
].
id
;
i
++
)
if
(
ciphers
[
i
].
id
==
cipher
)
return
(
ciphers
[
i
].
keylen
==
len
);
return
(
0
);
}
/* convert libcrypto nids to cryptodev */
static
int
cipher_nid_to_cryptodev
(
int
nid
)
{
int
i
;
for
(
i
=
0
;
ciphers
[
i
].
id
;
i
++
)
if
(
ciphers
[
i
].
nid
==
nid
)
return
(
ciphers
[
i
].
id
);
return
(
0
);
}
/*
/*
* Find out what ciphers /dev/crypto will let us have a session for.
* Find out what ciphers /dev/crypto will let us have a session for.
* XXX note, that some of these openssl doesn't deal with yet!
* XXX note, that some of these openssl doesn't deal with yet!
...
@@ -427,16 +383,20 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
...
@@ -427,16 +383,20 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
{
{
struct
dev_crypto_state
*
state
=
ctx
->
cipher_data
;
struct
dev_crypto_state
*
state
=
ctx
->
cipher_data
;
struct
session_op
*
sess
=
&
state
->
d_sess
;
struct
session_op
*
sess
=
&
state
->
d_sess
;
int
cipher
;
int
cipher
,
i
;
if
((
cipher
=
cipher_nid_to_cryptodev
(
ctx
->
cipher
->
nid
))
==
NID_undef
)
return
(
0
);
if
(
ctx
->
cipher
->
iv_len
>
cryptodev_max_iv
(
cipher
))
for
(
i
=
0
;
ciphers
[
i
].
id
;
i
++
)
return
(
0
);
if
(
ctx
->
cipher
->
nid
==
ciphers
[
i
].
nid
&&
ctx
->
cipher
->
iv_len
<=
ciphers
[
i
].
ivmax
&&
ctx
->
key_len
==
ciphers
[
i
].
keylen
)
{
cipher
=
ciphers
[
i
].
id
;
break
;
}
if
(
!
cryptodev_key_length_valid
(
cipher
,
ctx
->
key_len
))
if
(
!
ciphers
[
i
].
id
)
{
state
->
d_fd
=
-
1
;
return
(
0
);
return
(
0
);
}
memset
(
sess
,
0
,
sizeof
(
struct
session_op
));
memset
(
sess
,
0
,
sizeof
(
struct
session_op
));
...
@@ -496,6 +456,20 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
...
@@ -496,6 +456,20 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
* gets called when libcrypto requests a cipher NID.
* gets called when libcrypto requests a cipher NID.
*/
*/
/* RC4 */
const
EVP_CIPHER
cryptodev_rc4
=
{
NID_rc4
,
1
,
16
,
0
,
EVP_CIPH_VARIABLE_LENGTH
,
cryptodev_init_key
,
cryptodev_cipher
,
cryptodev_cleanup
,
sizeof
(
struct
dev_crypto_state
),
NULL
,
NULL
,
NULL
};
/* DES CBC EVP */
/* DES CBC EVP */
const
EVP_CIPHER
cryptodev_des_cbc
=
{
const
EVP_CIPHER
cryptodev_des_cbc
=
{
NID_des_cbc
,
NID_des_cbc
,
...
@@ -563,6 +537,32 @@ const EVP_CIPHER cryptodev_aes_cbc = {
...
@@ -563,6 +537,32 @@ const EVP_CIPHER cryptodev_aes_cbc = {
NULL
NULL
};
};
const
EVP_CIPHER
cryptodev_aes_192_cbc
=
{
NID_aes_192_cbc
,
16
,
24
,
16
,
EVP_CIPH_CBC_MODE
,
cryptodev_init_key
,
cryptodev_cipher
,
cryptodev_cleanup
,
sizeof
(
struct
dev_crypto_state
),
EVP_CIPHER_set_asn1_iv
,
EVP_CIPHER_get_asn1_iv
,
NULL
};
const
EVP_CIPHER
cryptodev_aes_256_cbc
=
{
NID_aes_256_cbc
,
16
,
32
,
16
,
EVP_CIPH_CBC_MODE
,
cryptodev_init_key
,
cryptodev_cipher
,
cryptodev_cleanup
,
sizeof
(
struct
dev_crypto_state
),
EVP_CIPHER_set_asn1_iv
,
EVP_CIPHER_get_asn1_iv
,
NULL
};
/*
/*
* Registered by the ENGINE when used to find out how to deal with
* Registered by the ENGINE when used to find out how to deal with
* a particular NID in the ENGINE. this says what we'll do at the
* a particular NID in the ENGINE. this says what we'll do at the
...
@@ -576,6 +576,9 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
...
@@ -576,6 +576,9 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
return
(
cryptodev_usable_ciphers
(
nids
));
return
(
cryptodev_usable_ciphers
(
nids
));
switch
(
nid
)
{
switch
(
nid
)
{
case
NID_rc4
:
*
cipher
=
&
cryptodev_rc4
;
break
;
case
NID_des_ede3_cbc
:
case
NID_des_ede3_cbc
:
*
cipher
=
&
cryptodev_3des_cbc
;
*
cipher
=
&
cryptodev_3des_cbc
;
break
;
break
;
...
@@ -591,6 +594,12 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
...
@@ -591,6 +594,12 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
case
NID_aes_128_cbc
:
case
NID_aes_128_cbc
:
*
cipher
=
&
cryptodev_aes_cbc
;
*
cipher
=
&
cryptodev_aes_cbc
;
break
;
break
;
case
NID_aes_192_cbc
:
*
cipher
=
&
cryptodev_aes_192_cbc
;
break
;
case
NID_aes_256_cbc
:
*
cipher
=
&
cryptodev_aes_256_cbc
;
break
;
default:
default:
*
cipher
=
NULL
;
*
cipher
=
NULL
;
break
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录