PHP: Hypertext Preprocessor (original) (raw)

`<?php ciphers=opensslgetciphermethods();//ECBmodeshouldbeavoided<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>i</mi><mi>p</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>s</mi><mo>=</mo><mi>a</mi><mi>r</mi><mi>r</mi><mi>a</mi><msub><mi>y</mi><mi>f</mi></msub><mi>i</mi><mi>l</mi><mi>t</mi><mi>e</mi><mi>r</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">ciphers=arrayfilter(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.8889em;vertical−align:−0.1944em;"></span><spanclass="mordmathnormal">c</span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal">h</span><spanclass="mordmathnormal">ers</span><spanclass="mspace"style="margin−right:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="margin−right:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1.0361em;vertical−align:−0.2861em;"></span><spanclass="mordmathnormal">a</span><spanclass="mordmathnormal"style="margin−right:0.02778em;">rr</span><spanclass="mordmathnormal">a</span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.03588em;">y</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3361em;"><spanstyle="top:−2.55em;margin−left:−0.0359em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight"style="margin−right:0.10764em;">f</span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.2861em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">lt</span><spanclass="mordmathnormal"style="margin−right:0.02778em;">er</span><spanclass="mopen">(</span></span></span></span>ciphers,function(ciphers = openssl_get_cipher_methods();//ECB mode should be avoided <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>i</mi><mi>p</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>s</mi><mo>=</mo><mi>a</mi><mi>r</mi><mi>r</mi><mi>a</mi><msub><mi>y</mi><mi>f</mi></msub><mi>i</mi><mi>l</mi><mi>t</mi><mi>e</mi><mi>r</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">ciphers = array_filter(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">i</span><span class="mord mathnormal">p</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ers</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.02778em;">rr</span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal">i</span><span class="mord mathnormal">lt</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mopen">(</span></span></span></span>ciphers, function (ciphers=opensslgetciphermethods();//ECBmodeshouldbeavoided<spanclass="katex"><spanclass="katexmathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>i</mi><mi>p</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>s</mi><mo>=</mo><mi>a</mi><mi>r</mi><mi>r</mi><mi>a</mi><msub><mi>y</mi><mi>f</mi></msub><mi>i</mi><mi>l</mi><mi>t</mi><mi>e</mi><mi>r</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/xtex">ciphers=arrayfilter(</annotation></semantics></math></span><spanclass="katexhtml"ariahidden="true"><spanclass="base"><spanclass="strut"style="height:0.8889em;verticalalign:0.1944em;"></span><spanclass="mordmathnormal">c</span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal">h</span><spanclass="mordmathnormal">ers</span><spanclass="mspace"style="marginright:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="marginright:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1.0361em;verticalalign:0.2861em;"></span><spanclass="mordmathnormal">a</span><spanclass="mordmathnormal"style="marginright:0.02778em;">rr</span><spanclass="mordmathnormal">a</span><spanclass="mord"><spanclass="mordmathnormal"style="marginright:0.03588em;">y</span><spanclass="msupsub"><spanclass="vlisttvlistt2"><spanclass="vlistr"><spanclass="vlist"style="height:0.3361em;"><spanstyle="top:2.55em;marginleft:0.0359em;marginright:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingresetsize6size3mtight"><spanclass="mordmathnormalmtight"style="marginright:0.10764em;">f</span></span></span></span><spanclass="vlists"></span></span><spanclass="vlistr"><spanclass="vlist"style="height:0.2861em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">lt</span><spanclass="mordmathnormal"style="marginright:0.02778em;">er</span><spanclass="mopen">(</span></span></span></span>ciphers,function(n) {
return stripos($n, "ecb") === FALSE;
});// At least as early as Aug 2016, Openssl declared the following weak: RC2, RC4, DES, 3DES, MD5 based ciphers=arrayfilter(ciphers = array_filter(ciphers=arrayfilter(ciphers, function ($c) {
return stripos($c, "des") === FALSE;
}); ciphers=arrayfilter(ciphers = array_filter(ciphers=arrayfilter(ciphers, function ($c) {
return stripos($c, "rc2") === FALSE;
}); ciphers=arrayfilter(ciphers = array_filter(ciphers=arrayfilter(ciphers, function ($c) {
return stripos($c, "rc4") === FALSE;
}); ciphers=arrayfilter(ciphers = array_filter(ciphers=arrayfilter(ciphers, function ($c) {
return stripos($c, "md5") === FALSE;
});

if (

is_array($ciphers)) {
foreach ($ciphers as $cipher) {
echo $cipher.': ';
echo openssl_cipher_iv_length($cipher);
echo "
\n";
}
}
?>

Will be...
AES-xxx-xxx is 16
BF-xxx is 8
CAMELLIA-xxx is 16
CAST5-xxx is 8
IDEA-xxx is 8
SEED-xxx is 16

lower case:
aes-xxx-xxx are mixed between 16 and 12.
id-aes-xxx are mixed between 12 and 8.
The values above are tested with PHP 5.5 - 5.6 on Windows. In PHP 7.x is different than this.

`