Re: Fw: [PEAR-DEV] Re: [RFC] Horde_Cipher -> Crypt_Cipher

From: Date: Sun, 27 Jul 2003 16:01:30 +0000
Subject: Re: Fw: [PEAR-DEV] Re: [RFC] Horde_Cipher -> Crypt_Cipher
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18807@lists.php.net to get a copy of this message
Thanks. Please forward this to whomever needs to see it. I'll try and catch up on the PEAR-DEV mailing list shortly, so I should be able to read any responses. ---- I'm sort of jumping in at the end here, but here's the answers I think you need from me:
Colin: What does CBC do? if it is blocking, can I use it how I'd like? Does it have a place in an all-in-one Crypt_Cipher/Hash package?
Crypt_CBC is basically a translation from Perl into PHP of CPAN's Crypt::CBC. I needed it because I was writing a PHP client that spoke encrypted to a Perl server, and the way that the mcrypt functions handled CBC wasn't compatible with Perl. That said, it was a really quick hack, and basically uses mcrypt to do ECB encryption, and handles the chaining itself. It also uses a standard IV that Crypt::CBC uses so as to be compatible. I would not call this class a good candidate for a general CBC encryption class. Like I said, it's a quick hack and exists solely (for me anyway) to talk to Perl. That said, if you want my opinion on the structuring of a generic cipher/hash class, may I suggest doing something like DB.php or Log.php do? i.e. have one singleton-type class/method that includes the required "driver" class. Each driver class would then have identical methods. You could even split the cipher stuff and hash stuff and have: Cipher.php Cipher_CBC.php Cipher_ECB.php etc. Hash.php Hash_MD5.php Hash_HMAC.php etc. And the code might look like: <? require 'Crypt.php'; $C = Crypt::singleton( 'CBC://Blowfish/RandomIV' ); $C->encrypt('secret message'); ?> That 'CBC://Blowfish/RandomIV' would be some parseable DSN or whatever to let the class know the cipher, algorithm, IV, and any other data needed. The Cipher_* classes would have initialize(), encrypt() and decrypt() methods. The Hash_* classes would (I guess) only have initialize() and hash() methods. Anyway, that's all just IMHO. I'm not a encryption guru by any means, and I really only use Crypt_CBC for one thing right now. I wouldn't be offended if it was removed from PEAR, or renamed or whatever. I'll try and follow along in the newsgroup for the rest of this discussion. - Colin

« previous php.pear.dev (#18807) next »