mcrypt_enc_get_iv_size not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Slaughter

    mcrypt_enc_get_iv_size not working

    mcrypt_enc_get_ iv_size is not randomizing the vector. I have tried to
    randomize the seed in various ways but it always returns the same output.

    My current code as follows:

    for($i = 1; $i < 5; $i++)
    {
    list($usec, $sec) = explode(' ', microtime());
    srand((float) $sec + ((float) $usec * 100000));

    $iv = mcrypt_create_i v(mcrypt_enc_ge t_iv_size($this->CryptRes),
    MCRYPT_RAND);
    echo $iv."<br/>\n";
    }

    It outputs the same string each time.


    Any ideas?

    Thanks,
    Jon


  • Jon Slaughter

    #2
    Re: mcrypt_enc_get_ iv_size not working

    Of course I meant mcrypt_create_i v...


    Comment

    • C.

      #3
      Re: mcrypt_enc_get_ iv_size not working

      On 31 May, 19:27, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
      Of course I meant mcrypt_create_i v...
      Code looks OK.

      Are you getting a sensible value for mcrypt_enc_get_ iv_size($this-
      >CryptRes) ?
      Have you tried using the devices as an entropy source?

      IIRC mcrypt uses binary strings, in some cases it even assigns C
      strings to PHP strings; it might be a better idea to encode the output
      before writing to the console/browser:

      echo base64_encode($ iv) ."<br/>\n";

      C.

      Comment

      • Jon Slaughter

        #4
        Re: mcrypt_enc_get_ iv_size not working


        "C." <colin.mckinnon @gmail.comwrote in message
        news:1180647949 .867403.167430@ o5g2000hsb.goog legroups.com...
        On 31 May, 19:27, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
        >Of course I meant mcrypt_create_i v...
        >
        Code looks OK.
        >
        Are you getting a sensible value for mcrypt_enc_get_ iv_size($this-
        >>CryptRes) ?
        >
        yeah, its a bug in mcrypt and I randomized the string it returned myself.
        Have you tried using the devices as an entropy source?
        >
        IIRC mcrypt uses binary strings, in some cases it even assigns C
        strings to PHP strings; it might be a better idea to encode the output
        before writing to the console/browser:
        >
        echo base64_encode($ iv) ."<br/>\n";
        >
        Well, it was just for a test.. in reality there is no writing to the
        console. Was just trying to figure why my strings were not being randomized.

        Thanks,
        Jon


        Comment

        Working...