matasarei/euspe

OOP interfaces for the EUSign PHP library

1.0.2 2024-08-26 18:24 UTC

This package is auto-updated.

Last update: 2024-08-26 18:25:39 UTC


README

CI workflow

OOP interfaces for the EUSign PHP library. The eusphpe extension is included in releases.

Usage

Similar to euspe_* functions, but with OOP interfaces.

Decrypt signed data:

$crypto = new Matasar\Euspe\Crypto(); // initializes the library

// similar to EUSignTest.php \develop()
$result = $crypto->develop('path/to/private_key', 'password', 'encrypted_data');
var_dump($result->signInfo->data); // decrypted data

Hash data for signing:

$crypto = new Matasar\Euspe\Crypto();

$hash = $crypto->hash('path/to/file', true); // hash a file
var_dump(base64_encode($hash));

$hash = $crypto->hash('qwerty', false); // hash a string
var_dump(base64_encode($hash));

Tests and development

The tests should not and don't do any real cryptography testing, as this is only a wrapper for the library.

  1. Install vendors
docker run --rm -v $(pwd):/app -w /app composer:lts composer install --ignore-platform-reqs

Important

The --ignore-platform-reqs flag is required to avoid the ext-eusphpe requirement.

  1. Run tests
docker run --rm -v $(pwd):/app -w /app composer:lts vendor/bin/phpunit

Recommendations to install the EUSign library

  1. Unpack and copy library files:
cp .../eusphpe.ini /etc/php/7.4/mods-available/eusphpe.ini
cp -R .../eusphpe_extension /usr/lib/php/eusphpe_extension
  1. Make symlinks to the configuration file:
ln -s /etc/php/7.4/mods-available/eusphpe.ini /etc/php/7.4/fpm/conf.d/20-eusphpe.ini
ln -s /etc/php/7.4/mods-available/eusphpe.ini /etc/php/7.4/cli/conf.d/20-eusphpe.ini
  1. Restart the FPM service
  2. If you have certificates install them (by default in /data/certificates, see osplm.ini):
ls -la /data/certificates/
-rw-rw-r-- 1 root root 876543 Feb 24 2022 CACertificates.p7b
-rw-rw-r-- 1 root root  12345 Feb 24 2022 CAs.json
-rw-rw-r-- 1 root root   1234 Feb 24 2022 EU-xxxxxx.cer
-rw-rw-r-- 1 root root   1234 Feb 24 2022 EU-xxxxxx.cer

Important

You will likely need the original osplm.ini file and not the one which provided with the library demo. The eusphpe extension is compiled for x86_64 architecture, so it can't run on ARM natively.