linux/crypto/hash.c
<<
>>
Prefs
   1/*
   2 * Cryptographic Hash operations.
   3 * 
   4 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
   5 *
   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.
  10 */
  11
  12#include <linux/errno.h>
  13#include <linux/kernel.h>
  14#include <linux/module.h>
  15#include <linux/seq_file.h>
  16
  17#include "internal.h"
  18
  19static unsigned int crypto_hash_ctxsize(struct crypto_alg *alg)
  20{
  21        return alg->cra_ctxsize;
  22}
  23
  24static int crypto_init_hash_ops(struct crypto_tfm *tfm)
  25{
  26        struct hash_tfm *crt = &tfm->crt_hash;
  27        struct hash_alg *alg = &tfm->__crt_alg->cra_hash;
  28
  29        if (alg->digestsize > crypto_tfm_alg_blocksize(tfm))
  30                return -EINVAL;
  31
  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;
  38
  39        return 0;
  40}
  41
  42static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
  43        __attribute_used__;
  44static void crypto_hash_show(struct seq_file *m, struct crypto_alg *alg)
  45{
  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);
  49}
  50
  51const 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
  57};
  58EXPORT_SYMBOL_GPL(crypto_hash_type);
  59
  60MODULE_LICENSE("GPL");
  61MODULE_DESCRIPTION("Generic cryptographic hash type");
  62
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.