diff options
Diffstat (limited to 'linux/crypto/blkcipher.c')
-rw-r--r-- | linux/crypto/blkcipher.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/linux/crypto/blkcipher.c b/linux/crypto/blkcipher.c new file mode 100644 index 00000000..31f91418 --- /dev/null +++ b/linux/crypto/blkcipher.c @@ -0,0 +1,47 @@ +/* + * Block chaining cipher operations. + * + * Generic encrypt/decrypt wrapper for ciphers, handles operations across + * multiple page boundaries by using temporary blocks. In user context, + * the kernel is given a chance to schedule us once per page. + * + * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ + +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/string.h> + +#include <crypto/algapi.h> +#include "internal.h" + +static unsigned crypto_blkcipher_ctxsize(struct crypto_alg *alg, + u32 type, u32 mask) +{ + return alg->cra_ctxsize; +} + +static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask) +{ + struct blkcipher_tfm *crt = &tfm->crt_blkcipher; + struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher; + + BUG_ON((mask & CRYPTO_ALG_TYPE_MASK) != CRYPTO_ALG_TYPE_MASK); + + crt->setkey = alg->setkey; + crt->encrypt = alg->encrypt; + crt->decrypt = alg->decrypt; + return 0; +} + +const struct crypto_type crypto_blkcipher_type = { + .ctxsize = crypto_blkcipher_ctxsize, + .init = crypto_init_blkcipher_ops, +}; |