[前][次][番号順一覧][スレッド一覧]

ruby-changes:12487

From: nobu <ko1@a...>
Date: Sat, 18 Jul 2009 09:07:27 +0900 (JST)
Subject: [ruby-changes:12487] Ruby:r24187 (trunk): * random.c (fill_random_seed): use cryptographic service on Windows.

nobu	2009-07-18 09:07:07 +0900 (Sat, 18 Jul 2009)

  New Revision: 24187

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24187

  Log:
    * random.c (fill_random_seed): use cryptographic service on Windows.

  Modified files:
    trunk/ChangeLog
    trunk/random.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24186)
+++ ChangeLog	(revision 24187)
@@ -1,3 +1,7 @@
+Sat Jul 18 09:07:00 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* random.c (fill_random_seed): use cryptographic service on Windows.
+
 Sat Jul 18 07:56:00 2009  Hidetoshi NAGAI  <nagai@a...>
 
 	* ext/tk/lib/tk.rb: fail to create a widget object for an unknown
Index: random.c
===================================================================
--- random.c	(revision 24186)
+++ random.c	(revision 24187)
@@ -389,6 +389,8 @@
 #if USE_DEV_URANDOM
     int fd;
     struct stat statbuf;
+#elif defined(_WIN32)
+    HCRYPTPROV prov;    
 #endif
 
     memset(seed, 0, DEFAULT_SEED_LEN);
@@ -410,6 +412,11 @@
         }
         close(fd);
     }
+#elif defined(_WIN32)
+    if (CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
+	CryptGenRandom(prov, DEFAULT_SEED_LEN, seed);
+	CryptReleaseContext(prov, 0);
+    }
 #endif
 
     gettimeofday(&tv, 0);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]