Skip to content

ext-openssl is inconsistent in cipher algorithm accepted in functions vs the ones returned by openssl_get_cipher_methods #19994

Description

@stof

Description

The following code:

<?php

$ciphers = openssl_get_cipher_methods();

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

Resulted in this output:

aes-128-cbc: 16
aes-128-cbc-cts: PHP Warning:  openssl_cipher_iv_length(): Unknown cipher algorithm in /home/stof/src/Incenteev/Incenteev/build/tmp.php on line 15
PHP Stack trace:
PHP   1. {main}() /home/stof/src/Incenteev/Incenteev/build/tmp.php:0
PHP   2. openssl_cipher_iv_length($cipher_algo = 'aes-128-cbc-cts') /home/stof/src/Incenteev/Incenteev/build/tmp.php:7

aes-128-cbc-hmac-sha1: 16
aes-128-cbc-hmac-sha256: 16
aes-128-ccm: 12
aes-128-cfb: 16
aes-128-cfb1: 16
aes-128-cfb8: 16
aes-128-ctr: 16
aes-128-ecb: 0
aes-128-gcm: 12
aes-128-ocb: 12
aes-128-ofb: 16
aes-128-siv: PHP Warning:  openssl_cipher_iv_length(): Unknown cipher algorithm in /home/stof/src/Incenteev/Incenteev/build/tmp.php on line 15
PHP Stack trace:
PHP   1. {main}() /home/stof/src/Incenteev/Incenteev/build/tmp.php:0
PHP   2. openssl_cipher_iv_length($cipher_algo = 'aes-128-siv') /home/stof/src/Incenteev/Incenteev/build/tmp.php:7

[REDACTED: more algorithms]

But I expected this output instead: no warnings about unknown algorithms, as I'm using the list of known algorithms as input.

PHP Version

PHP 8.3.25 (cli) (built: Aug 29 2025 12:01:53) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.25, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.25, Copyright (c), by Zend Technologies
    with Xdebug v3.4.5, Copyright (c) 2002-2025, by Derick Rethans
    with blackfire v1.92.44~linux-x64-non_zts83, https://blackfire.io, by Blackfire

In case this is relevant, I'm using OpenSSL 3.0.13

Operating System

Ubuntu 24.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions