Cryptography proof randomizer

This forum is for general developer support questions.
Post Reply
softwarefailure
Posts: 96
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: 591
Joined: Sat Jun 18, 2011 2: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"

User avatar
Raziel
Posts: 927
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

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?
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg

User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 591
Joined: Sat Jun 18, 2011 2: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

User avatar
Raziel
Posts: 927
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: Cryptography proof randomizer

Post by Raziel »

:blush:

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


Thanks
;-)
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg

softwarefailure
Posts: 96
Joined: Fri Feb 14, 2014 10:29 pm

Re: Cryptography proof randomizer

Post by softwarefailure »

@broadblues: Thanks for the pointer!

Post Reply