ecb works , but cfb and cbc don't ( php )



I am reading that cbc and cfb are better than ecb, but I can not get
this php code below to work. It works fine for ebc, but not for cbc or
cfb. What could I be missing? Is it something to do with the byte
length of the input string? If I use a longer string, I notice it does
decrypt some of the string ok, but not the beginning?

<?php

$input = 'Hello World Today';
$key = '12345';

$td = mcrypt_module_open('rijndael-128', '', 'cbc', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND );
mcrypt_generic_init($td, $key, $iv);

$encrypted_data = mcrypt_generic($td, $input);

$decrypted = mdecrypt_generic($td, $encrypted_data );

?>

.



Relevant Pages

  • Re: enc and auth scheme with tiny cryptograms
    ... CTR has a better security reduction. ... CFB and OFB modes offer equivalent ... For instance I would never use CBC because AFAICS ... stealing lets you use CBC mode without padding or ciphertext expansion. ...
    (sci.crypt)
  • SERPENT application
    ... algorithm with possibility of coding in various modes (ECB, CBC, CFB, ... OFB). ... I need it for efficiency testing. ...
    (sci.crypt)
  • Re: Is RC4 a good choice?
    ... >> Maybe you could use Skipjack CBC MAC and avoid the need for another ... >I thought about CBC as MAC method, but since transmission time/power is most ... time/power makes CFB better than CBC for encryption. ... use CFB for encryption, you can still use CBC-MAC for integrity. ...
    (sci.crypt)
  • Re: Block Cipher Applications
    ... ECB, CBC, CFB, OFB and CTR.A line each as to why it is suited for that ...
    (sci.crypt)
  • Block Cipher Applications
    ... ECB, CBC, CFB, OFB and CTR.A line each as to why it is suited for that ...
    (sci.crypt)