<?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <refentry xml:id="function.openssl-get-cipher-methods" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>openssl_get_cipher_methods</refname> <refpurpose>Gets available cipher methods</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>openssl_get_cipher_methods</methodname> <methodparam choice="opt"><type>bool</type><parameter>aliases</parameter><initializer>&false;</initializer></methodparam> </methodsynopsis> <para> Gets a list of available cipher methods. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>aliases</parameter></term> <listitem> <para> Set to &true; if cipher aliases should be included within the returned <type>array</type>. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> An <type>array</type> of available cipher methods. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>openssl_get_cipher_methods</function> example</title> <para> Shows how the available ciphers might look, and also which aliases might be available. </para> <programlisting role="php"> <![CDATA[ <?php $ciphers = openssl_get_cipher_methods(); $ciphers_and_aliases = openssl_get_cipher_methods(true); $cipher_aliases = array_diff($ciphers_and_aliases, $ciphers); //ECB mode should be avoided $ciphers = array_filter( $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 = array_filter( $ciphers, function($c) { return stripos($c,"des")===FALSE; } ); $ciphers = array_filter( $ciphers, function($c) { return stripos($c,"rc2")===FALSE; } ); $ciphers = array_filter( $ciphers, function($c) { return stripos($c,"rc4")===FALSE; } ); $ciphers = array_filter( $ciphers, function($c) { return stripos($c,"md5")===FALSE; } ); $cipher_aliases = array_filter($cipher_aliases,function($c) { return stripos($c,"des")===FALSE; } ); $cipher_aliases = array_filter($cipher_aliases,function($c) { return stripos($c,"rc2")===FALSE; } ); print_r($ciphers); print_r($cipher_aliases); ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[ Array ( [0] => AES-128-CBC [1] => AES-128-CFB [2] => AES-128-CFB1 [3] => AES-128-CFB8 [5] => AES-128-OFB [6] => AES-192-CBC [7] => AES-192-CFB [8] => AES-192-CFB1 [9] => AES-192-CFB8 [11] => AES-192-OFB [12] => AES-256-CBC [13] => AES-256-CFB [14] => AES-256-CFB1 [15] => AES-256-CFB8 [17] => AES-256-OFB [18] => BF-CBC [19] => BF-CFB [21] => BF-OFB [22] => CAST5-CBC [23] => CAST5-CFB [25] => CAST5-OFB [41] => IDEA-CBC [42] => IDEA-CFB [44] => IDEA-OFB [53] => aes-128-cbc [54] => aes-128-cfb [55] => aes-128-cfb1 [56] => aes-128-cfb8 [58] => aes-128-ofb [59] => aes-192-cbc [60] => aes-192-cfb [61] => aes-192-cfb1 [62] => aes-192-cfb8 [64] => aes-192-ofb [65] => aes-256-cbc [66] => aes-256-cfb [67] => aes-256-cfb1 [68] => aes-256-cfb8 [70] => aes-256-ofb [71] => bf-cbc [72] => bf-cfb [74] => bf-ofb [75] => cast5-cbc [76] => cast5-cfb [78] => cast5-ofb [94] => idea-cbc [95] => idea-cfb [97] => idea-ofb ) Array ( [18] => AES128 [19] => AES192 [20] => AES256 [21] => BF [26] => CAST [27] => CAST-cbc [50] => IDEA [82] => aes128 [83] => aes192 [84] => aes256 [85] => bf [90] => blowfish [91] => cast [92] => cast-cbc [115] => idea ) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>openssl_get_md_methods</function></member> </simplelist> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"~/.phpdoc/manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->