Changeset 147 for trunk/src/sh_entropy.c


Ignore:
Timestamp:
Nov 26, 2007, 8:34:29 PM (17 years ago)
Author:
katerina
Message:

Fix regression in the seeding routine of the PRNG

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_entropy.c

    r138 r147  
    295295      if (0 == sh_unix_device_readable(fd2))
    296296        {
    297           m_count = sl_read_timeout_fd(fd2, &nbuf, nbytes,
     297          m_count = sl_read_timeout_fd(fd2, nbuf, nbytes,
    298298                                       timeout_val, SL_FALSE);
    299299          if (m_count < 0)
     
    387387      SH_MUTEX_UNLOCK_UNSAFE(mutex_skey);
    388388      memset (keybuf, '\0', KEY_BYT);
     389      memset (kbuf,   '\0', sizeof(kbuf));
    389390     
    390391      SL_RETURN(0, _("sh_entropy"));
     
    960961#endif
    961962
    962 
    963 
    964 
    965 
    966 
    967 
     963#ifdef SH_CUTEST
     964#include "CuTest.h"
     965
     966void Test_entropy (CuTest *tc)
     967{
     968  char                 bufx[9 * sizeof(UINT32) + 1];
     969  char                 bufy[9 * sizeof(UINT32) + 1];
     970  int                  status;
     971
     972  memset(skey->poolv, '\0', KEY_BYT);
     973
     974  status = sh_entropy (24, bufx);
     975  CuAssertTrue(tc, 0 == status);
     976
     977  memset(skey->poolv, '\0', KEY_BYT);
     978
     979  status = sh_entropy (24, bufy);
     980  CuAssertTrue(tc, 0 == status);
     981
     982  CuAssertTrue(tc, 0 != memcmp(bufx, bufy, 24));
     983}
     984#endif
     985
     986
     987
     988
     989
     990
     991
     992
Note: See TracChangeset for help on using the changeset viewer.