Recommend this page to a friend! |
Classes of Jose Luis Lucas | Pure PHP Rijndael-128 to 256 | README.md | Download |
|
Downloadaes128cbcWHY A NEW RIJNDAEL CLASS? I WANTED TO MAKE A PURE CLASS WITHOUT HELP-TABLES, ONLY THE PURE COMPUTING ON DATA AS IS RIJNDAEL ENCRYPTION. THIS IS A BIT MORE COMPLICATED AS THE ROW SHIFTING AND MIXING COLUMNS GALOIS ARE NOT EASY TO IMPLEMENT, AND I HAVE NOT FOUND ON THE WEB ANYTHING SIMILAR. Pure PHP Rijndael/AES code for 128 bits block CBC This is PURE RIJNDAEL IMPLEMENTATION with each step explained
USAGE:
RIJNDAELPure PHP Rijndael/AES code for 128 to 256 bits block ECB,CBC,CTR,CFB,OFB & GCM This is PURE RIJNDAEL IMPLEMENTATION with each step explained PRETTY SHORT WITHOUT TABLES SBOX IS GENERATED BY DEFAULT 16 BYTE BLOCK SIZE (AES STANDARD) AND CBC, BUT YOU CAN ENCRYPT IN 20,24,28 AND 32 BYTES BLOCK SIZE KEY CAN BE 128,160,192,224 OR 256 BITS, either hexadecimal or ascii. IV SHOULD MATCH BLOCK SIZE (CBC MODE) GCM MODE INCORPORATED
USAGE:
USAGE for AES-GCM
THERE IS A TEST to validate THIS AES-GCM, SIMPLY RUN THIS SCRIPTAES GCM test vectors from http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-spec.pdf Supported key lengths:128 bits 160 bits 192 bits 224 bits 256 bits Support block modes:ECB: Electronic Code Book CBC: Cipher Block Chaining CTR: Counter mode CFB: Cipher Feedback OFB: Output Feedback GCM: Galois Counter Mode TO IMPLEMENTPadding Oracle Attack Also, you normally don't want to use a (rather short) password directly as a key, but instead use a longer passphrase, and hash it with a salt (included with in the message) to derive the key. If you do this, you can also derive the initialization vector from the same two pieces of data (but in a way that they'll be different, using a key derivation function). To avoid brute-forcing your password from the encrypted file, use a slow hash function here (PBKDF-2 or bcrypt). |