AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

More secure random numbers
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
greynite



Joined: 17 May 2008
Posts: 32
Location: Dallas, TX

PostPosted: Fri Jan 02, 2009 8:44 am    Post subject: Reply with quote

Laszlo wrote:
Yes, you can do that. TEA is even faster
I thought TEA was fairly broken? Do it's faults not apply to this use?
Quote:
Keep in mind that AHK's built in random number generator is two orders of magnitude faster, so only use ciphers for secure random numbers, for higher quality requirements.
Speaking of which, is there any way to drop fresh entropy -- e.g. GUID output -- into the internal state of the built-in RNG? I was reading some of your archive posts about the twister's poor applicability for security.

Thanks,
Shawn
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Fri Jan 02, 2009 3:15 pm    Post subject: Reply with quote

The XTEA version posted in the Forum is not broken, but it is not as secure AES. TEA's advantages are its speed, small footprint and the flexibility in the number of rounds, which allows tuning it to your security requirements. There are even faster and similarly secure alternatives.

The difficulty with the Mersenne Twister, built in AHK is that its large table is initialized with a Linear Congruential Generator. If you re-seed it often, you degrade the randomness to that of the LCG. If you don't re-seed it, the simple twister algorithm can be inverted, the seed guessed. Maybe the best is to use a few different simple, fast pseudorandom number generators, and add/XOR their results. The seeds could be derived from a couple of GUID's, not the AHK's default tick count alone, which does not provide enough entropy.
Back to top
View user's profile Send private message
greynite



Joined: 17 May 2008
Posts: 32
Location: Dallas, TX

PostPosted: Wed Jan 28, 2009 5:26 am    Post subject: Reply with quote

Laszlo wrote:
The XTEA version posted in the Forum is not broken[..]

The difficulty with the Mersenne Twister, built in AHK is that its large table is initialized with a Linear Congruential Generator. If you re-seed it often, you degrade the randomness to that of the LCG. If you don't re-seed it, the simple twister algorithm can be inverted, the seed guessed. Maybe the best is to use a few different simple, fast pseudorandom number generators, and add/XOR their results. The seeds could be derived from a couple of GUID's, not the AHK's default tick count alone, which does not provide enough entropy.


So how about using the GUID / XTEA + builtin random() ? e.g.:
Code:

TRandom()
{
  if (not rounds) {
    tweak = GUIDRandom()
    rounds = 100
  }
  rounds -= 1
  return Mod( tweak + random(), 1.0 )
}


thoughts? I figure 99% of the time we're just adding overhead of three extra math operations & a user function call versus just using builtin random() directly, but getting the benefit of less predicable numbers coming out of the twister.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Wed Jan 28, 2009 7:32 am    Post subject: Reply with quote

The differences between consecutive random numbers generated this way are (roughly) the same as the differences of the random numbers generated by the built in generator, most of the time, therefore there is practically no security. Generating secure random numbers is not easy, and these speedups usually turn out bad.
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 144

PostPosted: Tue Apr 21, 2009 4:34 pm    Post subject: get GUID in PC Reply with quote

Hi Laszlo,

what is the function to get
GUID of a PC
that was created by some other tool ?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Tue Apr 21, 2009 7:06 pm    Post subject: Reply with quote

The Windows GUID is different at each call. If the other application does not tell what it got, there is no way to discover that old instance of the GUID.
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 144

PostPosted: Wed Apr 22, 2009 6:37 am    Post subject: Reply with quote

it was created with delphi:
CoCreateGUID(guid)
and then converted to string

can it help ?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Wed Apr 22, 2009 6:50 am    Post subject: Reply with quote

The Delphi program can write its GUID to disk, and you can read it from there (or from the registry, or sent as a parameter of a Windows message, etc.).
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 144

PostPosted: Wed Apr 22, 2009 12:38 pm    Post subject: Reply with quote

how I can read it with ahk ?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Wed Apr 22, 2009 3:59 pm    Post subject: Reply with quote

It depends to where and how it is written
Back to top
View user's profile Send private message
rani



Joined: 18 Mar 2008
Posts: 144

PostPosted: Sat May 02, 2009 5:08 pm    Post subject: Reply with quote

hi laslo,

I need to get uinque ID of client PC

how I can define some simple own GUID , for first time if it's not defined
and if defined get it's value ?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4514
Location: Boulder, CO

PostPosted: Sat May 02, 2009 5:16 pm    Post subject: Reply with quote

These are random looking numbers, always different when you generate them. It does not matter if they are generated in the client machine or in your own. You probably want a secure fingerprint of the client, which is also a random looking number, but when generated repeatedly it remains the same until the PC configuration changes. See here.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group