Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4beb1060 authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: vmx - Reindent to kernel style



This patch reidents the vmx code-base to the kernel coding style.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0903e435
Loading
Loading
Loading
Loading
+84 −82
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ static int p8_aes_init(struct crypto_tfm *tfm)

	fallback = crypto_alloc_cipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(fallback)) {
        printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n",
		printk(KERN_ERR
		       "Failed to allocate transformation for '%s': %ld\n",
		       alg, PTR_ERR(fallback));
		return PTR_ERR(fallback);
	}
@@ -56,7 +57,9 @@ static int p8_aes_init(struct crypto_tfm *tfm)
	       crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback));

	crypto_cipher_set_flags(fallback,
            crypto_cipher_get_flags((struct crypto_cipher *) tfm));
				crypto_cipher_get_flags((struct
							 crypto_cipher *)
							tfm));
	ctx->fallback = fallback;

	return 0;
@@ -136,4 +139,3 @@ struct crypto_alg p8_aes_alg = {
		       .cia_decrypt = p8_aes_decrypt,
	},
};
+122 −114
Original line number Diff line number Diff line
@@ -47,16 +47,19 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm)
		return -ENOENT;
	}

    fallback = crypto_alloc_blkcipher(alg, 0 ,CRYPTO_ALG_NEED_FALLBACK);
	fallback =
	    crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(fallback)) {
        printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n",
		printk(KERN_ERR
		       "Failed to allocate transformation for '%s': %ld\n",
		       alg, PTR_ERR(fallback));
		return PTR_ERR(fallback);
	}
	printk(KERN_INFO "Using '%s' as fallback implementation.\n",
	       crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback));

    crypto_blkcipher_set_flags(fallback,
	crypto_blkcipher_set_flags(
		fallback,
		crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm));
	ctx->fallback = fallback;

@@ -90,13 +93,13 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
}

static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
    struct scatterlist *dst, struct scatterlist *src,
    unsigned int nbytes)
			      struct scatterlist *dst,
			      struct scatterlist *src, unsigned int nbytes)
{
	int ret;
	struct blkcipher_walk walk;
    struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(
            crypto_blkcipher_tfm(desc->tfm));
	struct p8_aes_cbc_ctx *ctx =
		crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
	struct blkcipher_desc fallback_desc = {
		.tfm = ctx->fallback,
		.info = desc->info,
@@ -104,7 +107,8 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
	};

	if (in_interrupt()) {
        ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, nbytes);
		ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src,
					       nbytes);
	} else {
		pagefault_disable();
		enable_kernel_altivec();
@@ -112,8 +116,10 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
		blkcipher_walk_init(&walk, dst, src, nbytes);
		ret = blkcipher_walk_virt(desc, &walk);
		while ((nbytes = walk.nbytes)) {
			aes_p8_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
				nbytes & AES_BLOCK_MASK, &ctx->enc_key, walk.iv, 1);
			aes_p8_cbc_encrypt(walk.src.virt.addr,
					   walk.dst.virt.addr,
					   nbytes & AES_BLOCK_MASK,
					   &ctx->enc_key, walk.iv, 1);
			nbytes &= AES_BLOCK_SIZE - 1;
			ret = blkcipher_walk_done(desc, &walk, nbytes);
		}
@@ -125,13 +131,13 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
}

static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
    struct scatterlist *dst, struct scatterlist *src,
    unsigned int nbytes)
			      struct scatterlist *dst,
			      struct scatterlist *src, unsigned int nbytes)
{
	int ret;
	struct blkcipher_walk walk;
    struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(
            crypto_blkcipher_tfm(desc->tfm));
	struct p8_aes_cbc_ctx *ctx =
		crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
	struct blkcipher_desc fallback_desc = {
		.tfm = ctx->fallback,
		.info = desc->info,
@@ -139,7 +145,8 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
	};

	if (in_interrupt()) {
        ret = crypto_blkcipher_decrypt(&fallback_desc, dst, src, nbytes);
		ret = crypto_blkcipher_decrypt(&fallback_desc, dst, src,
					       nbytes);
	} else {
		pagefault_disable();
		enable_kernel_altivec();
@@ -147,8 +154,10 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
		blkcipher_walk_init(&walk, dst, src, nbytes);
		ret = blkcipher_walk_virt(desc, &walk);
		while ((nbytes = walk.nbytes)) {
			aes_p8_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
				nbytes & AES_BLOCK_MASK, &ctx->dec_key, walk.iv, 0);
			aes_p8_cbc_encrypt(walk.src.virt.addr,
					   walk.dst.virt.addr,
					   nbytes & AES_BLOCK_MASK,
					   &ctx->dec_key, walk.iv, 0);
			nbytes &= AES_BLOCK_SIZE - 1;
			ret = blkcipher_walk_done(desc, &walk, nbytes);
		}
@@ -181,4 +190,3 @@ struct crypto_alg p8_aes_cbc_alg = {
			  .decrypt = p8_aes_cbc_decrypt,
	},
};
+117 −108
Original line number Diff line number Diff line
@@ -45,16 +45,19 @@ static int p8_aes_ctr_init(struct crypto_tfm *tfm)
		return -ENOENT;
	}

    fallback = crypto_alloc_blkcipher(alg, 0 ,CRYPTO_ALG_NEED_FALLBACK);
	fallback =
	    crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(fallback)) {
        printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n",
		printk(KERN_ERR
		       "Failed to allocate transformation for '%s': %ld\n",
		       alg, PTR_ERR(fallback));
		return PTR_ERR(fallback);
	}
	printk(KERN_INFO "Using '%s' as fallback implementation.\n",
	       crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback));

    crypto_blkcipher_set_flags(fallback,
	crypto_blkcipher_set_flags(
		fallback,
		crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm));
	ctx->fallback = fallback;

