Root/
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_get_random(struct crypto_rng *tfm, u8 *rdata, unsigned int dlen) |
20 | { |
21 | get_random_bytes(rdata, dlen); |
22 | return 0; |
23 | } |
24 | |
25 | static int krng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen) |
26 | { |
27 | return 0; |
28 | } |
29 | |
30 | static struct crypto_alg krng_alg = { |
31 | .cra_name = "stdrng", |
32 | .cra_driver_name = "krng", |
33 | .cra_priority = 200, |
34 | .cra_flags = CRYPTO_ALG_TYPE_RNG, |
35 | .cra_ctxsize = 0, |
36 | .cra_type = &crypto_rng_type, |
37 | .cra_module = THIS_MODULE, |
38 | .cra_list = LIST_HEAD_INIT(krng_alg.cra_list), |
39 | .cra_u = { |
40 | .rng = { |
41 | .rng_make_random = krng_get_random, |
42 | .rng_reset = krng_reset, |
43 | .seedsize = 0, |
44 | } |
45 | } |
46 | }; |
47 | |
48 | |
49 | /* Module initalization */ |
50 | static int __init krng_mod_init(void) |
51 | { |
52 | return crypto_register_alg(&krng_alg); |
53 | } |
54 | |
55 | static void __exit krng_mod_fini(void) |
56 | { |
57 | crypto_unregister_alg(&krng_alg); |
58 | return; |
59 | } |
60 | |
61 | module_init(krng_mod_init); |
62 | module_exit(krng_mod_fini); |
63 | |
64 | MODULE_LICENSE("GPL"); |
65 | MODULE_DESCRIPTION("Kernel Random Number Generator"); |
66 | MODULE_ALIAS("stdrng"); |
67 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9