• Post Reply Bookmark Topic Watch Topic
  • New Topic

Random stream cut off

 
Matthias Antioch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all, I have designed a class, specifically designed for unix systems which dumps a specified number of bytes from the /dev/random block device to a specified binary file. Unfortunately I discovered that while java will read and copy 128 bytes of data, after that, the stream puts out zeros. IE: If I request a 256 byte file, it will give 128 bytes random data, and 128 bytes of zeroes.

Further complicating the matter is the fact that the exact same code, directed to the /dev/urandom device, performs flawlessly. I have checked the entropy pool, and there is more than enough entropy to fill the need. The presentation makes me think it is a limitation of the system, and not java, but I cannot find any reference to the problem online.

Any help would be greatly appreciated!
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing your code, I'm just guessing, but I'll bet that ReadDoesntDoWhatYouThinkItDoes

 
Matthias Antioch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:Without seeing your code, I'm just guessing, but I'll bet that ReadDoesntDoWhatYouThinkItDoes



You nailed it exactly. I completely forgot /dev/random blocks on linux, and what that does to FileInputStream. If I could give karma, you would have it.

Mods, please close thread
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!