Comments (3)
Thanks for the excellent report and the fix. I'm going to be tagging/releasing a new version tonight. 👍
from sodium_compat.
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.
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)
- Fatal error Invoking Compat::library_version_major()
- Preloading Issue HOT 4
- Class 'ParagonIE_Sodium_Core_Util' not found HOT 7
- Constants such as SODIUM_CRYPTO_PWHASH_ALG_DEFAULT
- Undefined constant 'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES' HOT 15
- Issue in crypto_box_open function HOT 2
- sodium_crypto_aead_xchacha20poly1305_ietf_encrypt doesn't take null as Argument 2 HOT 5
- suggests ext-sodium HOT 2
- Argument 1 must be at least CRYPTO_SIGN_BYTES long HOT 5
- What would a hypothetical sodium_compat v2 look like? HOT 1
- PHP 8.1 x86 deprecation: Implicit conversion from float 4294967295 to int loses precision HOT 11
- Uncaught Error: Class 'ParagonIE_Sodium_Core32_Curve25519' not found HOT 4
- 'include guards' in src/Compat.php (among others) do nothing HOT 3
- Class not found due to autoload-fast.php not including directory HOT 2
- php newb seeing memory exhaustion composer-requiring into snipe-it HOT 2
- Build of sodium-compat.phar fails
- box.json omits autoload-php7.php HOT 2
- HKDF HOT 2
- AEAD - AEGIS-128L and AEGIS-256 HOT 1
- Missing file using composer install HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sodium_compat.