Fix broken libsodium php installation Ubuntu Xenial

396 views Asked by At

libsodium WAS working fine but now I managed to break it and can't find how to unbreak it.

Amazon AWS Ubuntu Xenial, libsodium18 installed, php-sodium from Ondrej Sury PPA installed but instead of working I now get:

Undefined constant 'Sodium\CRYPTO_SECRETBOX_NONCEBYTES'

The annoying thing is it's fine in Zesty but there's no stable AWS Zesty image still. I'm sure I've just forgotten some simple thing but it's just ceased working.

2

There are 2 answers

0
AlreadyTriedGoogle On

Found it.

PHP sodium function names have changed so instead of calling \Sodium\crypto_secretbox_open() you now have to call sodium_crypto_secretbox_open()

I seriously hope this post helps someone avoid the grief I've had in the last 24 hours wondering what I'd *^&%'d up - it might well be the only thing on the internet actually pointing this change out that Google finds...

The revised function names and constants are all listed at https://paragonie.com/book/pecl-libsodium/read/01-quick-start.md

1
Frank Denis On

The project description explains the reason behind these changes: https://github.com/jedisct1/libsodium-php

There is also a polyfill that provides the old interface: https://github.com/mollie/polyfill-libsodium

However, new libsodium APIs are not available using this polyfill.

I can't maintain both versions, sorry. I wish we could have kept using the original, namespaced version.