1 From 3fe44ab50a87106af3349148e81ec8a1d524de82 Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@nxp.com>
3 Date: Tue, 15 Dec 2015 15:43:28 +0200
4 Subject: [PATCH 29/48] cryptodev: use CIOCHASH ioctl for digest operations
6 Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
8 crypto/engine/eng_cryptodev.c | 34 +++++++++++-----------------------
9 1 file changed, 11 insertions(+), 23 deletions(-)
11 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
12 index 1585009..dc27b55 100644
13 --- a/crypto/engine/eng_cryptodev.c
14 +++ b/crypto/engine/eng_cryptodev.c
15 @@ -84,6 +84,7 @@ struct dev_crypto_state {
18 # ifdef USE_CRYPTODEV_DIGESTS
19 + struct hash_op_data hash_op;
20 char dummy_mac_key[HASH_MAX_LEN];
21 unsigned char digest_res[HASH_MAX_LEN];
23 @@ -1556,7 +1557,7 @@ static int digest_key_length(int nid)
24 static int cryptodev_digest_init(EVP_MD_CTX *ctx)
26 struct dev_crypto_state *state = ctx->md_data;
27 - struct session_op *sess = &state->d_sess;
28 + struct hash_op_data *hash_op = &state->hash_op;
31 memset(state, 0, sizeof(struct dev_crypto_state));
32 @@ -1573,9 +1574,9 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
36 - sess->mackey = state->dummy_mac_key;
37 - sess->mackeylen = digest_key_length(ctx->digest->type);
39 + hash_op->mac_op = digest;
40 + hash_op->mackey = state->dummy_mac_key;
41 + hash_op->mackeylen = digest_key_length(ctx->digest->type);
45 @@ -1617,37 +1618,24 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
46 static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
49 - struct crypt_op cryp;
50 struct dev_crypto_state *state = ctx->md_data;
51 - struct session_op *sess = &state->d_sess;
52 + struct hash_op_data *hash_op = &state->hash_op;
54 if (!md || state->d_fd < 0) {
55 printf("%s: illegal input\n", __func__);
59 - if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
60 - printf("%s: Open session failed\n", __func__);
64 - memset(&cryp, 0, sizeof(cryp));
66 + hash_op->len = state->mac_len;
67 + hash_op->src = state->mac_data;
68 + hash_op->mac_result = md;
70 - cryp.ses = sess->ses;
72 - cryp.len = state->mac_len;
73 - cryp.src = state->mac_data;
76 - if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
77 + if (ioctl(state->d_fd, CIOCHASH, hash_op) < 0) {
78 printf("%s: digest failed\n", __func__);
82 - if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
83 - printf("%s: failed to close session\n", __func__);