Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
d09f51b6
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d09f51b6
编写于
7月 14, 2007
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
差异文件
Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
Conflicts: crypto/Kconfig
上级
1b1ac759
e559e91c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
125 addition
and
34 deletion
+125
-34
crypto/Kconfig
crypto/Kconfig
+1
-5
crypto/ablkcipher.c
crypto/ablkcipher.c
+29
-2
crypto/algapi.c
crypto/algapi.c
+2
-2
crypto/api.c
crypto/api.c
+1
-1
crypto/blkcipher.c
crypto/blkcipher.c
+25
-0
crypto/cipher.c
crypto/cipher.c
+30
-3
crypto/hash.c
crypto/hash.c
+37
-1
include/linux/crypto.h
include/linux/crypto.h
+0
-20
未找到文件。
crypto/Kconfig
浏览文件 @
d09f51b6
...
...
@@ -12,9 +12,7 @@ source "crypto/async_tx/Kconfig"
#
# Cryptographic API Configuration
#
menu "Cryptographic options"
config CRYPTO
menuconfig CRYPTO
bool "Cryptographic API"
help
This option provides the core Cryptographic API.
...
...
@@ -473,5 +471,3 @@ config CRYPTO_TEST
source "drivers/crypto/Kconfig"
endif # if CRYPTO
endmenu
crypto/ablkcipher.c
浏览文件 @
d09f51b6
...
...
@@ -19,16 +19,41 @@
#include <linux/module.h>
#include <linux/seq_file.h>
static
int
setkey_unaligned
(
struct
crypto_ablkcipher
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
ablkcipher_alg
*
cipher
=
crypto_ablkcipher_alg
(
tfm
);
unsigned
long
alignmask
=
crypto_ablkcipher_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cipher
->
setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_ablkcipher
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
ablkcipher_alg
*
cipher
=
crypto_ablkcipher_alg
(
tfm
);
unsigned
long
alignmask
=
crypto_ablkcipher_alignmask
(
tfm
);
if
(
keylen
<
cipher
->
min_keysize
||
keylen
>
cipher
->
max_keysize
)
{
crypto_ablkcipher_set_flags
(
tfm
,
CRYPTO_TFM_RES_BAD_KEY_LEN
);
return
-
EINVAL
;
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cipher
->
setkey
(
tfm
,
key
,
keylen
);
}
...
...
@@ -66,8 +91,10 @@ static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
seq_printf
(
m
,
"min keysize : %u
\n
"
,
ablkcipher
->
min_keysize
);
seq_printf
(
m
,
"max keysize : %u
\n
"
,
ablkcipher
->
max_keysize
);
seq_printf
(
m
,
"ivsize : %u
\n
"
,
ablkcipher
->
ivsize
);
seq_printf
(
m
,
"qlen : %u
\n
"
,
ablkcipher
->
queue
->
qlen
);
seq_printf
(
m
,
"max qlen : %u
\n
"
,
ablkcipher
->
queue
->
max_qlen
);
if
(
ablkcipher
->
queue
)
{
seq_printf
(
m
,
"qlen : %u
\n
"
,
ablkcipher
->
queue
->
qlen
);
seq_printf
(
m
,
"max qlen : %u
\n
"
,
ablkcipher
->
queue
->
max_qlen
);
}
}
const
struct
crypto_type
crypto_ablkcipher_type
=
{
...
...
crypto/algapi.c
浏览文件 @
d09f51b6
...
...
@@ -34,7 +34,7 @@ void crypto_larval_error(const char *name, u32 type, u32 mask)
if
(
alg
)
{
if
(
crypto_is_larval
(
alg
))
{
struct
crypto_larval
*
larval
=
(
void
*
)
alg
;
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
}
crypto_mod_put
(
alg
);
}
...
...
@@ -164,7 +164,7 @@ static int __crypto_register_alg(struct crypto_alg *alg,
continue
;
larval
->
adult
=
alg
;
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
continue
;
}
...
...
crypto/api.c
浏览文件 @
d09f51b6
...
...
@@ -144,7 +144,7 @@ static void crypto_larval_kill(struct crypto_alg *alg)
down_write
(
&
crypto_alg_sem
);
list_del
(
&
alg
->
cra_list
);
up_write
(
&
crypto_alg_sem
);
complete
(
&
larval
->
completion
);
complete
_all
(
&
larval
->
completion
);
crypto_alg_put
(
alg
);
}
...
...
crypto/blkcipher.c
浏览文件 @
d09f51b6
...
...
@@ -336,16 +336,41 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc,
return
blkcipher_walk_next
(
desc
,
walk
);
}
static
int
setkey_unaligned
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
blkcipher_alg
*
cipher
=
&
tfm
->
__crt_alg
->
cra_blkcipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cipher
->
setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
blkcipher_alg
*
cipher
=
&
tfm
->
__crt_alg
->
cra_blkcipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
if
(
keylen
<
cipher
->
min_keysize
||
keylen
>
cipher
->
max_keysize
)
{
tfm
->
crt_flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cipher
->
setkey
(
tfm
,
key
,
keylen
);
}
...
...
crypto/cipher.c
浏览文件 @
d09f51b6
...
...
@@ -20,16 +20,43 @@
#include <linux/string.h>
#include "internal.h"
static
int
setkey_unaligned
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
cipher_alg
*
cia
=
&
tfm
->
__crt_alg
->
cra_cipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
cia
->
cia_setkey
(
tfm
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
setkey
(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
cipher_alg
*
cia
=
&
tfm
->
__crt_alg
->
cra_cipher
;
unsigned
long
alignmask
=
crypto_tfm_alg_alignmask
(
tfm
);
tfm
->
crt_flags
&=
~
CRYPTO_TFM_RES_MASK
;
if
(
keylen
<
cia
->
cia_min_keysize
||
keylen
>
cia
->
cia_max_keysize
)
{
tfm
->
crt_flags
|=
CRYPTO_TFM_RES_BAD_KEY_LEN
;
return
-
EINVAL
;
}
else
return
cia
->
cia_setkey
(
tfm
,
key
,
keylen
);
}
if
((
unsigned
long
)
key
&
alignmask
)
return
setkey_unaligned
(
tfm
,
key
,
keylen
);
return
cia
->
cia_setkey
(
tfm
,
key
,
keylen
);
}
static
void
cipher_crypt_unaligned
(
void
(
*
fn
)(
struct
crypto_tfm
*
,
u8
*
,
...
...
crypto/hash.c
浏览文件 @
d09f51b6
...
...
@@ -22,6 +22,42 @@ static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg, u32 type,
return
alg
->
cra_ctxsize
;
}
static
int
hash_setkey_unaligned
(
struct
crypto_hash
*
crt
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
crypto_tfm
*
tfm
=
crypto_hash_tfm
(
crt
);
struct
hash_alg
*
alg
=
&
tfm
->
__crt_alg
->
cra_hash
;
unsigned
long
alignmask
=
crypto_hash_alignmask
(
crt
);
int
ret
;
u8
*
buffer
,
*
alignbuffer
;
unsigned
long
absize
;
absize
=
keylen
+
alignmask
;
buffer
=
kmalloc
(
absize
,
GFP_ATOMIC
);
if
(
!
buffer
)
return
-
ENOMEM
;
alignbuffer
=
(
u8
*
)
ALIGN
((
unsigned
long
)
buffer
,
alignmask
+
1
);
memcpy
(
alignbuffer
,
key
,
keylen
);
ret
=
alg
->
setkey
(
crt
,
alignbuffer
,
keylen
);
memset
(
alignbuffer
,
0
,
absize
);
kfree
(
buffer
);
return
ret
;
}
static
int
hash_setkey
(
struct
crypto_hash
*
crt
,
const
u8
*
key
,
unsigned
int
keylen
)
{
struct
crypto_tfm
*
tfm
=
crypto_hash_tfm
(
crt
);
struct
hash_alg
*
alg
=
&
tfm
->
__crt_alg
->
cra_hash
;
unsigned
long
alignmask
=
crypto_hash_alignmask
(
crt
);
if
((
unsigned
long
)
key
&
alignmask
)
return
hash_setkey_unaligned
(
crt
,
key
,
keylen
);
return
alg
->
setkey
(
crt
,
key
,
keylen
);
}
static
int
crypto_init_hash_ops
(
struct
crypto_tfm
*
tfm
,
u32
type
,
u32
mask
)
{
struct
hash_tfm
*
crt
=
&
tfm
->
crt_hash
;
...
...
@@ -34,7 +70,7 @@ static int crypto_init_hash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
crt
->
update
=
alg
->
update
;
crt
->
final
=
alg
->
final
;
crt
->
digest
=
alg
->
digest
;
crt
->
setkey
=
alg
->
setkey
;
crt
->
setkey
=
hash_
setkey
;
crt
->
digestsize
=
alg
->
digestsize
;
return
0
;
...
...
include/linux/crypto.h
浏览文件 @
d09f51b6
...
...
@@ -295,28 +295,8 @@ struct blkcipher_tfm {
};
struct
cipher_tfm
{
void
*
cit_iv
;
unsigned
int
cit_ivsize
;
u32
cit_mode
;
int
(
*
cit_setkey
)(
struct
crypto_tfm
*
tfm
,
const
u8
*
key
,
unsigned
int
keylen
);
int
(
*
cit_encrypt
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
);
int
(
*
cit_encrypt_iv
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
,
u8
*
iv
);
int
(
*
cit_decrypt
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
);
int
(
*
cit_decrypt_iv
)(
struct
crypto_tfm
*
tfm
,
struct
scatterlist
*
dst
,
struct
scatterlist
*
src
,
unsigned
int
nbytes
,
u8
*
iv
);
void
(
*
cit_xor_block
)(
u8
*
dst
,
const
u8
*
src
);
void
(
*
cit_encrypt_one
)(
struct
crypto_tfm
*
tfm
,
u8
*
dst
,
const
u8
*
src
);
void
(
*
cit_decrypt_one
)(
struct
crypto_tfm
*
tfm
,
u8
*
dst
,
const
u8
*
src
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录