Connecting Tech Pros Worldwide Help | Site Map

phpmyadmin's blowfish / mcrypt

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:30 PM
BKDotCom
Guest
 
Posts: n/a
Default phpmyadmin's blowfish / mcrypt

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';
$string = 'test string';
$iv = blah;
$encrypted = PMA_blowfish_encrypt($string,$secret);
$decrypted =
trim(mcrypt_decrypt(MCRYPT_BLOWFISH,$secret,base64 _decode($encrypted),MCRYPT_MODE_CBC,$iv));
echo $decrypted;

will output something like
test strÙÚE¦ô<qÕ

Anyhow, how do I make these two interchangeable?


  #2  
Old July 17th, 2005, 01:30 PM
Colin McKinnon
Guest
 
Posts: n/a
Default Re: phpmyadmin's blowfish / mcrypt

BKDotCom wrote:
[color=blue]
> 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';
> $string = 'test string';
> $iv = blah;
> $encrypted = PMA_blowfish_encrypt($string,$secret);
> $decrypted =
>[/color]
trim(mcrypt_decrypt(MCRYPT_BLOWFISH,$secret,base64 _decode($encrypted),MCRYPT_MODE_CBC,$iv));[color=blue]
> echo $decrypted;
>
> will output something like
> test strÙÚE¦ô<qÕ
>
> Anyhow, how do I make these two interchangeable?[/color]

Last time I played around with PHP mcrypt to any extenet I found that the
mcrypt functions were returning C type strings (terminated by '\0') for the
decryption.

Only getting partial output suggests that it may be a string termination
issue somewhere, but you're getting the key right.

I must admit to being rather in the dark regards IVs, but if you're not
supplying one to PMA_Blowfish_encrypt() why do you need one for
mcrypt_decrypt()? (it's optional anyway for CBC). Bearing in mind the issue
regarding C strings and the recommended use of mcrypt_enc_get_iv_size(),
I'd suggest that it is not only advisable to avoid using it for now, it may
even be the source of the error.

HTH

C.



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.