@@ -106,13 +109,13 @@ static void p8_aes_ctr_final(struct p8_aes_ctr_ctx *ctx,
}

static int p8_aes_ctr_crypt(struct blkcipher_desc *desc,
    struct scatterlist *dst, struct scatterlist *src,
    unsigned int nbytes)
			    struct scatterlist *dst,
			    struct scatterlist *src, unsigned int nbytes)
{
	int ret;
	struct blkcipher_walk walk;
    struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(
            crypto_blkcipher_tfm(desc->tfm));
	struct p8_aes_ctr_ctx *ctx =
		crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
	struct blkcipher_desc fallback_desc = {
		.tfm = ctx->fallback,
		.info = desc->info,
@@ -120,15 +123,21 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc,
	};

	if (in_interrupt()) {
        ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, nbytes);
		ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src,
					       nbytes);
	} else {
		blkcipher_walk_init(&walk, dst, src, nbytes);
		ret = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE);
		while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) {
			pagefault_disable();
			enable_kernel_altivec();
            aes_p8_ctr32_encrypt_blocks(walk.src.virt.addr, walk.dst.virt.addr,
                (nbytes & AES_BLOCK_MASK)/AES_BLOCK_SIZE, &ctx->enc_key, walk.iv);
			aes_p8_ctr32_encrypt_blocks(walk.src.virt.addr,
						    walk.dst.virt.addr,
						    (nbytes &
						     AES_BLOCK_MASK) /
						    AES_BLOCK_SIZE,
						    &ctx->enc_key,
						    walk.iv);
			pagefault_enable();

			crypto_inc(walk.iv, AES_BLOCK_SIZE);
+8 −7
Original line number Diff line number Diff line
@@ -17,4 +17,5 @@ void aes_p8_decrypt(const u8 *in, u8 *out,const struct aes_key *key);
void aes_p8_cbc_encrypt(const u8 *in, u8 *out, size_t len,
			const struct aes_key *key, u8 *iv, const int enc);
void aes_p8_ctr32_encrypt_blocks(const u8 *in, u8 *out,
        size_t len, const struct aes_key *key, const u8 *iv);
				 size_t len, const struct aes_key *key,
				 const u8 *iv);
+141 −137
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ static int p8_ghash_init_tfm(struct crypto_tfm *tfm)

	fallback = crypto_alloc_shash(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(fallback)) {
        printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n",
		printk(KERN_ERR
		       "Failed to allocate transformation for '%s': %ld\n",
		       alg, PTR_ERR(fallback));
		return PTR_ERR(fallback);
	}
@@ -75,7 +76,8 @@ static int p8_ghash_init_tfm(struct crypto_tfm *tfm)
	       crypto_tfm_alg_driver_name(crypto_shash_tfm(fallback)));

	crypto_shash_set_flags(fallback,
            crypto_shash_get_flags((struct crypto_shash *) tfm));
			       crypto_shash_get_flags((struct crypto_shash
						       *) tfm));
	ctx->fallback = fallback;

	shash_tfm->descsize = sizeof(struct p8_ghash_desc_ctx)
@@ -130,11 +132,13 @@ static int p8_ghash_update(struct shash_desc *desc,
	struct p8_ghash_desc_ctx *dctx = shash_desc_ctx(desc);

	if (IN_INTERRUPT) {
        return crypto_shash_update(&dctx->fallback_desc, src, srclen);
		return crypto_shash_update(&dctx->fallback_desc, src,
					   srclen);
	} else {
		if (dctx->bytes) {
			if (dctx->bytes + srclen < GHASH_DIGEST_SIZE) {
                memcpy(dctx->buffer + dctx->bytes, src, srclen);
				memcpy(dctx->buffer + dctx->bytes, src,
				       srclen);
				dctx->bytes += srclen;
				return 0;
			}
@@ -143,8 +147,8 @@ static int p8_ghash_update(struct shash_desc *desc,
			pagefault_disable();
			enable_kernel_altivec();
			enable_kernel_fp();
            gcm_ghash_p8(dctx->shash, ctx->htable, dctx->buffer,
                    GHASH_DIGEST_SIZE);
			gcm_ghash_p8(dctx->shash, ctx->htable,
				     dctx->buffer, GHASH_DIGEST_SIZE);
			pagefault_enable();
			src += GHASH_DIGEST_SIZE - dctx->bytes;
			srclen -= GHASH_DIGEST_SIZE - dctx->bytes;
@@ -183,8 +187,8 @@ static int p8_ghash_final(struct shash_desc *desc, u8 *out)
			pagefault_disable();
			enable_kernel_altivec();
			enable_kernel_fp();
            gcm_ghash_p8(dctx->shash, ctx->htable, dctx->buffer,
                    GHASH_DIGEST_SIZE);
			gcm_ghash_p8(dctx->shash, ctx->htable,
				     dctx->buffer, GHASH_DIGEST_SIZE);
			pagefault_enable();
			dctx->bytes = 0;
		}
Loading