Cryptography proof randomizer

This forum is for general developer support questions.
Post Reply
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Cryptography proof randomizer

Post by softwarefailure »

What's the best way to generate strong random numbers on OS4? It needs to be applicable for cryptography-related contexts so things like srand(time(NULL)) and rand() obviously don't fit because they are never random enough. MorphOS has random.library which does a pretty good job here. Is there an OS4 counterpart or something?
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK
Contact:

Re: Cryptography proof randomizer

Post by broadblues »

AmigaOS 4 has the RANDOM: device

NAME
random_handler -- Pseudo-random data generator (V51)

SYNOPSIS
Open("RANDOM:[TEXT/LINELENGTH=<Number>/SIZE=<Number>]",...);

FUNCTION
Random-Handler generates a contiguous stream of data using a
pseudo-random number generator based upon the SHA-256 cryptographic
hash function. The generator is reseeded regularly using the
timer.device entropy gathering process.

The RANDOM: device defaults to generate binary data. To produce
ASCII text data instead, use the TEXT switch. To limit the lengths
of the text lines produced, use the LINELENGTH=<Number> option.
By default, the RANDOM: device will generate a neverending stream
of data. You can limit the amount of data produced with the
SIZE=<Number> option.

PACKETS
ACTION_FINDINPUT
ACTION_READ
ACTION_END
ACTION_IS_FILESYSTEM

NOTE
Access to the RANDOM: device is read-only.

EXAMPLES
Produce 500 bytes of binary data; print the data with the
"Type" shell command:

1> Type "RANDOM:SIZE=500" HEX

Produce 80 characters; print the text with the "Type" shell
command:

1> Type "RANDOM:TEXT/SIZE=80"

Produce text characters, 80 characters per line; print the text
with the "Type" shell command:

1> Type "RANDOM:TEXT/LINELENGTH=80"
Raziel

Re: Cryptography proof randomizer

Post by Raziel »

It doesn't seem to produce any umlauts in there.

Why is that?
Some sort of ASCII, ISO or UTF restriction?
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK
Contact:

Re: Cryptography proof randomizer

Post by broadblues »

@Raziel
To produce
ASCII text data instead, use the TEXT switch.
There might be clue in the above text
Raziel

Re: Cryptography proof randomizer

Post by Raziel »

:blush:

Well...uh, is that the time...gotta run


Thanks
;-)
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: Cryptography proof randomizer

Post by softwarefailure »

@broadblues: Thanks for the pointer!
Post Reply