The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/crypto/krng.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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_u                  = {
   39                 .rng = {
   40                         .rng_make_random        = krng_get_random,
   41                         .rng_reset              = krng_reset,
   42                         .seedsize               = 0,
   43                 }
   44         }
   45 };
   46 
   47 
   48 /* Module initalization */
   49 static int __init krng_mod_init(void)
   50 {
   51         return crypto_register_alg(&krng_alg);
   52 }
   53 
   54 static void __exit krng_mod_fini(void)
   55 {
   56         crypto_unregister_alg(&krng_alg);
   57         return;
   58 }
   59 
   60 module_init(krng_mod_init);
   61 module_exit(krng_mod_fini);
   62 
   63 MODULE_LICENSE("GPL");
   64 MODULE_DESCRIPTION("Kernel Random Number Generator");
   65 MODULE_ALIAS("stdrng");

Cache object: 862165b91b8d8f96155460e7261d3bcd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.