Skip to content
This repository has been archived by the owner on Aug 10, 2019. It is now read-only.

Segfault using openssl #88

Open
JEDIBC opened this issue Jul 2, 2015 · 0 comments
Open

Segfault using openssl #88

JEDIBC opened this issue Jul 2, 2015 · 0 comments

Comments

@JEDIBC
Copy link

JEDIBC commented Jul 2, 2015

Hi,

While making a script to bench openssl encrypt/decrypt ciphers, I always got a segfault with dotdeb php5 (tried with various php version from dotdeb on different servers).

I've tried with debian8 and windows version of php5 and no problem.

Here's the script :

<?php

$string   = str_repeat('foo bar gru ', 1000);
$password = 'myVeryLongPAssword6842-,.;;;withSpecialsCharacters';
$number   = 10000;

$methods = openssl_get_cipher_methods();

foreach ($methods as $method) {
    $ivLength = openssl_cipher_iv_length($method);
    $start    = microtime(true);
    for ($i = 0; $i < $number; $i++) {
        $iv      = openssl_random_pseudo_bytes($ivLength);
        $crypted = base64_encode(openssl_encrypt($string, $method, $password, OPENSSL_RAW_DATA, $iv));
        if ($string !== openssl_decrypt(base64_decode($crypted), $method, $password, OPENSSL_RAW_DATA, $iv)) {
            die("ERROR\n\n");
        }
    }
    printf("%s = %f\n", $method, microtime(true) - $start);
}

echo "\n";
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant