cvs: presentations / encryption-vancouver.xml /slides/encryption example-fail.xml mcrypt-bug26733.xml mcrypt-crypt.xml mcrypt-future.xml
mcrypt-generic.xml mcrypt-iv.xml mcrypt-modules.xml mcrypt-store.xml mcrypt-supported.xml quote-1337.xml quote-fail.xml resources.xml /slides/xdebug
questions.xml
| From: | Derick Rethans | Date: | Wed, 21 Jan 2004 06:42:43 +0000 |
| Subject: | cvs: presentations / encryption-vancouver.xml /slides/encryption example-fail.xml mcrypt-bug26733.xml mcrypt-crypt.xml mcrypt-future.xml mcrypt-generic.xml mcrypt-iv.xml mcrypt-modules.xml mcrypt-store.xml mcrypt-supported.xml quote-1337.xml quote-fail.xml resources.xml /slides/xdebug questions.xml |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-953@lists.php.net to get a copy of this message | ||
derick Wed Jan 21 01:42:43 2004 EDT
Added files:
/presentations/slides/encryption example-fail.xml
mcrypt-bug26733.xml
mcrypt-crypt.xml mcrypt-future.xml
mcrypt-generic.xml mcrypt-iv.xml
mcrypt-modules.xml
mcrypt-store.xml
mcrypt-supported.xml
Modified files:
/presentations encryption-vancouver.xml
/presentations/slides/encryption quote-1337.xml quote-fail.xml
resources.xml
/presentations/slides/xdebug questions.xml
Log:
- Plane hacking on the encryption presentation
http://cvs.php.net/diff.php/presentations/encryption-vancouver.xml?r1=1.1&r2=1.2&ty=u Index: presentations/encryption-vancouver.xml diff -u presentations/encryption-vancouver.xml:1.1 presentations/encryption-vancouver.xml:1.2 --- presentations/encryption-vancouver.xml:1.1 Sun Jan 18 17:15:38 2004 +++ presentations/encryption-vancouver.xml Wed Jan 21 01:42:41 2004 @@ -38,8 +38,20 @@ <slide>slides/encryption/mode-ecb.xml</slide> <slide>slides/encryption/mode-cfb.xml</slide> <slide>slides/encryption/quote-fail.xml</slide> +<slide>slides/encryption/example-fail.xml</slide> +<!-- mcrypt examples --> +<slide>slides/encryption/mcrypt-modules.xml</slide> +<slide>slides/encryption/mcrypt-generic.xml</slide> +<slide>slides/encryption/mcrypt-crypt.xml</slide> +<slide>slides/encryption/mcrypt-store.xml</slide> +<slide>slides/encryption/mcrypt-bug26733.xml</slide> +<slide>slides/encryption/mcrypt-iv.xml</slide> +<slide>slides/encryption/mcrypt-supported.xml</slide> +<slide>slides/encryption/mcrypt-future.xml</slide> +<slide>slides/encryption/quote-false.xml</slide> +<slide>slides/xdebug/questions.xml</slide> <slide>slides/encryption/resources.xml</slide> </presentation> http://cvs.php.net/diff.php/presentations/slides/encryption/quote-1337.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/quote-1337.xml diff -u presentations/slides/encryption/quote-1337.xml:1.1 presentations/slides/encryption/quote-1337.xml:1.2 --- presentations/slides/encryption/quote-1337.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/quote-1337.xml Wed Jan 21 01:42:42 2004 @@ -6,5 +6,5 @@ <blurb fontsize="5em">I've found one, and only one practical application for "13375p33k"</blurb> <blurb fontsize="5em">Secure passwords</blurb> - <blurb align="right" fontsize="4em">~Anonymous on IRC~</blurb> + <blurb align="right" fontsize="4em">~Jan Lehnardt~</blurb> </slide> http://cvs.php.net/diff.php/presentations/slides/encryption/quote-fail.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/quote-fail.xml diff -u presentations/slides/encryption/quote-fail.xml:1.1 presentations/slides/encryption/quote-fail.xml:1.2 --- presentations/slides/encryption/quote-fail.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/quote-fail.xml Wed Jan 21 01:42:42 2004 @@ -2,7 +2,7 @@ <slide fontsize="6em"> <title>Quote</title> - <break lines="9"/> + <break lines="6"/> <blurb fontsize="5em">"most security failures in its area of interest are due to failures in implementation, not failure in algorithms or protocols"</blurb> <blurb align="right" fontsize="4em">~The NSA~</blurb> http://cvs.php.net/diff.php/presentations/slides/encryption/resources.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/resources.xml diff -u presentations/slides/encryption/resources.xml:1.1 presentations/slides/encryption/resources.xml:1.2 --- presentations/slides/encryption/resources.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/resources.xml Wed Jan 21 01:42:42 2004 @@ -6,11 +6,9 @@ <image align="center" filename="blowfish.png" /> <break lines="2" /> - <link fontsize="3em" marginleft="2em" leader="These Slides: " href="http://pres.derickrethans.nl" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="Xdebug site: " href="http://xdebug.org" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="DBGp specification: " href="http://xdebug.org/docs-dbgp.php" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="These Slides: " href="http://pres.derickrethans.nl/mcrypt-vancouver" target="_new"/> - <break lines="3" /> <link fontsize="3em" marginleft="2em" leader="PHP: " href="http://www.php.net" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="Questions?: " href="derick@xdebug.org" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="Crypto Intro: " href="http://" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="Questions?: " href="mailto:derick@php.net" target="_new"/> </slide> http://cvs.php.net/diff.php/presentations/slides/xdebug/questions.xml?r1=1.2&r2=1.3&ty=u Index: presentations/slides/xdebug/questions.xml diff -u presentations/slides/xdebug/questions.xml:1.2 presentations/slides/xdebug/questions.xml:1.3 --- presentations/slides/xdebug/questions.xml:1.2 Tue Jan 13 05:04:49 2004 +++ presentations/slides/xdebug/questions.xml Wed Jan 21 01:42:43 2004 @@ -2,5 +2,6 @@ <slide fontsize="6em"> <title>Questions</title> + <break lines="16"/> <blurb align="center" marginleft="0" marginright="0" fontsize="12em">?</blurb> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/example-fail.xml?r=1.1&p=1 Index: presentations/slides/encryption/example-fail.xml +++ presentations/slides/encryption/example-fail.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Example</title> <break lines="6"/> <blurb fontsize="5em">"most security failures in its area of interest are due to failures in implementation, not failure in algorithms or protocols"</blurb> <blurb align="right" fontsize="4em">~The NSA~</blurb> <break lines="1"/> <list> <bullet marginleft="-0.3em" fontsize="2.8em" type="none">Do [blink]*not*[/blink] store the key on the same machine as the encrypted data</bullet> </list> <list> <bullet effect="slide" fontsize="2.8em" type="none">Do *never* store passwords, unless hashed</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-bug26733.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-bug26733.xml +++ presentations/slides/encryption/mcrypt-bug26733.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q2: Bug #26733</title> <break lines="2"/> <blurb fontsize="3em">"I have a string encrypted with mcrypt and encoded in base64. I unbase64 this string and I decrypt it using mcrypt. I looks like I got the exact same string but when I compare it with == it is not the same."</blurb> <break /> <example fontsize="1.3em" result="0"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-128', '', 'ecb', ''); $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ @mcrypt_generic_init($td, $key, ''); /* Decrypt text */ $text = mdecrypt_generic($td, $crypt_text); echo $text; ?>]]></example> <break /> <list fontsize="4em" effect="slide" marginleft="-2em"> <bullet>If you use a block method, mcrypt will pad with \0s.</bullet> <bullet>So store the original length of the text too.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-crypt.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-crypt.xml +++ presentations/slides/encryption/mcrypt-crypt.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Encrypting</title> <example fontsize="1.5em" result="1"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); $iv = mcrypt_create_iv($iv_size); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ mcrypt_generic_init($td, $key, $iv); /* Encrypt text */ $crypt_text = mcrypt_generic($td, "very important data"); echo $crypt_text; /* Clean up cipher */ mcrypt_generic_deinit($td); mcrypt_module_close($td); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-future.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-future.xml +++ presentations/slides/encryption/mcrypt-future.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Future?</title> <blurb fontsize="4em">Wouldn't this be much nicer?</blurb> <example fontsize="1.5em"><![CDATA[<?php $td = new Mcrypt('tripledes', 'cfb'); echo $td->name; echo $td->is_block_algorithm; echo $td->block_size; echo $td->iv_size; echo $td->key_size; $iv = $td->generate_iv(); /* or */ $iv = mcrypt::creat_iv($size); $td->set_iv($iv); $td->set_key('secret_key', MCRYPT_HASH); /* or MCRYPT_PAD */ $td->init(); /* optional, only required for multiple encryptions */ $crypt = $td->encrypt('secret text'); $td = NULL; ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-generic.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-generic.xml +++ presentations/slides/encryption/mcrypt-generic.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Mcrypt Init</title> <break lines="2"/> <example fontsize="1.8em" result="0"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { /* Get key size and IV size */ $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); /* Create IV and 'key' */ $iv = mcrypt_create_iv($iv_size); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ mcrypt_generic_init($td, $key, $iv); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-iv.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-iv.xml +++ presentations/slides/encryption/mcrypt-iv.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q3: IV troubles</title> <break lines="2"/> <blurb fontsize="3.5em">"Typical uses for something like libmcrypt is to encrypt a plaintext for decryption at some later date. All that should be required for the decryption is the key that was used during encryption. In particular, the values in the IV array cannot be expected to be the same during encryption and decryption.</blurb> <blurb fontsize="3.5">[...] If however, I modify the test program as per the patch below, so that the IV array is different for encryption and decryption, then many of the tests fail."</blurb> <break /> <list fontsize="4em" effect="slide" marginleft="-1.5em"> <bullet type="none">The IV for encryption and decryption should always be the same.</bullet> <bullet type="none">*But* it does not need to be secret, only unique and random.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-modules.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-modules.xml +++ presentations/slides/encryption/mcrypt-modules.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Mcrypt Modules</title> <example fontsize="1.4em" result="1"><![CDATA[<?php error_reporting(E_ALL); $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { echo mcrypt_enc_get_algorithms_name($td). "/"; echo mcrypt_enc_get_modes_name($td). "<br />"; echo "IV Size: ". mcrypt_enc_get_iv_size($td). "; "; echo "Block Size: ". mcrypt_enc_get_block_size($td). "; "; echo "Key Size: ". mcrypt_enc_get_key_size($td). "<br />"; echo "Key Sizes: ". join(", ", mcrypt_enc_get_supported_key_sizes($td)). "<br />"; echo "Is Block A/M: ". (mcrypt_enc_is_block_algorithm_mode($td) ? "Y" : "N"). "; "; echo "Is Block A: ". (mcrypt_enc_is_block_algorithm($td) ? "Y" : "N"). "; "; echo "Is Block M: ". (mcrypt_enc_is_block_mode($td) ? "Y" : "N"). "<br /> "; echo "Selftest: ". (mcrypt_enc_self_test($td) ? "N" : "Y"); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-store.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-store.xml +++ presentations/slides/encryption/mcrypt-store.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q1: Storing crypttext</title> <break lines="8"/> <list fontsize="5em" marginleft="-0.3em"> <bullet>Encrypted data is binary 'crap'</bullet> </list> <list fontsize="5em" marginleft="-0.3em"> <bullet>Length and trailing zeros are important</bullet> </list> <list fontsize="5em" effect="slide"> <bullet>Use base64_encode() or binhex()</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-supported.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-supported.xml +++ presentations/slides/encryption/mcrypt-supported.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Supported modes and ciphers</title> <example fontsize="1.5em" result="1"><![CDATA[<pre><font size="6"><?php $modes = mcrypt_list_modes(); $algos = mcrypt_list_algorithms(); sort($modes); sort($algos); foreach ($modes as $mode) { printf ("%7s ", $mode); } echo "<br />"; foreach ($algos as $algo) { foreach ($modes as $mode) { if ($td = @mcrypt_module_open($algo, '', $mode, '')) { if (mcrypt_enc_is_block_mode($td)) { $bs = mcrypt_enc_get_block_size($td); } else { $bs = 1; } $ks = mcrypt_enc_get_key_size($td); printf ("%3s/%3s ", $bs, $ks); mcrypt_module_close($td); } else { printf ("%7s ", "-"); } } echo $algo."<br />"; } ?></pre>]]></example> </slide>
http://cvs.php.net/diff.php/presentations/encryption-vancouver.xml?r1=1.1&r2=1.2&ty=u Index: presentations/encryption-vancouver.xml diff -u presentations/encryption-vancouver.xml:1.1 presentations/encryption-vancouver.xml:1.2 --- presentations/encryption-vancouver.xml:1.1 Sun Jan 18 17:15:38 2004 +++ presentations/encryption-vancouver.xml Wed Jan 21 01:42:41 2004 @@ -38,8 +38,20 @@ <slide>slides/encryption/mode-ecb.xml</slide> <slide>slides/encryption/mode-cfb.xml</slide> <slide>slides/encryption/quote-fail.xml</slide> +<slide>slides/encryption/example-fail.xml</slide> +<!-- mcrypt examples --> +<slide>slides/encryption/mcrypt-modules.xml</slide> +<slide>slides/encryption/mcrypt-generic.xml</slide> +<slide>slides/encryption/mcrypt-crypt.xml</slide> +<slide>slides/encryption/mcrypt-store.xml</slide> +<slide>slides/encryption/mcrypt-bug26733.xml</slide> +<slide>slides/encryption/mcrypt-iv.xml</slide> +<slide>slides/encryption/mcrypt-supported.xml</slide> +<slide>slides/encryption/mcrypt-future.xml</slide> +<slide>slides/encryption/quote-false.xml</slide> +<slide>slides/xdebug/questions.xml</slide> <slide>slides/encryption/resources.xml</slide> </presentation> http://cvs.php.net/diff.php/presentations/slides/encryption/quote-1337.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/quote-1337.xml diff -u presentations/slides/encryption/quote-1337.xml:1.1 presentations/slides/encryption/quote-1337.xml:1.2 --- presentations/slides/encryption/quote-1337.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/quote-1337.xml Wed Jan 21 01:42:42 2004 @@ -6,5 +6,5 @@ <blurb fontsize="5em">I've found one, and only one practical application for "13375p33k"</blurb> <blurb fontsize="5em">Secure passwords</blurb> - <blurb align="right" fontsize="4em">~Anonymous on IRC~</blurb> + <blurb align="right" fontsize="4em">~Jan Lehnardt~</blurb> </slide> http://cvs.php.net/diff.php/presentations/slides/encryption/quote-fail.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/quote-fail.xml diff -u presentations/slides/encryption/quote-fail.xml:1.1 presentations/slides/encryption/quote-fail.xml:1.2 --- presentations/slides/encryption/quote-fail.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/quote-fail.xml Wed Jan 21 01:42:42 2004 @@ -2,7 +2,7 @@ <slide fontsize="6em"> <title>Quote</title> - <break lines="9"/> + <break lines="6"/> <blurb fontsize="5em">"most security failures in its area of interest are due to failures in implementation, not failure in algorithms or protocols"</blurb> <blurb align="right" fontsize="4em">~The NSA~</blurb> http://cvs.php.net/diff.php/presentations/slides/encryption/resources.xml?r1=1.1&r2=1.2&ty=u Index: presentations/slides/encryption/resources.xml diff -u presentations/slides/encryption/resources.xml:1.1 presentations/slides/encryption/resources.xml:1.2 --- presentations/slides/encryption/resources.xml:1.1 Sun Jan 18 17:15:39 2004 +++ presentations/slides/encryption/resources.xml Wed Jan 21 01:42:42 2004 @@ -6,11 +6,9 @@ <image align="center" filename="blowfish.png" /> <break lines="2" /> - <link fontsize="3em" marginleft="2em" leader="These Slides: " href="http://pres.derickrethans.nl" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="Xdebug site: " href="http://xdebug.org" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="DBGp specification: " href="http://xdebug.org/docs-dbgp.php" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="These Slides: " href="http://pres.derickrethans.nl/mcrypt-vancouver" target="_new"/> - <break lines="3" /> <link fontsize="3em" marginleft="2em" leader="PHP: " href="http://www.php.net" target="_new"/> - <link fontsize="3em" marginleft="2em" leader="Questions?: " href="derick@xdebug.org" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="Crypto Intro: " href="http://" target="_new"/> + <link fontsize="3em" marginleft="2em" leader="Questions?: " href="mailto:derick@php.net" target="_new"/> </slide> http://cvs.php.net/diff.php/presentations/slides/xdebug/questions.xml?r1=1.2&r2=1.3&ty=u Index: presentations/slides/xdebug/questions.xml diff -u presentations/slides/xdebug/questions.xml:1.2 presentations/slides/xdebug/questions.xml:1.3 --- presentations/slides/xdebug/questions.xml:1.2 Tue Jan 13 05:04:49 2004 +++ presentations/slides/xdebug/questions.xml Wed Jan 21 01:42:43 2004 @@ -2,5 +2,6 @@ <slide fontsize="6em"> <title>Questions</title> + <break lines="16"/> <blurb align="center" marginleft="0" marginright="0" fontsize="12em">?</blurb> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/example-fail.xml?r=1.1&p=1 Index: presentations/slides/encryption/example-fail.xml +++ presentations/slides/encryption/example-fail.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide fontsize="6em"> <title>Example</title> <break lines="6"/> <blurb fontsize="5em">"most security failures in its area of interest are due to failures in implementation, not failure in algorithms or protocols"</blurb> <blurb align="right" fontsize="4em">~The NSA~</blurb> <break lines="1"/> <list> <bullet marginleft="-0.3em" fontsize="2.8em" type="none">Do [blink]*not*[/blink] store the key on the same machine as the encrypted data</bullet> </list> <list> <bullet effect="slide" fontsize="2.8em" type="none">Do *never* store passwords, unless hashed</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-bug26733.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-bug26733.xml +++ presentations/slides/encryption/mcrypt-bug26733.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q2: Bug #26733</title> <break lines="2"/> <blurb fontsize="3em">"I have a string encrypted with mcrypt and encoded in base64. I unbase64 this string and I decrypt it using mcrypt. I looks like I got the exact same string but when I compare it with == it is not the same."</blurb> <break /> <example fontsize="1.3em" result="0"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-128', '', 'ecb', ''); $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ @mcrypt_generic_init($td, $key, ''); /* Decrypt text */ $text = mdecrypt_generic($td, $crypt_text); echo $text; ?>]]></example> <break /> <list fontsize="4em" effect="slide" marginleft="-2em"> <bullet>If you use a block method, mcrypt will pad with \0s.</bullet> <bullet>So store the original length of the text too.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-crypt.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-crypt.xml +++ presentations/slides/encryption/mcrypt-crypt.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Encrypting</title> <example fontsize="1.5em" result="1"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); $iv = mcrypt_create_iv($iv_size); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ mcrypt_generic_init($td, $key, $iv); /* Encrypt text */ $crypt_text = mcrypt_generic($td, "very important data"); echo $crypt_text; /* Clean up cipher */ mcrypt_generic_deinit($td); mcrypt_module_close($td); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-future.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-future.xml +++ presentations/slides/encryption/mcrypt-future.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Future?</title> <blurb fontsize="4em">Wouldn't this be much nicer?</blurb> <example fontsize="1.5em"><![CDATA[<?php $td = new Mcrypt('tripledes', 'cfb'); echo $td->name; echo $td->is_block_algorithm; echo $td->block_size; echo $td->iv_size; echo $td->key_size; $iv = $td->generate_iv(); /* or */ $iv = mcrypt::creat_iv($size); $td->set_iv($iv); $td->set_key('secret_key', MCRYPT_HASH); /* or MCRYPT_PAD */ $td->init(); /* optional, only required for multiple encryptions */ $crypt = $td->encrypt('secret text'); $td = NULL; ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-generic.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-generic.xml +++ presentations/slides/encryption/mcrypt-generic.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Mcrypt Init</title> <break lines="2"/> <example fontsize="1.8em" result="0"><![CDATA[<?php $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { /* Get key size and IV size */ $iv_size = mcrypt_enc_get_iv_size($td); $key_size = mcrypt_enc_get_key_size($td); /* Create IV and 'key' */ $iv = mcrypt_create_iv($iv_size); $key = substr(sha1('very secret key'), 0, $key_size); /* Init encryption module */ mcrypt_generic_init($td, $key, $iv); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-iv.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-iv.xml +++ presentations/slides/encryption/mcrypt-iv.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q3: IV troubles</title> <break lines="2"/> <blurb fontsize="3.5em">"Typical uses for something like libmcrypt is to encrypt a plaintext for decryption at some later date. All that should be required for the decryption is the key that was used during encryption. In particular, the values in the IV array cannot be expected to be the same during encryption and decryption.</blurb> <blurb fontsize="3.5">[...] If however, I modify the test program as per the patch below, so that the IV array is different for encryption and decryption, then many of the tests fail."</blurb> <break /> <list fontsize="4em" effect="slide" marginleft="-1.5em"> <bullet type="none">The IV for encryption and decryption should always be the same.</bullet> <bullet type="none">*But* it does not need to be secret, only unique and random.</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-modules.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-modules.xml +++ presentations/slides/encryption/mcrypt-modules.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Mcrypt Modules</title> <example fontsize="1.4em" result="1"><![CDATA[<?php error_reporting(E_ALL); $td = @mcrypt_module_open('rijndael-256', '', 'cfb', ''); if ($td) { echo mcrypt_enc_get_algorithms_name($td). "/"; echo mcrypt_enc_get_modes_name($td). "<br />"; echo "IV Size: ". mcrypt_enc_get_iv_size($td). "; "; echo "Block Size: ". mcrypt_enc_get_block_size($td). "; "; echo "Key Size: ". mcrypt_enc_get_key_size($td). "<br />"; echo "Key Sizes: ". join(", ", mcrypt_enc_get_supported_key_sizes($td)). "<br />"; echo "Is Block A/M: ". (mcrypt_enc_is_block_algorithm_mode($td) ? "Y" : "N"). "; "; echo "Is Block A: ". (mcrypt_enc_is_block_algorithm($td) ? "Y" : "N"). "; "; echo "Is Block M: ". (mcrypt_enc_is_block_mode($td) ? "Y" : "N"). "<br /> "; echo "Selftest: ". (mcrypt_enc_self_test($td) ? "N" : "Y"); } ?>]]></example> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-store.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-store.xml +++ presentations/slides/encryption/mcrypt-store.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Q1: Storing crypttext</title> <break lines="8"/> <list fontsize="5em" marginleft="-0.3em"> <bullet>Encrypted data is binary 'crap'</bullet> </list> <list fontsize="5em" marginleft="-0.3em"> <bullet>Length and trailing zeros are important</bullet> </list> <list fontsize="5em" effect="slide"> <bullet>Use base64_encode() or binhex()</bullet> </list> </slide> http://cvs.php.net/co.php/presentations/slides/encryption/mcrypt-supported.xml?r=1.1&p=1 Index: presentations/slides/encryption/mcrypt-supported.xml +++ presentations/slides/encryption/mcrypt-supported.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide> <title>Supported modes and ciphers</title> <example fontsize="1.5em" result="1"><![CDATA[<pre><font size="6"><?php $modes = mcrypt_list_modes(); $algos = mcrypt_list_algorithms(); sort($modes); sort($algos); foreach ($modes as $mode) { printf ("%7s ", $mode); } echo "<br />"; foreach ($algos as $algo) { foreach ($modes as $mode) { if ($td = @mcrypt_module_open($algo, '', $mode, '')) { if (mcrypt_enc_is_block_mode($td)) { $bs = mcrypt_enc_get_block_size($td); } else { $bs = 1; } $ks = mcrypt_enc_get_key_size($td); printf ("%3s/%3s ", $bs, $ks); mcrypt_module_close($td); } else { printf ("%7s ", "-"); } } echo $algo."<br />"; } ?></pre>]]></example> </slide>