[NETFILTER]: nf_conntrack: add helper function for expectation initialization
[hh.org.git] / crypto / hash.c
blobcdec23d885fed5630ddec0c347869d507b50fae5
1 /*
2 * Cryptographic Hash operations.
3 *
4 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
12 #include <linux/errno.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/seq_file.h>
17 #include "internal.h"
19 static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg)
21 return alg->cra_ctxsize;
24 static int crypto_init_hash_ops(struct crypto_tfm *tfm)
26 struct hash_tfm *crt = &tfm->crt_hash;
27 struct hash_alg *alg = &tfm->__crt_alg->cra_hash;
29 if (alg->digestsize > crypto_tfm_alg_blocksize(tfm))
30 return -EINVAL;
32 crt->init = alg->init;
33 crt->update = alg->update;
34 crt->final = alg->final;
35 crt->digest = alg->digest;
36 crt->setkey = alg->setkey;
37 crt->digestsize = alg->digestsize;
39 return 0;
42 static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
43 __attribute_used__;
44 static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
46 seq_printf(m, "type : hash\n");
47 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
48 seq_printf(m, "digestsize : %u\n", alg->cra_hash.digestsize);
51 const struct crypto_type crypto_hash_type = {
52 .ctxsize = crypto_hash_ctxsize,
53 .init = crypto_init_hash_ops,
54 #ifdef CONFIG_PROC_FS
55 .show = crypto_hash_show,
56 #endif
58 EXPORT_SYMBOL_GPL(crypto_hash_type);
60 MODULE_LICENSE("GPL");
61 MODULE_DESCRIPTION("Generic cryptographic hash type");