]> git.karo-electronics.de Git - karo-tx-linux.git/blob - crypto/krng.c
crypto: cryptd - Add setkey/setauthsize functions for AEAD
[karo-tx-linux.git] / crypto / krng.c
1 /*
2  * RNG implementation using standard kernel RNG.
3  *
4  * Copyright (c) 2008 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
8  * Free Software Foundation; either version 2 of the License, or (at your
9  * any later version.
10  *
11  */
12
13 #include <crypto/internal/rng.h>
14 #include <linux/err.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/random.h>
18
19 static int krng_generate(struct crypto_rng *tfm,
20                          const u8 *src, unsigned int slen,
21                          u8 *rdata, unsigned int dlen)
22 {
23         get_random_bytes(rdata, dlen);
24         return 0;
25 }
26
27 static int krng_seed(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
28 {
29         return 0;
30 }
31
32 static struct rng_alg krng_alg = {
33         .generate               = krng_generate,
34         .seed                   = krng_seed,
35         .base                   =       {
36                 .cra_name               = "stdrng",
37                 .cra_driver_name        = "krng",
38                 .cra_priority           = 200,
39                 .cra_module             = THIS_MODULE,
40         }
41 };
42
43
44 /* Module initalization */
45 static int __init krng_mod_init(void)
46 {
47         return crypto_register_rng(&krng_alg);
48 }
49
50 static void __exit krng_mod_fini(void)
51 {
52         crypto_unregister_rng(&krng_alg);
53 }
54
55 module_init(krng_mod_init);
56 module_exit(krng_mod_fini);
57
58 MODULE_LICENSE("GPL");
59 MODULE_DESCRIPTION("Kernel Random Number Generator");
60 MODULE_ALIAS_CRYPTO("stdrng");
61 MODULE_ALIAS_CRYPTO("krng");