Project 1999

Go Back   Project 1999 > General Community > Rants and Flames

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 03-14-2014, 06:17 PM
r00t r00t is offline
Sarnak


Join Date: Jun 2013
Posts: 330
Thumbs down linear congruential generators & you

the standard gcc library definition for rand() is a simple linear congruential generator

Code:
static unsigned long int next = 1;

int rand(void) // RAND_MAX assumed to be 32767
{
    next = next * 1103515245 + 12345;
    return (unsigned int)(next/65536) % 32768;
}

void srand(unsigned int seed)
{
    next = seed;
}
Quote:
Linear congruential generator should also not be used for cryptographic applications; see cryptographically secure pseudo-random number generator for more suitable generators. If a linear congruential generator is seeded with a character and then iterated once, the result is a simple classical cipher called an affine cipher; this cipher is easily broken by standard frequency analysis.
if you think the embedded devices like your router or printer et al. is using anything fancier you are sadly mistaken

these are your x.509 certificates we're talking about here people
  #2  
Old 03-14-2014, 06:18 PM
Weyoun the Vorta Weyoun the Vorta is offline
Banned


Join Date: Feb 2014
Location: The Gamma Quadrant
Posts: 14
Default

Shut up
  #3  
Old 03-14-2014, 06:19 PM
Daldolma Daldolma is offline
Fire Giant


Join Date: Jun 2010
Posts: 644
Default

wat about ayn though
  #4  
Old 03-14-2014, 06:21 PM
SamwiseRed SamwiseRed is offline
Planar Protector

SamwiseRed's Avatar

Join Date: Dec 2011
Location: Tatooine
Posts: 10,176
Default

im going back to school for computer science, maybe ill understand wtf this is all about soon.

maybe not.
__________________
Current Games:
Naw
  #5  
Old 03-14-2014, 06:21 PM
r00t r00t is offline
Sarnak


Join Date: Jun 2013
Posts: 330
Default

when your "random" number generator uses 12345 as a magic constant..... you "might" have a security vulnerability

[You must be logged in to view images. Log in or Register.]
  #6  
Old 03-14-2014, 06:23 PM
r00t r00t is offline
Sarnak


Join Date: Jun 2013
Posts: 330
Default

Let me see if I can put this in a way ya'll can understand. Studying the ramifications of this mathematical function is justification for ninalooting if you lose a /random
  #7  
Old 03-14-2014, 06:25 PM
Weyoun the Vorta Weyoun the Vorta is offline
Banned


Join Date: Feb 2014
Location: The Gamma Quadrant
Posts: 14
Default

Ninalooting you say.
  #8  
Old 03-14-2014, 06:31 PM
quido quido is offline
Planar Protector

quido's Avatar

Join Date: Oct 2009
Posts: 5,501
Default

http://en.wikipedia.org/wiki/Mersenne_twister
__________________
Bush <Toxic>
Jeremy <TMO> - Patron Saint of Blue
  #9  
Old 03-15-2014, 09:05 PM
r00t r00t is offline
Sarnak


Join Date: Jun 2013
Posts: 330
Default

I implemented mersenne twister in pure C


PHP Code:
static const unsigned int MT_STATE_SIZE 624;

static 
unsigned int mt_state[MT_STATE_SIZE] = { };
static 
unsigned int mt_index 0;

static const 
unsigned int SEED_CONST 0x6c078965;
static const 
unsigned int EXTRACT1_CONST 0x9d2c5680;
static const 
unsigned int EXTRACT2_CONST 0xefc60000;
static const 
unsigned int GENERATE_CONST 0x9908b0df
PHP Code:
unsigned int mt_rand()
{
    if (
mt_index == 0)
    {
        for (
int i 0MT_STATE_SIZE; ++i)
        {
            
unsigned int y = (mt_state[i] & 0x80000000
                + (
mt_state[(1) % MT_STATE_SIZE && 0x7fffffff]); 

            
mt_state[i] = mt_state[(397) % MT_STATE_SIZE] ^ (>> 1);

            if (
!= 0)
                
mt_state[i] ^= GENERATE_CONST;
        }
    }

    
int y mt_state[mt_index];

    
^= (>> 11);
    
^= (<< 7) & EXTRACT1_CONST;
    
^= (<< 15) & EXTRACT2_CONST;
    
^= (>> 18);

    ++
mt_index;
    
mt_index %= MT_STATE_SIZE;

    return 
y;

PHP Code:
void seed_mt_rand(int seed)
{
    
mt_index 0;
    
mt_state[0] = seed;

    for (
unsigned int i 1MT_STATE_SIZE; ++i)
        
mt_state[i] = (SEED_CONST * (mt_state[1] ^ (mt_state[1] >> 30)) + i)) & 0xFFFFFFFF;

by freely releasing this code I could possibly be breaking a non-compete agreement so yw
  #10  
Old 03-15-2014, 09:14 PM
Doors Doors is offline
Planar Protector

Doors's Avatar

Join Date: Apr 2011
Location: Pittsburgh
Posts: 2,933
Default

?
__________________
Quote:
Originally Posted by Drakaris View Post
You can be my squire once you can bench half of what I can.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:39 PM.


Everquest is a registered trademark of Daybreak Game Company LLC.
Project 1999 is not associated or affiliated in any way with Daybreak Game Company LLC.
Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.