Skip to content

Commit a0aae82

Browse files
chunkeeyherbertx
authored andcommitted
crypto: crypto4xx - prepare for AEAD support
This patch enhances existing interfaces and functions to support AEAD ciphers in the next patches. Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2f77690 commit a0aae82

File tree

5 files changed

+230
-73
lines changed

5 files changed

+230
-73
lines changed

drivers/crypto/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ config CRYPTO_DEV_PPC4XX
315315
tristate "Driver AMCC PPC4xx crypto accelerator"
316316
depends on PPC && 4xx
317317
select CRYPTO_HASH
318+
select CRYPTO_AEAD
319+
select CRYPTO_AES
320+
select CRYPTO_CCM
321+
select CRYPTO_GCM
318322
select CRYPTO_BLKCIPHER
319323
help
320324
This option allows you to have support for AMCC crypto acceleration.

drivers/crypto/amcc/crypto4xx_alg.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <crypto/internal/hash.h>
2727
#include <linux/dma-mapping.h>
2828
#include <crypto/algapi.h>
29+
#include <crypto/aead.h>
2930
#include <crypto/aes.h>
3031
#include <crypto/sha.h>
3132
#include <crypto/ctr.h>
@@ -83,7 +84,7 @@ int crypto4xx_encrypt(struct ablkcipher_request *req)
8384
crypto4xx_memcpy_to_le32(iv, req->info, ivlen);
8485

8586
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
86-
req->nbytes, iv, ivlen, ctx->sa_out, ctx->sa_len);
87+
req->nbytes, iv, ivlen, ctx->sa_out, ctx->sa_len, 0);
8788
}
8889

8990
int crypto4xx_decrypt(struct ablkcipher_request *req)
@@ -97,7 +98,7 @@ int crypto4xx_decrypt(struct ablkcipher_request *req)
9798
crypto4xx_memcpy_to_le32(iv, req->info, ivlen);
9899

99100
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
100-
req->nbytes, iv, ivlen, ctx->sa_in, ctx->sa_len);
101+
req->nbytes, iv, ivlen, ctx->sa_in, ctx->sa_len, 0);
101102
}
102103

103104
/**
@@ -213,7 +214,7 @@ int crypto4xx_rfc3686_encrypt(struct ablkcipher_request *req)
213214

214215
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
215216
req->nbytes, iv, AES_IV_SIZE,
216-
ctx->sa_out, ctx->sa_len);
217+
ctx->sa_out, ctx->sa_len, 0);
217218
}
218219

219220
int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req)
@@ -227,7 +228,7 @@ int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req)
227228

228229
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
229230
req->nbytes, iv, AES_IV_SIZE,
230-
ctx->sa_out, ctx->sa_len);
231+
ctx->sa_out, ctx->sa_len, 0);
231232
}
232233

233234
/**
@@ -239,11 +240,13 @@ static int crypto4xx_hash_alg_init(struct crypto_tfm *tfm,
239240
unsigned char hm)
240241
{
241242
struct crypto_alg *alg = tfm->__crt_alg;
242-
struct crypto4xx_alg *my_alg = crypto_alg_to_crypto4xx_alg(alg);
243+
struct crypto4xx_alg *my_alg;
243244
struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
244245
struct dynamic_sa_hash160 *sa;
245246
int rc;
246247

248+
my_alg = container_of(__crypto_ahash_alg(alg), struct crypto4xx_alg,
249+
alg.u.hash);
247250
ctx->dev = my_alg->dev;
248251

249252
/* Create SA */
@@ -300,7 +303,7 @@ int crypto4xx_hash_update(struct ahash_request *req)
300303

301304
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
302305
req->nbytes, NULL, 0, ctx->sa_in,
303-
ctx->sa_len);
306+
ctx->sa_len, 0);
304307
}
305308

306309
int crypto4xx_hash_final(struct ahash_request *req)
@@ -319,7 +322,7 @@ int crypto4xx_hash_digest(struct ahash_request *req)
319322

320323
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
321324
req->nbytes, NULL, 0, ctx->sa_in,
322-
ctx->sa_len);
325+
ctx->sa_len, 0);
323326
}
324327

325328
/**
@@ -330,5 +333,3 @@ int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm)
330333
return crypto4xx_hash_alg_init(tfm, SA_HASH160_LEN, SA_HASH_ALG_SHA1,
331334
SA_HASH_MODE_HASH);
332335
}
333-
334-

0 commit comments

Comments
 (0)