Git Product home page Git Product logo

Comments (3)

paragonie-scott avatar paragonie-scott commented on May 23, 2024

Thanks for the excellent report and the fix. I'm going to be tagging/releasing a new version tonight. 👍

from sodium_compat.

LeSuisse avatar LeSuisse commented on May 23, 2024

Hi,

Thanks for your work!

I still think there is an issue with sodium_increment(). I mentioned it in #74, the same trick does not seem to work, the string is not incremented. It works as expected if I call \Sodium\increment() directly or if I force sodium_compat to use the pure PHP polyfill.

I did not took the time to do further investigations yet, either I miss something related to my environment or there is something subtle at play here.

from sodium_compat.

LeSuisse avatar LeSuisse commented on May 23, 2024

Hi,

So it seems there is really an issue not related to my environnement, the following crappy Dockerfile can be used to reproduce:

FROM php:5.6.37

RUN apt-get -y update \
    && apt-get -y install libsodium-dev \
    && pecl install libsodium-1.0.7 \
    && docker-php-ext-enable libsodium

WORKDIR /root/sodium_compat

RUN apt-get -y install unzip \
    && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && php composer.phar require paragonie/sodium_compat:1.6.4 \
    && { \
        echo '<?php'; \
        echo 'require_once __DIR__ . "/vendor/autoload.php";'; \
        echo '$str = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);'; \
        echo 'var_dump(sodium_bin2hex($str));'; \
        echo 'sodium_increment($str);'; \
        echo 'var_dump(sodium_bin2hex($str));'; \
    } > compat_increment.php \
    && { \
        echo '<?php'; \
        echo 'require_once __DIR__ . "/vendor/autoload.php";'; \
        echo '$str = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);'; \
        echo 'var_dump(sodium_bin2hex($str));'; \
        echo 'Sodium\increment($str);'; \
        echo 'var_dump(sodium_bin2hex($str));'; \
    } > increment.php \
    && { \
        echo '#!/bin/sh'; \
        echo 'set -ex'; \
        echo 'php ./compat_increment.php'; \
        echo 'php -n ./compat_increment.php'; \
        echo 'php ./increment.php'; \
    } > run.sh \
    && chmod +x run.sh

CMD /root/sodium_compat/run.sh
 $ docker build -t sodium_compat_73 .
 $ docker run --rm sodium_compat_73
+ php ./compat_increment.php
string(48) "e8d9de99e92e434bdc569ed1bcab8dbc4c9eb4831fcc9f16"
string(48) "e8d9de99e92e434bdc569ed1bcab8dbc4c9eb4831fcc9f16"
+ php -n ./compat_increment.php
string(48) "cabe321d95412bd0c4719d7c96a3f79e5c74927933d36823"
string(48) "cbbe321d95412bd0c4719d7c96a3f79e5c74927933d36823"
+ php ./increment.php
string(48) "7248b751f048f86c952afd4433f642e4b08e0fca73d386ee"
string(48) "7348b751f048f86c952afd4433f642e4b08e0fca73d386ee"

The first script executed uses sodium_increment() and the string is not incremented.
The second execution is the same than the first but with PHP extensions disabled to force the use of the pure PHP polyfill, the string is correctly incremented.
The third execution uses \Sodium\increment() directly, the string is correctly incremented.

So it seems there is an issue with sodium_compat but I'm not sure to understand why you have done in bbb7fac does not work.

from sodium_compat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.