Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
773bb506
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
773bb506
编写于
7月 14, 2015
作者:
H
Herbert Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge
git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Merge the crypto tree to pull in the nx reentrancy patch.
上级
1425d2d1
030f4e96
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
125 addition
and
79 deletion
+125
-79
drivers/crypto/nx/nx-aes-ccm.c
drivers/crypto/nx/nx-aes-ccm.c
+4
-2
drivers/crypto/nx/nx-aes-ctr.c
drivers/crypto/nx/nx-aes-ctr.c
+4
-3
drivers/crypto/nx/nx-aes-gcm.c
drivers/crypto/nx/nx-aes-gcm.c
+10
-7
drivers/crypto/nx/nx-aes-xcbc.c
drivers/crypto/nx/nx-aes-xcbc.c
+44
-26
drivers/crypto/nx/nx-sha256.c
drivers/crypto/nx/nx-sha256.c
+24
-19
drivers/crypto/nx/nx-sha512.c
drivers/crypto/nx/nx-sha512.c
+25
-19
drivers/crypto/nx/nx.c
drivers/crypto/nx/nx.c
+3
-0
drivers/crypto/nx/nx.h
drivers/crypto/nx/nx.h
+11
-3
未找到文件。
drivers/crypto/nx/nx-aes-ccm.c
浏览文件 @
773bb506
...
...
@@ -494,8 +494,9 @@ static int ccm_nx_encrypt(struct aead_request *req,
static
int
ccm4309_aes_nx_encrypt
(
struct
aead_request
*
req
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
struct
nx_gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
struct
blkcipher_desc
desc
;
u8
*
iv
=
nx_ctx
->
priv
.
ccm
.
iv
;
u8
*
iv
=
rctx
->
iv
;
iv
[
0
]
=
3
;
memcpy
(
iv
+
1
,
nx_ctx
->
priv
.
ccm
.
nonce
,
3
);
...
...
@@ -525,8 +526,9 @@ static int ccm_aes_nx_encrypt(struct aead_request *req)
static
int
ccm4309_aes_nx_decrypt
(
struct
aead_request
*
req
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
struct
nx_gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
struct
blkcipher_desc
desc
;
u8
*
iv
=
nx_ctx
->
priv
.
ccm
.
iv
;
u8
*
iv
=
rctx
->
iv
;
iv
[
0
]
=
3
;
memcpy
(
iv
+
1
,
nx_ctx
->
priv
.
ccm
.
nonce
,
3
);
...
...
drivers/crypto/nx/nx-aes-ctr.c
浏览文件 @
773bb506
...
...
@@ -72,7 +72,7 @@ static int ctr3686_aes_nx_set_key(struct crypto_tfm *tfm,
if
(
key_len
<
CTR_RFC3686_NONCE_SIZE
)
return
-
EINVAL
;
memcpy
(
nx_ctx
->
priv
.
ctr
.
iv
,
memcpy
(
nx_ctx
->
priv
.
ctr
.
nonce
,
in_key
+
key_len
-
CTR_RFC3686_NONCE_SIZE
,
CTR_RFC3686_NONCE_SIZE
);
...
...
@@ -131,14 +131,15 @@ static int ctr3686_aes_nx_crypt(struct blkcipher_desc *desc,
unsigned
int
nbytes
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_blkcipher_ctx
(
desc
->
tfm
);
u8
*
iv
=
nx_ctx
->
priv
.
ctr
.
iv
;
u8
iv
[
16
]
;
memcpy
(
iv
,
nx_ctx
->
priv
.
ctr
.
nonce
,
CTR_RFC3686_IV_SIZE
);
memcpy
(
iv
+
CTR_RFC3686_NONCE_SIZE
,
desc
->
info
,
CTR_RFC3686_IV_SIZE
);
iv
[
12
]
=
iv
[
13
]
=
iv
[
14
]
=
0
;
iv
[
15
]
=
1
;
desc
->
info
=
nx_ctx
->
priv
.
ctr
.
iv
;
desc
->
info
=
iv
;
return
ctr_aes_nx_crypt
(
desc
,
dst
,
src
,
nbytes
);
}
...
...
drivers/crypto/nx/nx-aes-gcm.c
浏览文件 @
773bb506
...
...
@@ -317,6 +317,7 @@ static int gcm_empty(struct aead_request *req, struct blkcipher_desc *desc,
static
int
gcm_aes_nx_crypt
(
struct
aead_request
*
req
,
int
enc
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
struct
nx_gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
struct
nx_csbcpb
*
csbcpb
=
nx_ctx
->
csbcpb
;
struct
blkcipher_desc
desc
;
unsigned
int
nbytes
=
req
->
cryptlen
;
...
...
@@ -326,7 +327,7 @@ static int gcm_aes_nx_crypt(struct aead_request *req, int enc)
spin_lock_irqsave
(
&
nx_ctx
->
lock
,
irq_flags
);
desc
.
info
=
nx_ctx
->
priv
.
gcm
.
iv
;
desc
.
info
=
rctx
->
iv
;
/* initialize the counter */
*
(
u32
*
)(
desc
.
info
+
NX_GCM_CTR_OFFSET
)
=
1
;
...
...
@@ -424,8 +425,8 @@ static int gcm_aes_nx_crypt(struct aead_request *req, int enc)
static
int
gcm_aes_nx_encrypt
(
struct
aead_request
*
req
)
{
struct
nx_
crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
char
*
iv
=
nx_ctx
->
priv
.
gcm
.
iv
;
struct
nx_
gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
char
*
iv
=
rctx
->
iv
;
memcpy
(
iv
,
req
->
iv
,
12
);
...
...
@@ -434,8 +435,8 @@ static int gcm_aes_nx_encrypt(struct aead_request *req)
static
int
gcm_aes_nx_decrypt
(
struct
aead_request
*
req
)
{
struct
nx_
crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
char
*
iv
=
nx_ctx
->
priv
.
gcm
.
iv
;
struct
nx_
gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
char
*
iv
=
rctx
->
iv
;
memcpy
(
iv
,
req
->
iv
,
12
);
...
...
@@ -445,7 +446,8 @@ static int gcm_aes_nx_decrypt(struct aead_request *req)
static
int
gcm4106_aes_nx_encrypt
(
struct
aead_request
*
req
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
char
*
iv
=
nx_ctx
->
priv
.
gcm
.
iv
;
struct
nx_gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
char
*
iv
=
rctx
->
iv
;
char
*
nonce
=
nx_ctx
->
priv
.
gcm
.
nonce
;
memcpy
(
iv
,
nonce
,
NX_GCM4106_NONCE_LEN
);
...
...
@@ -457,7 +459,8 @@ static int gcm4106_aes_nx_encrypt(struct aead_request *req)
static
int
gcm4106_aes_nx_decrypt
(
struct
aead_request
*
req
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
req
->
base
.
tfm
);
char
*
iv
=
nx_ctx
->
priv
.
gcm
.
iv
;
struct
nx_gcm_rctx
*
rctx
=
aead_request_ctx
(
req
);
char
*
iv
=
rctx
->
iv
;
char
*
nonce
=
nx_ctx
->
priv
.
gcm
.
nonce
;
memcpy
(
iv
,
nonce
,
NX_GCM4106_NONCE_LEN
);
...
...
drivers/crypto/nx/nx-aes-xcbc.c
浏览文件 @
773bb506
...
...
@@ -42,6 +42,7 @@ static int nx_xcbc_set_key(struct crypto_shash *desc,
unsigned
int
key_len
)
{
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_shash_ctx
(
desc
);
struct
nx_csbcpb
*
csbcpb
=
nx_ctx
->
csbcpb
;
switch
(
key_len
)
{
case
AES_KEYSIZE_128
:
...
...
@@ -51,7 +52,7 @@ static int nx_xcbc_set_key(struct crypto_shash *desc,
return
-
EINVAL
;
}
memcpy
(
nx_ctx
->
priv
.
xcbc
.
key
,
in_key
,
key_len
);
memcpy
(
csbcpb
->
cpb
.
aes_
xcbc
.
key
,
in_key
,
key_len
);
return
0
;
}
...
...
@@ -148,32 +149,29 @@ static int nx_xcbc_empty(struct shash_desc *desc, u8 *out)
return
rc
;
}
static
int
nx_
xcbc_init
(
struct
shash_desc
*
desc
)
static
int
nx_
crypto_ctx_aes_xcbc_init2
(
struct
crypto_tfm
*
tfm
)
{
struct
xcbc_state
*
sctx
=
shash_desc_ctx
(
desc
);
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
tfm
);
struct
nx_csbcpb
*
csbcpb
=
nx_ctx
->
csbcpb
;
struct
nx_sg
*
out_sg
;
int
len
;
int
err
;
nx_ctx_init
(
nx_ctx
,
HCOP_FC_AES
);
err
=
nx_crypto_ctx_aes_xcbc_init
(
tfm
);
if
(
err
)
return
err
;
memset
(
sctx
,
0
,
sizeof
*
sctx
);
nx_ctx_init
(
nx_ctx
,
HCOP_FC_AES
);
NX_CPB_SET_KEY_SIZE
(
csbcpb
,
NX_KS_AES_128
);
csbcpb
->
cpb
.
hdr
.
mode
=
NX_MODE_AES_XCBC_MAC
;
memcpy
(
csbcpb
->
cpb
.
aes_xcbc
.
key
,
nx_ctx
->
priv
.
xcbc
.
key
,
AES_BLOCK_SIZE
);
memset
(
nx_ctx
->
priv
.
xcbc
.
key
,
0
,
sizeof
*
nx_ctx
->
priv
.
xcbc
.
key
);
len
=
AES_BLOCK_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
len
,
nx_ctx
->
ap
->
sglen
);
return
0
;
}
if
(
len
!=
AES_BLOCK_SIZE
)
return
-
EINVAL
;
static
int
nx_xcbc_init
(
struct
shash_desc
*
desc
)
{
struct
xcbc_state
*
sctx
=
shash_desc_ctx
(
desc
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
memset
(
sctx
,
0
,
sizeof
*
sctx
);
return
0
;
}
...
...
@@ -186,6 +184,7 @@ static int nx_xcbc_update(struct shash_desc *desc,
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_csbcpb
*
csbcpb
=
nx_ctx
->
csbcpb
;
struct
nx_sg
*
in_sg
;
struct
nx_sg
*
out_sg
;
u32
to_process
=
0
,
leftover
,
total
;
unsigned
int
max_sg_len
;
unsigned
long
irq_flags
;
...
...
@@ -213,6 +212,17 @@ static int nx_xcbc_update(struct shash_desc *desc,
max_sg_len
=
min_t
(
u64
,
max_sg_len
,
nx_ctx
->
ap
->
databytelen
/
NX_PAGE_SIZE
);
data_len
=
AES_BLOCK_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
len
,
nx_ctx
->
ap
->
sglen
);
if
(
data_len
!=
AES_BLOCK_SIZE
)
{
rc
=
-
EINVAL
;
goto
out
;
}
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
do
{
to_process
=
total
-
to_process
;
to_process
=
to_process
&
~
(
AES_BLOCK_SIZE
-
1
);
...
...
@@ -235,8 +245,10 @@ static int nx_xcbc_update(struct shash_desc *desc,
(
u8
*
)
sctx
->
buffer
,
&
data_len
,
max_sg_len
);
if
(
data_len
!=
sctx
->
count
)
return
-
EINVAL
;
if
(
data_len
!=
sctx
->
count
)
{
rc
=
-
EINVAL
;
goto
out
;
}
}
data_len
=
to_process
-
sctx
->
count
;
...
...
@@ -245,8 +257,10 @@ static int nx_xcbc_update(struct shash_desc *desc,
&
data_len
,
max_sg_len
);
if
(
data_len
!=
to_process
-
sctx
->
count
)
return
-
EINVAL
;
if
(
data_len
!=
to_process
-
sctx
->
count
)
{
rc
=
-
EINVAL
;
goto
out
;
}
nx_ctx
->
op
.
inlen
=
(
nx_ctx
->
in_sg
-
in_sg
)
*
sizeof
(
struct
nx_sg
);
...
...
@@ -325,15 +339,19 @@ static int nx_xcbc_final(struct shash_desc *desc, u8 *out)
in_sg
=
nx_build_sg_list
(
nx_ctx
->
in_sg
,
(
u8
*
)
sctx
->
buffer
,
&
len
,
nx_ctx
->
ap
->
sglen
);
if
(
len
!=
sctx
->
count
)
return
-
EINVAL
;
if
(
len
!=
sctx
->
count
)
{
rc
=
-
EINVAL
;
goto
out
;
}
len
=
AES_BLOCK_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
out
,
&
len
,
nx_ctx
->
ap
->
sglen
);
if
(
len
!=
AES_BLOCK_SIZE
)
return
-
EINVAL
;
if
(
len
!=
AES_BLOCK_SIZE
)
{
rc
=
-
EINVAL
;
goto
out
;
}
nx_ctx
->
op
.
inlen
=
(
nx_ctx
->
in_sg
-
in_sg
)
*
sizeof
(
struct
nx_sg
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
...
...
@@ -372,7 +390,7 @@ struct shash_alg nx_shash_aes_xcbc_alg = {
.
cra_blocksize
=
AES_BLOCK_SIZE
,
.
cra_module
=
THIS_MODULE
,
.
cra_ctxsize
=
sizeof
(
struct
nx_crypto_ctx
),
.
cra_init
=
nx_crypto_ctx_aes_xcbc_init
,
.
cra_init
=
nx_crypto_ctx_aes_xcbc_init
2
,
.
cra_exit
=
nx_crypto_ctx_exit
,
}
};
drivers/crypto/nx/nx-sha256.c
浏览文件 @
773bb506
...
...
@@ -29,34 +29,28 @@
#include "nx.h"
static
int
nx_
sha256_init
(
struct
shash_desc
*
desc
)
static
int
nx_
crypto_ctx_sha256_init
(
struct
crypto_tfm
*
tfm
)
{
struct
sha256_state
*
sctx
=
shash_desc_ctx
(
desc
);
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_sg
*
out_sg
;
int
len
;
u32
max_sg_len
;
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
tfm
);
int
err
;
nx_ctx_init
(
nx_ctx
,
HCOP_FC_SHA
);
err
=
nx_crypto_ctx_sha_init
(
tfm
);
if
(
err
)
return
err
;
memset
(
sctx
,
0
,
sizeof
*
sctx
);
nx_ctx_init
(
nx_ctx
,
HCOP_FC_SHA
);
nx_ctx
->
ap
=
&
nx_ctx
->
props
[
NX_PROPS_SHA256
];
NX_CPB_SET_DIGEST_SIZE
(
nx_ctx
->
csbcpb
,
NX_DS_SHA256
);
max_sg_len
=
min_t
(
u64
,
nx_ctx
->
ap
->
sglen
,
nx_driver
.
of
.
max_sg_len
/
sizeof
(
struct
nx_sg
));
max_sg_len
=
min_t
(
u64
,
max_sg_len
,
nx_ctx
->
ap
->
databytelen
/
NX_PAGE_SIZE
);
return
0
;
}
len
=
SHA256_DIGEST_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
len
,
max_sg_len
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
static
int
nx_sha256_init
(
struct
shash_desc
*
desc
)
{
struct
sha256_state
*
sctx
=
shash_desc_ctx
(
desc
);
if
(
len
!=
SHA256_DIGEST_SIZE
)
return
-
EINVAL
;
memset
(
sctx
,
0
,
sizeof
*
sctx
);
sctx
->
state
[
0
]
=
__cpu_to_be32
(
SHA256_H0
);
sctx
->
state
[
1
]
=
__cpu_to_be32
(
SHA256_H1
);
...
...
@@ -78,6 +72,7 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_csbcpb
*
csbcpb
=
(
struct
nx_csbcpb
*
)
nx_ctx
->
csbcpb
;
struct
nx_sg
*
in_sg
;
struct
nx_sg
*
out_sg
;
u64
to_process
=
0
,
leftover
,
total
;
unsigned
long
irq_flags
;
int
rc
=
0
;
...
...
@@ -108,6 +103,16 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
max_sg_len
=
min_t
(
u64
,
max_sg_len
,
nx_ctx
->
ap
->
databytelen
/
NX_PAGE_SIZE
);
data_len
=
SHA256_DIGEST_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
data_len
,
max_sg_len
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
if
(
data_len
!=
SHA256_DIGEST_SIZE
)
{
rc
=
-
EINVAL
;
goto
out
;
}
do
{
/*
* to_process: the SHA256_BLOCK_SIZE data chunk to process in
...
...
@@ -282,7 +287,7 @@ struct shash_alg nx_shash_sha256_alg = {
.
cra_blocksize
=
SHA256_BLOCK_SIZE
,
.
cra_module
=
THIS_MODULE
,
.
cra_ctxsize
=
sizeof
(
struct
nx_crypto_ctx
),
.
cra_init
=
nx_crypto_ctx_sha_init
,
.
cra_init
=
nx_crypto_ctx_sha
256
_init
,
.
cra_exit
=
nx_crypto_ctx_exit
,
}
};
drivers/crypto/nx/nx-sha512.c
浏览文件 @
773bb506
...
...
@@ -28,34 +28,29 @@
#include "nx.h"
static
int
nx_
sha512_init
(
struct
shash_desc
*
desc
)
static
int
nx_
crypto_ctx_sha512_init
(
struct
crypto_tfm
*
tfm
)
{
struct
sha512_state
*
sctx
=
shash_desc_ctx
(
desc
);
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_sg
*
out_sg
;
int
len
;
u32
max_sg_len
;
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
tfm
);
int
err
;
nx_ctx_init
(
nx_ctx
,
HCOP_FC_SHA
);
err
=
nx_crypto_ctx_sha_init
(
tfm
);
if
(
err
)
return
err
;
memset
(
sctx
,
0
,
sizeof
*
sctx
);
nx_ctx_init
(
nx_ctx
,
HCOP_FC_SHA
);
nx_ctx
->
ap
=
&
nx_ctx
->
props
[
NX_PROPS_SHA512
];
NX_CPB_SET_DIGEST_SIZE
(
nx_ctx
->
csbcpb
,
NX_DS_SHA512
);
max_sg_len
=
min_t
(
u64
,
nx_ctx
->
ap
->
sglen
,
nx_driver
.
of
.
max_sg_len
/
sizeof
(
struct
nx_sg
));
max_sg_len
=
min_t
(
u64
,
max_sg_len
,
nx_ctx
->
ap
->
databytelen
/
NX_PAGE_SIZE
);
return
0
;
}
len
=
SHA512_DIGEST_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
len
,
max_sg_len
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
static
int
nx_sha512_init
(
struct
shash_desc
*
desc
)
{
struct
sha512_state
*
sctx
=
shash_desc_ctx
(
desc
);
if
(
len
!=
SHA512_DIGEST_SIZE
)
return
-
EINVAL
;
memset
(
sctx
,
0
,
sizeof
*
sctx
);
sctx
->
state
[
0
]
=
__cpu_to_be64
(
SHA512_H0
);
sctx
->
state
[
1
]
=
__cpu_to_be64
(
SHA512_H1
);
...
...
@@ -77,6 +72,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
struct
nx_crypto_ctx
*
nx_ctx
=
crypto_tfm_ctx
(
&
desc
->
tfm
->
base
);
struct
nx_csbcpb
*
csbcpb
=
(
struct
nx_csbcpb
*
)
nx_ctx
->
csbcpb
;
struct
nx_sg
*
in_sg
;
struct
nx_sg
*
out_sg
;
u64
to_process
,
leftover
=
0
,
total
;
unsigned
long
irq_flags
;
int
rc
=
0
;
...
...
@@ -107,6 +103,16 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
max_sg_len
=
min_t
(
u64
,
max_sg_len
,
nx_ctx
->
ap
->
databytelen
/
NX_PAGE_SIZE
);
data_len
=
SHA512_DIGEST_SIZE
;
out_sg
=
nx_build_sg_list
(
nx_ctx
->
out_sg
,
(
u8
*
)
sctx
->
state
,
&
data_len
,
max_sg_len
);
nx_ctx
->
op
.
outlen
=
(
nx_ctx
->
out_sg
-
out_sg
)
*
sizeof
(
struct
nx_sg
);
if
(
data_len
!=
SHA512_DIGEST_SIZE
)
{
rc
=
-
EINVAL
;
goto
out
;
}
do
{
/*
* to_process: the SHA512_BLOCK_SIZE data chunk to process in
...
...
@@ -288,7 +294,7 @@ struct shash_alg nx_shash_sha512_alg = {
.
cra_blocksize
=
SHA512_BLOCK_SIZE
,
.
cra_module
=
THIS_MODULE
,
.
cra_ctxsize
=
sizeof
(
struct
nx_crypto_ctx
),
.
cra_init
=
nx_crypto_ctx_sha_init
,
.
cra_init
=
nx_crypto_ctx_sha
512
_init
,
.
cra_exit
=
nx_crypto_ctx_exit
,
}
};
drivers/crypto/nx/nx.c
浏览文件 @
773bb506
...
...
@@ -713,12 +713,15 @@ static int nx_crypto_ctx_init(struct nx_crypto_ctx *nx_ctx, u32 fc, u32 mode)
/* entry points from the crypto tfm initializers */
int
nx_crypto_ctx_aes_ccm_init
(
struct
crypto_tfm
*
tfm
)
{
crypto_aead_set_reqsize
(
__crypto_aead_cast
(
tfm
),
sizeof
(
struct
nx_ccm_rctx
));
return
nx_crypto_ctx_init
(
crypto_tfm_ctx
(
tfm
),
NX_FC_AES
,
NX_MODE_AES_CCM
);
}
int
nx_crypto_ctx_aes_gcm_init
(
struct
crypto_aead
*
tfm
)
{
crypto_aead_set_reqsize
(
tfm
,
sizeof
(
struct
nx_gcm_rctx
));
return
nx_crypto_ctx_init
(
crypto_aead_ctx
(
tfm
),
NX_FC_AES
,
NX_MODE_AES_GCM
);
}
...
...
drivers/crypto/nx/nx.h
浏览文件 @
773bb506
...
...
@@ -2,6 +2,8 @@
#ifndef __NX_H__
#define __NX_H__
#include <crypto/ctr.h>
#define NX_NAME "nx-crypto"
#define NX_STRING "IBM Power7+ Nest Accelerator Crypto Driver"
#define NX_VERSION "1.0"
...
...
@@ -91,8 +93,11 @@ struct nx_crypto_driver {
#define NX_GCM4106_NONCE_LEN (4)
#define NX_GCM_CTR_OFFSET (12)
struct
nx_gcm_
priv
{
struct
nx_gcm_
rctx
{
u8
iv
[
16
];
};
struct
nx_gcm_priv
{
u8
iauth_tag
[
16
];
u8
nonce
[
NX_GCM4106_NONCE_LEN
];
};
...
...
@@ -100,8 +105,11 @@ struct nx_gcm_priv {
#define NX_CCM_AES_KEY_LEN (16)
#define NX_CCM4309_AES_KEY_LEN (19)
#define NX_CCM4309_NONCE_LEN (3)
struct
nx_ccm_
priv
{
struct
nx_ccm_
rctx
{
u8
iv
[
16
];
};
struct
nx_ccm_priv
{
u8
b0
[
16
];
u8
iauth_tag
[
16
];
u8
oauth_tag
[
16
];
...
...
@@ -113,7 +121,7 @@ struct nx_xcbc_priv {
};
struct
nx_ctr_priv
{
u8
iv
[
16
];
u8
nonce
[
CTR_RFC3686_NONCE_SIZE
];
};
struct
nx_crypto_ctx
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录