2008-09-19 01:26:27 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! Copyright (C) 2008 Doug Coleman
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! See http://factorcode.org/license.txt for BSD license.
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-02 16:57:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								USING: alien.c-types io io.files kernel namespaces random
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								io.encodings.binary init accessors system ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-19 17:18:03 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: random.unix
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-02 16:57:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								TUPLE: unix-random reader ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-28 23:10:01 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-02 16:57:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: <unix-random> ( path -- random )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    binary <file-reader> unix-random boa ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-19 17:18:03 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-28 23:10:01 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								M: unix-random random-bytes* ( n tuple -- byte-array )
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-02 16:57:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    reader>> stream-read ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-19 17:18:03 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-04-03 01:59:20 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								os openbsd? [
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-30 07:45:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "/dev/srandom" <unix-random> secure-random-generator set-global
							 | 
						
					
						
							
								
									
										
										
										
											2008-04-12 22:35:07 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "/dev/arandom" <unix-random> system-random-generator set-global
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-30 07:45:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] "random.unix" add-init-hook
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "/dev/random" <unix-random> secure-random-generator set-global
							 | 
						
					
						
							
								
									
										
										
										
											2008-04-12 22:35:07 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "/dev/urandom" <unix-random> system-random-generator set-global
							 | 
						
					
						
							
								
									
										
										
										
											2008-03-30 07:45:38 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] "random.unix" add-init-hook
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								] if
							 |