Re: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-19 Thread Mike Hummel
So this solution does work, however it doesn't answer the question as to 
why this is occurring in the first place.
Rather then finding a work around for it, I'd like to know why PHP / 
mcrypt is throwing the error.  Is it an issue in the library itself?

Tom Rogers wrote:
Hi,
Saturday, April 9, 2005, 3:35:21 AM, you wrote:
MH I have an odd php issue with mcrypt.
MH I'm getting a lot of this type of error, but only sometimes:
MH mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32
MH (note, the supplied length: 0 is not always the same.  sometimes it is
MH 1, 16, etc).
MH It doesn't seem to affect the decoding of the file, but it is throwing a
MH notice in to my error log. I've tried doing this:
MH @mcrypt_generic_init($this-td, $key, $iv)
MH but that doesn't stop it from throwing an error.
MH The only thing I can think is that I have
MH mcrypt_module_close($this-td) 
MH commented out because my code was dying with it...

MH System:
MH Linux w/ Apache 1.3.31
MH PHP Version 4.3.4
MH libmcrypt version 2.5.7
MH Suggestions?
I do this to set a zero iv
$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-12 Thread Mike Hummel
Do you do this on the encryption or the decryption section or both?
Tom Rogers wrote:
Hi,
Saturday, April 9, 2005, 3:35:21 AM, you wrote:
MH I have an odd php issue with mcrypt.
MH I'm getting a lot of this type of error, but only sometimes:
MH mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32
MH (note, the supplied length: 0 is not always the same.  sometimes it is
MH 1, 16, etc).
MH It doesn't seem to affect the decoding of the file, but it is throwing a
MH notice in to my error log. I've tried doing this:
MH @mcrypt_generic_init($this-td, $key, $iv)
MH but that doesn't stop it from throwing an error.
MH The only thing I can think is that I have
MH mcrypt_module_close($this-td) 
MH commented out because my code was dying with it...

MH System:
MH Linux w/ Apache 1.3.31
MH PHP Version 4.3.4
MH libmcrypt version 2.5.7
MH Suggestions?
I do this to set a zero iv
$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-12 Thread Mike Hummel
I get the following error when I try your suggestion:
Unknown error type: [8] Undefined variable:  iv
Code:
$key = md5($this-_cypherkey);
$key = substr($key, 0, mcrypt_enc_get_key_size($this-td));
$iv_size = mcrypt_enc_get_iv_size($this-td);
#$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$iv = pack(a.$iv_size,$iv);
Tom Rogers wrote:
Hi,
Saturday, April 9, 2005, 3:35:21 AM, you wrote:
MH I have an odd php issue with mcrypt.
MH I'm getting a lot of this type of error, but only sometimes:
MH mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32
MH (note, the supplied length: 0 is not always the same.  sometimes it is
MH 1, 16, etc).
MH It doesn't seem to affect the decoding of the file, but it is throwing a
MH notice in to my error log. I've tried doing this:
MH @mcrypt_generic_init($this-td, $key, $iv)
MH but that doesn't stop it from throwing an error.
MH The only thing I can think is that I have
MH mcrypt_module_close($this-td) 
MH commented out because my code was dying with it...

MH System:
MH Linux w/ Apache 1.3.31
MH PHP Version 4.3.4
MH libmcrypt version 2.5.7
MH Suggestions?
I do this to set a zero iv
$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re[2]: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-12 Thread Tom Rogers
Hi,

Wednesday, April 13, 2005, 5:14:25 AM, you wrote:
MH Do you do this on the encryption or the decryption section or both?

I do it on both, here is a class I use that may help:


class encryptClass{
  var $secret;
  function encryptClass(){
$this-secret = 'put secret here';
  }
  Function encode($id){
$eid = $iv = 0;
$len = strlen($id);
$id = $len.'-'.$id;
$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$eid = base64_encode(mcrypt_generic ($td, $id));
mcrypt_generic_deinit($td);
return $eid;
  }
  Function decode($eid){
$id = $iv = 0;
$td = mcrypt_module_open (MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);
$id = mdecrypt_generic ($td, base64_decode($eid));
$len = strtok($id,'-');
$id = substr($id,(strlen($len)+1),$len);
mcrypt_generic_deinit($td);
return $id;
  }
}


( I encode the length of the original string so I can trim the extra
rubbish that deinit leaves behind as packing)

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-12 Thread Tom Rogers
Hi,

Wednesday, April 13, 2005, 6:04:05 AM, you wrote:
MH I get the following error when I try your suggestion:

MH Unknown error type: [8] Undefined variable:  iv

MH Code:

$key = md5($this-_cypherkey);
MH $key = substr($key, 0, mcrypt_enc_get_key_size($this-td));
MH $iv_size = mcrypt_enc_get_iv_size($this-td);
MH #$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
MH $iv = pack(a.$iv_size,$iv);

Yes I forgot to put $iv = 0; before that line.
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-08 Thread Mike Hummel
I have an odd php issue with mcrypt.
I'm getting a lot of this type of error, but only sometimes:
mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32
(note, the supplied length: 0 is not always the same.  sometimes it is 
1, 16, etc).

It doesn't seem to affect the decoding of the file, but it is throwing a 
notice in to my error log. I've tried doing this:

@mcrypt_generic_init($this-td, $key, $iv)
but that doesn't stop it from throwing an error.
The only thing I can think is that I have mcrypt_module_close($this-td) 
commented out because my code was dying with it...

System:
   Linux w/ Apache 1.3.31
   PHP Version 4.3.4
   libmcrypt version 2.5.7
Suggestions?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mcrypt_generic_init(): Iv size incorrect

2005-04-08 Thread Tom Rogers
Hi,

Saturday, April 9, 2005, 3:35:21 AM, you wrote:
MH I have an odd php issue with mcrypt.
MH I'm getting a lot of this type of error, but only sometimes:

MH mcrypt_generic_init(): Iv size incorrect; supplied length: 0, needed: 32

MH (note, the supplied length: 0 is not always the same.  sometimes it is
MH 1, 16, etc).

MH It doesn't seem to affect the decoding of the file, but it is throwing a
MH notice in to my error log. I've tried doing this:

MH @mcrypt_generic_init($this-td, $key, $iv)

MH but that doesn't stop it from throwing an error.

MH The only thing I can think is that I have
MH mcrypt_module_close($this-td) 
MH commented out because my code was dying with it...

MH System:
MH Linux w/ Apache 1.3.31
MH PHP Version 4.3.4
MH libmcrypt version 2.5.7


MH Suggestions?


I do this to set a zero iv

$td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, );
$key = substr($secret, 0, mcrypt_enc_get_key_size ($td));
$iv = pack(a.mcrypt_enc_get_iv_size($td),$iv);
mcrypt_generic_init ($td, $key, $iv);

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php