Add crypt_keyslot_area() API call.
[platform/upstream/cryptsetup.git] / lib / random.c
index a0c693d..5de4214 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * cryptsetup kernel RNG access functions
  *
- * Copyright (C) 2010-2011, Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2012, Red Hat, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <stdlib.h>
@@ -176,7 +176,17 @@ int crypt_random_get(struct crypt_device *ctx, char *buf, size_t len, int qualit
        case CRYPT_RND_NORMAL:
                status = _get_urandom(ctx, buf, len);
                break;
+       case CRYPT_RND_SALT:
+               if (crypt_fips_mode())
+                       status = crypt_backend_rng(buf, len, quality, 1);
+               else
+                       status = _get_urandom(ctx, buf, len);
+               break;
        case CRYPT_RND_KEY:
+               if (crypt_fips_mode()) {
+                       status = crypt_backend_rng(buf, len, quality, 1);
+                       break;
+               }
                rng_type = ctx ? crypt_get_rng_type(ctx) :
                                 crypt_random_default_key_rng();
                switch (rng_type) {