[patch/rfc] crypto: padlock-aes use crypto API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems that the driver uses something like crypto_.*_ctx_aligned() of his own.
Replace it with the API's functions. Compile tested.

Signed-off-by: Sebastian Siewior <sebastian@xxxxxxxxxxxxx>

--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -297,30 +297,10 @@ aes_hw_extkey_available(uint8_t key_len)
 	return 0;
 }
 
-static inline struct aes_ctx *aes_ctx_common(void *ctx)
-{
-	unsigned long addr = (unsigned long)ctx;
-	unsigned long align = PADLOCK_ALIGNMENT;
-
-	if (align <= crypto_tfm_ctx_alignment())
-		align = 1;
-	return (struct aes_ctx *)ALIGN(addr, align);
-}
-
-static inline struct aes_ctx *aes_ctx(struct crypto_tfm *tfm)
-{
-	return aes_ctx_common(crypto_tfm_ctx(tfm));
-}
-
-static inline struct aes_ctx *blk_aes_ctx(struct crypto_blkcipher *tfm)
-{
-	return aes_ctx_common(crypto_blkcipher_ctx(tfm));
-}
-
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
 		       unsigned int key_len)
 {
-	struct aes_ctx *ctx = aes_ctx(tfm);
+	struct aes_ctx *ctx = crypto_tfm_ctx_aligned(tfm);
 	const __le32 *key = (const __le32 *)in_key;
 	u32 *flags = &tfm->crt_flags;
 	uint32_t i, t, u, v, w;
@@ -442,13 +422,13 @@ static inline u8 *padlock_xcrypt_cbc(con
 
 static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
-	struct aes_ctx *ctx = aes_ctx(tfm);
+	struct aes_ctx *ctx = crypto_tfm_ctx_aligned(tfm);
 	padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, 1);
 }
 
 static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
 {
-	struct aes_ctx *ctx = aes_ctx(tfm);
+	struct aes_ctx *ctx = crypto_tfm_ctx_aligned(tfm);
 	padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, 1);
 }
 
@@ -477,7 +457,7 @@ static int ecb_aes_encrypt(struct blkcip
 			   struct scatterlist *dst, struct scatterlist *src,
 			   unsigned int nbytes)
 {
-	struct aes_ctx *ctx = blk_aes_ctx(desc->tfm);
+	struct aes_ctx *ctx = crypto_blkcipher_ctx_aligned(desc->tfm);
 	struct blkcipher_walk walk;
 	int err;
 
@@ -499,7 +479,7 @@ static int ecb_aes_decrypt(struct blkcip
 			   struct scatterlist *dst, struct scatterlist *src,
 			   unsigned int nbytes)
 {
-	struct aes_ctx *ctx = blk_aes_ctx(desc->tfm);
+	struct aes_ctx *ctx = crypto_blkcipher_ctx_aligned(desc->tfm);
 	struct blkcipher_walk walk;
 	int err;
 
@@ -543,7 +523,7 @@ static int cbc_aes_encrypt(struct blkcip
 			   struct scatterlist *dst, struct scatterlist *src,
 			   unsigned int nbytes)
 {
-	struct aes_ctx *ctx = blk_aes_ctx(desc->tfm);
+	struct aes_ctx *ctx = crypto_blkcipher_ctx_aligned(desc->tfm);
 	struct blkcipher_walk walk;
 	int err;
 
@@ -567,7 +547,7 @@ static int cbc_aes_decrypt(struct blkcip
 			   struct scatterlist *dst, struct scatterlist *src,
 			   unsigned int nbytes)
 {
-	struct aes_ctx *ctx = blk_aes_ctx(desc->tfm);
+	struct aes_ctx *ctx = crypto_blkcipher_ctx_aligned(desc->tfm);
 	struct blkcipher_walk walk;
 	int err;
 
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux