Hi,
I'm getting some strange errors that I cannot pin down:
Warning: mcrypt_generic_ init(): Iv size incorrect; supplied length: 7,
needed: 8 in......
This is strange because the data is encrypted, inserted into the
databse, then later retrieved and decrypted with the necessary hash and
ivector keys.
The data itself is decrypted OK. But the error comes up.
The error does not occur when I run the same code on another machine
running on Mac OS X.
Is this a known bug on this FreeBSD build ?
As this is for a production site, I'm just tempted to set the
error_reporting directive in php.ini to off, as this looks bad when the
error flashes up, but is actually not causing any errors.
I did change alter the initialisation function to:
@mcrypt_generic _init()
but it still displays the error regardless.
This may be a bit obscure, but has anybody else encountered a similar
problem ?
Thanks
SS. 5 3059 Warning: mcrypt_generic_ init(): Iv size incorrect; supplied length: 7, needed: 8 in......
Can you post a minimal example of code that produces the warning
message.
---
Steve
OK,
I use the following settings:
$cipher = MCRYPT_GOST;
$mode = MCRYPT_MODE_ECB ;
$rand_src = MCRYPT_RAND;
I then randomly generate a hash and assign it to variable $hash, run it
through addslashes(), and use the following to encrypt:
$handle = mcrypt_module_o pen ($cipher, '', $mode, '');
if (!$handle)
die ("Couldn't locate open mcrypt module.");
$ivector =
mcrypt_create_i v(mcrypt_get_iv _size($cipher,$ mode),$rand_src );
if (mcrypt_generic _init ($handle, $hash, $ivector) == -1)
die ("Error: mcrypt failure.");
$address1 = addslashes(mcry pt_generic($han dle,$address1)) ;
$address2 = addslashes(mcry pt_generic($han dle,$address2)) ;
$address3 = addslashes(mcry pt_generic($han dle,$address3)) ;
$address4 = addslashes(mcry pt_generic($han dle,$address4)) ;
$address5 = addslashes(mcry pt_generic($han dle,$address5)) ;
$postcode = addslashes(mcry pt_generic($han dle,$postcode)) ;
$firstname = addslashes(mcry pt_generic($han dle,$firstname) );
$surname = addslashes(mcry pt_generic($han dle,$surname));
$telephone = addslashes(mcry pt_generic($han dle,$telephone) );
$em = addslashes(mcry pt_generic($han dle,$email));
$ivector = addslashes($ive ctor);
$username = addslashes($ema il);
mcrypt_generic_ deinit($handle) ;
These are inserted into the database tables, then I later decrypt with:
$site_sql="SELE CT * FROM security WHERE client_id ='$client_id' LIMIT
1";
$site_get = mysql_query($si te_sql) or die (mysql_error()) ;
while ($row = mysql_fetch_arr ay($site_get))
{
$hash_temp = stripslashes($r ow['hash']);
$iv_temp = stripslashes($r ow['iv']);
}
$site_sql="SELE CT * FROM client WHERE client_id ='$client_id' LIMIT 1";
$site_get = mysql_query($si te_sql) or die (mysql_error()) ;
while ($row = mysql_fetch_arr ay($site_get))
{
$handle = @mcrypt_module_ open ($cipher, '', $mode, '');
if (!$handle)
die ("Couldn't locate open mcrypt module.");
if (@mcrypt_generi c_init ($handle, $hash_temp, $iv_temp) == -1)
die ("Error: mcrypt failure.");
$title = $row['title'];
$firstname = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['firstname'])));
$surname = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['surname'])));
$address1 = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['address1'])));
$address2 = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['address2'])));
$address3 = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['address3'])));
$address4 = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['address4'])));
$address5 = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['address5'])));
$postcode = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['postcode'])));
$telephone = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['telephone'])));
$email = trim(stripslash es(@mdecrypt_ge neric($handle,
$row['email'])));
@mcrypt_generic _deinit($handle );
}
As I said, the data is decrypted fine. But this error keeps popping
up...
Very obscure....
Thanks
SS As I said, the data is decrypted fine. But this error keeps popping up...
Suggestions:
$ivector = mcrypt_create_i v(mcrypt_get_iv _size($cipher,$ mode),$rand_src );
Break this down into two calls, and check that the size returned from
the first call is what you expect.
$ivsize = mcrypt_get_iv_s ize($cipher,$mo de);
// [ check/debug $ivsize before use ]
$ivector = mcrypt_create_i v($ivsize,$rand _src);
Use <http://www.php.net/manual/en/function.mcrypt-enc-get-iv-size.php>
instead to see if it makes a difference.
$handle = mcrypt_module_o pen($cipher, '', $mode, '');
if(!$handle) die ("Couldn't locate open mcrypt module.");
$ivsize = mcrypt_enc_get_ iv_size($handle );
// [ check/debug $ivsize before use ]
$ivector = mcrypt_create_i v($ivsize,$rand _src);
Or suppress the warning as you suggest, as it seems harmless 8-)
---
Steve
I may just try and surpress the error.
I'm probably getting off the point here, but will the following
command:
ini_set('displa y_errors','0');
surpress ALL errors, or just some errors.
I ask, because on the code I posted above, adding a @ before the mcrypt
functions still caused the error to appear..... ini_set('displa y_errors','0');
You could try turning error reporting off just before the rogue
statement and back on again immediately after:
$oldsetting = ini_set( 'error_reportin g', E_NONE );
// ...rogue statment(s) here...
ini_set( 'error_reportin g', $oldsetting );
---
Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matt McKay |
last post by:
I've written a php page which allows users to type in a text string and a
key, then choose from a dropdown menu of encryption/decryption cyphers, and
a method (encrypt, decrypt).
The whole thing works, except the mcrypt command doesn't work.
here is my mcrypt command:
if ($method == 0) {
//Encrypt
$output = mcrypt_ecb ($algorithm, $key, $input, MCRYPT_ENCRYPT);
|
by: Marek Muszak |
last post by:
Hello,
I try use mcrypt but I want to use key in bytes, not in string. Encrypt
text will be decrypt in Delphi with function where key is 16byte not string.
How can I do this.
Thanks for any help.
best regards
|
by: BKDotCom |
last post by:
I'm writing an app that will use blowfish encryption..
PHP's mcrypt will be used if available.
if not, I'll use PHPmyadmin's blowfish.php library.
The problem is I can't figure out what initialization vector
blowfish.php is useing (or if that's even my problem).
ie, if I encrypt with blowfish.php and decrypt with mcrypt:
/* include path to phpmyadmin '/libraries/blowfish.php'; */
$secret = 'secret';
|
by: believein |
last post by:
Hi all,
I installed PHP thru the XAMPP package on my windows machine.
The problem, I couldn't solve, is that the mcryppt funcs don't work.
It return the following message:
Call to undefined function mcrypt_decrypt() ...
If I write a
<?php
echo ***";
|
by: laredotornado |
last post by:
Hello, My hosting company does not support the PHP mcrypt functions.
Instead, they recomend using the command line, /usr/local/bin/mcrypt
utility via PHP's exec method. Sadly, they do not provide any
documentation how to do this. How would i translate the following
function encryptString($p_str)
{
$iv_size = mcrypt_get_iv_size(MCRYPT_XTEA,
MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
| |
by: sylvian stone |
last post by:
Hi,
I'm getting some strange errors that I cannot pin down:
Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 7,
needed: 8 in......
This is strange because the data is encrypted, inserted into the
databse, then later retrieved and decrypted with the necessary hash and
ivector keys.
|
by: codearcher |
last post by:
I have the latest version of XAMPP installed on Windows XP Pro SP2. I
am trying to use mcrypt with rijnndael-128 on ecb:
"
$cr = mcrypt_module_open('rijndael-128','','ecb','') or
die('<br><br>Could not open Module<br><br>');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($cr), MCRYPT_RAND)
or die('<br><br>Could not create iv<br><br>');
mcrypt_generic_init($cr, $key, $iv) or die('<br><br>Could not
initialize mcrypt<br><br>');
$remix =...
|
by: E. Recio |
last post by:
Long story short. I want to use Mac OS/X and PHP. I have a db with
passwords stored under Linux using the crypt("foo", "$1$".$salt."$);
scheme. This means that crypt should execute a CRYPT_MD5 password hash.
I know that Mac OS/X only supports the two DES'. So is there a way I can
use mcrypt, or mhash or ANY library to reproduce php's CRYPT_MD5 crypt()
call?
I don't really have a choice to use another password hash scheme, as the
data is...
|
by: =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?= |
last post by:
Hi,
I'm having a hard time getting python-mcrypt extension to build.
I installed libmcrypt with --prefix=/usr and I checked that the
library exists
-rwxr-xr-x 1 root wheel 352K Sep 19 16:53 /usr/lib/libmcrypt.
4.4.8.dylib*
lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 /usr/lib/libmcrypt.
4.dylib@ -libmcrypt.4.4.8.dylib
lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 /usr/lib/
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |