1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
From 64d5378080c14a9cf9fd673457af0fa80f3a94ee Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@nxp.com>
Date: Tue, 15 Dec 2015 15:43:28 +0200
Subject: [PATCH 29/48] cryptodev: use CIOCHASH ioctl for digest operations
Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
---
crypto/engine/eng_cryptodev.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index b74f21c..4f375e0 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -85,6 +85,7 @@ struct dev_crypto_state {
unsigned char *iv;
int ivlen;
# ifdef USE_CRYPTODEV_DIGESTS
+ struct hash_op_data hash_op;
char dummy_mac_key[HASH_MAX_LEN];
unsigned char digest_res[HASH_MAX_LEN];
char *mac_data;
@@ -1557,7 +1558,7 @@ static int digest_key_length(int nid)
static int cryptodev_digest_init(EVP_MD_CTX *ctx)
{
struct dev_crypto_state *state = ctx->md_data;
- struct session_op *sess = &state->d_sess;
+ struct hash_op_data *hash_op = &state->hash_op;
int digest;
memset(state, 0, sizeof(struct dev_crypto_state));
@@ -1574,9 +1575,9 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
return (0);
}
- sess->mackey = state->dummy_mac_key;
- sess->mackeylen = digest_key_length(ctx->digest->type);
- sess->mac = digest;
+ hash_op->mac_op = digest;
+ hash_op->mackey = state->dummy_mac_key;
+ hash_op->mackeylen = digest_key_length(ctx->digest->type);
return (1);
}
@@ -1618,37 +1619,24 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
{
int ret = 1;
- struct crypt_op cryp;
struct dev_crypto_state *state = ctx->md_data;
- struct session_op *sess = &state->d_sess;
+ struct hash_op_data *hash_op = &state->hash_op;
if (!md || state->d_fd < 0) {
printf("%s: illegal input\n", __func__);
return (0);
}
- if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
- printf("%s: Open session failed\n", __func__);
- return (0);
- }
-
- memset(&cryp, 0, sizeof(cryp));
+ hash_op->flags = 0;
+ hash_op->len = state->mac_len;
+ hash_op->src = state->mac_data;
+ hash_op->mac_result = md;
- cryp.ses = sess->ses;
- cryp.flags = 0;
- cryp.len = state->mac_len;
- cryp.src = state->mac_data;
- cryp.mac = md;
-
- if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
+ if (ioctl(state->d_fd, CIOCHASH, hash_op) < 0) {
printf("%s: digest failed\n", __func__);
ret = 0;
}
- if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
- printf("%s: failed to close session\n", __func__);
- }
-
return ret;
}
--
2.7.3
|