Due: 23 December 2008, 5pm
This assignment involves developing and using ciphers using PHP. I have a brief overview of using PHP which should be sufficient to get users new to PHP started.
/** * Encryption with Simplified AES * @param String $plaintext Plaintext to be encrypted. 16 bits. * @param String $key Key to use for encryption. 16 bits. * @return String Ciphertext produced by encryption. 16 bits. */ function SAES_Encrypt ($plaintext, $key) /** * Decryption with Simplified AES * @param String $ciphertext Ciphertext to be decrypted. 16 bits. * @param String $key Key to use for decryption. 16 bits. * @return String Plaintext produced by decryption. 16 bits. */ function SAES_Decrypt ($ciphertext, $key)
/** * Generic encryption * @param String $plaintext Plaintext to be encrypted * @param String $key Key to use for encryption. Must be correct length for the selected cipher * @param String $cipher Abbreviation of the cipher to use. 'SDES' or 'SAES' * @param String $mode Abbreviation of the block mode to use. 'ECB', 'CBC' or 'CTR' * @return String The ciphertext produced from the encryption */ function Crypto_Encrypt ($plaintext, $key, $cipher, $mode) /** * Generic decryption * @param String $ciphertext Ciphertext to be decrypted * @param String $key Key to use for decryption. Must be correct length for the selected cipher * @param String $cipher Abbreviation of the cipher to use. See the source for list of ciphers available * @param String $mode Abbreviation of the block mode to use. See the source for list of modes available * @return String The plaintext produced from the decryption */ function Crypto_Decrypt ($ciphertext, $key, $cipher, $mode)
/** * Converts an ASCII string into its binary equivalent, that is * 7-bits for each character * @param String $ascii text or words * @return String binary representation of input text or words */ function Crypto_ASCII2BinString ($ascii) /** * Converts binary data into ASCII (7-bit) text * @param String $bin binary representation of text * @return String text */ function Crypto_BinString2ASCII ($bin)
/** * Key brute force attack * @param String $ciphertext Ciphertext available to attacker * @param String $cipher Abbreviation of the cipher to use. See the source for list of ciphers available * @param String $mode Abbreviation of the block mode to use. See the source for list of modes available * @return ???? */ function Crypto_KeyBruteForce ($ciphertext, $cipher, $mode)
Selected example PHP code and results from executing the code are shown below.
Example code:echo "Task 1: single-block encryption/decryption using SDES\n"; $plaintext = '01110010'; $key = '1010000010'; $ciphertext = SDES_Encrypt($plaintext,$key); echo $ciphertext . "\n"; $newplaintext = SDES_Decrypt($ciphertext,$key); echo $newplaintext . "\n"; echo $plaintext . "\n\n"; echo "Task 2: generic encryption/decryption using SAES and ECB mode\n"; $plaintext = '11010111001010001101011100101000'; $key = '0100101011110101'; $ciphertext = Crypto_Encrypt($plaintext,$key,'SAES','ECB'); echo $ciphertext . "\n"; $newplaintext = Crypto_Decrypt($ciphertext,$key,'SAES','ECB'); echo $newplaintext . "\n"; echo $plaintext . "\n\n"; echo "Task 3: encryption/decryption of ASCII text\n"; $ciphertext = Crypto_Encrypt(Crypto_ASCII2BinString ('steve'),$key,'SAES','CTR'); echo $ciphertext . "\n"; echo Crypto_BinString2ASCII($ciphertext) . "\n"; $newplaintext = Crypto_Decrypt($ciphertext,$key,'SAES','CTR'); echo $newplaintext . "\n"; echo Crypto_BinString2ASCII($newplaintext) . "\n"; echo "steve\n\n"; echo "Task 4: brute force attack\n"; echo "??? the output is for you to decide\n";Output from example code:
sgordon@ginger:~/svn/Steve/Courses/CSS322/Assessment$ php crypto.php Task 1: single-block encryption/decryption using SDES 01110111 01110010 01110010 Task 2: generic encryption/decryption using SAES and ECB mode 00100100111011000010010011101100 11010111001010001101011100101000 11010111001010001101011100101000 Task 3: encryption/decryption of ASCII text 101101010110001011101101110101110111001010111101 ZX]];J= 111001111101001100101111011011001010000000000000 steve~~ steve Task 4: brute force attack ??? the output is for you to decide
Each task will be assessed on correctness and clarity. Marks will also be given for the overall quality of the design/implementation. Bonus marks may be given for exceptional solutions.
Item | Correctness | Clarity |
---|---|---|
Task 1 | 25 | 10 |
Task 2 | 20 | 5 |
Task 3 | 5 | - |
Task 4 | 15 | 5 |
Overall | 15 |
You must submit the source code in electronic form (email as an attachment).
function SAES_Encrypt ($plaintext, $key) function SAES_Decrypt ($ciphertext, $key) function Crypto_Encrypt ($plaintext, $key, $cipher, $mode) function Crypto_Decrypt ($ciphertext, $key, $cipher, $mode) function Crypto_ASCII2BinString ($ascii) function Crypto_BinString2ASCII ($bin) function Crypto_KeyBruteForce ($ciphertext, $cipher, $mode)The above functions may (and should) call other functions. Include all functions in your source code.
These hints are only guidelines, not requirements. You do not have to follow them (and there may be better approaches than what I suggest).
Further hints may be posted to the mailing list. If you have questions, please email direct to me (not to the mail list). If I think the my response is useful for the entire class, I will reply via the mail list.
Name | Cipher | Mode1 | Mode2 |
Jedtana Sitipaneed | SDES | ECB | CBC |
Palakon Kotchapansompote | SAES | ECB | CTR |
Kankamol Wongwattanakit | SDES | ECB | CBC |
Tham Manjing | SAES | ECB | CTR |
Sivakorn Chantarasena | SDES | ECB | CTR |
Poomphat Techapoonpon | SDES | ECB | CBC |
Kritswut Budtpoe | SDES | ECB | CTR |
Chavalit Koweerawong | SDES | ECB | CTR |
San Choosang | SAES | ECB | CBC |
Onpapim Luchaichana | SDES | ECB | CBC |
Warrapat Korkerd | SAES | ECB | CBC |
Rattham Nirattisaisakul | SDES | ECB | CTR |
Theerawat Songyot | SAES | ECB | CBC |
Anond Sethabutr | SAES | ECB | CTR |
Taw Viriyasumethi | SDES | ECB | CTR |
Patsaporn Panitsuk | SAES | ECB | CBC |
Suracheth Chawla | SAES | ECB | CTR |
Sarissa Indhakanok | SAES | ECB | CBC |
Lerit Nuksawn | SDES | ECB | CBC |
Purivich Assaneevutikorn | SAES | ECB | CTR |
Apiratt Naraviriyakul | SDES | ECB | CTR |
Nipitphand Koosakulwattana | SDES | ECB | CBC |
Nattaphot Chalearnpong | SDES | ECB | CBC |
Touchapong Prukthichaipat | SDES | ECB | CBC |
Thudsanee Prochai | SAES | ECB | CBC |
Suthasinee Tangyotkhajorn | SAES | ECB | CBC |
Jirarat Boonchoti | SAES | ECB | CTR |
Jipakan Ratanakijtrakul | SDES | ECB | CTR |
Prach Viboontapachart | SDES | ECB | CTR |
Return to: CSS322 Home | Course List | Steven Gordon's Home | SIIT