Changeset 2801


Ignore:
Timestamp:
Apr 16, 2009, 10:43:02 AM (16 years ago)
Author:
Christoph Mayer
Message:

-rand seeding in StartupWrapper gezogen
-bessere rands für identifier

Location:
source/ariba/utility
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/utility/misc/KeyMapping.hpp

    r2800 r2801  
    6969public:
    7070        inline KeyMapping(){
    71                 srand(time(0));
     71                srand( time(NULL) );
    7272        }
    7373
  • source/ariba/utility/system/StartupWrapper.cpp

    r2800 r2801  
    7878        if( initialized ) return;
    7979        initialized = true;
     80
     81        //
     82        // having seeded the pseudo rng is always good
     83        //
     84
     85        srand( time(NULL) );
    8086
    8187        //
  • source/ariba/utility/types/Identifier.cpp

    r2457 r2801  
    598598
    599599        //as mpn_random has no seeding function
    600         // we mess aroung here a little to achive randomness
     600        // we mess aroung here a little to achive some randomness
     601        // using the rand function that _is_ seeded in the
     602        // StartupWrapper::initSystem function
     603
    601604        Identifier keyRandom = ZERO;
    602605        mpn_random(keyRandom.key, aSize);
    603         Identifier keyTime( time(NULL) );
    604         mpn_mul_1( newKey.key, keyRandom.key, aSize, *keyTime.key );
     606        Identifier keyrnd( rand() );
     607        mpn_mul_1( newKey.key, keyRandom.key, aSize, *keyrnd.key );
    605608
    606609        newKey.trim();
     
    608611}
    609612
    610 
    611 // README: due to some problems with serialization the keylength
    612 // was changed to 192 bit! As none of the hashing functions
    613 // can provide 160 bit output, and we currently don't use any
    614 // hashing for identifiers in the demo at all ... this is all commented out!!
    615 
    616 
    617 // generate sha1 hash
    618613Identifier Identifier::sha1(const string& input) {
    619614        Identifier newKey;
     
    652647}
    653648
    654 
    655 
    656649// generate a key=2**exponent
    657650Identifier Identifier::pow2(uint exponent) {
Note: See TracChangeset for help on using the changeset viewer.