2017 © Pedro Peláez
 

library php-secure-session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

image

ezimuel/php-secure-session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

  • Thursday, February 1, 2018
  • by ezimuel
  • Repository
  • 21 Watchers
  • 349 Stars
  • 1,168 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 80 Forks
  • 0 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

PHP-Secure-Session

Build Status Coverage Status, (*1)

About

This project adds encryption to internal PHP save handlers. It uses OpenSSL extension to provide encryption with AES-256 and authentication using HMAC-SHA-256., (*2)

The SecureHandler class extends the default SessionHandler of PHP and it adds only an encryption layer on the internal save handler. The session management logic remains the same, that means you can use SecureSession with all the PHP session handlers like 'file', 'sqlite', 'memcache' or 'memcached' which are provided by PHP extensions., (*3)

Installation

You can install this library using composer with the following command:, (*4)

composer require ezimuel/php-secure-session

After that the PHP-Secure-Session handler will be automatically executed in your project when consuming the vendor/autoload.php file., (*5)

Usage

You don't have to do nothing to consume this library, the SecureHandler is automatically registered with session_set_save_handler() during the composer autoload., (*6)

How it works

The session data are encrypted using a random key stored in a cookie variable starting with the prefix KEY_., (*7)

This random key is generated using the random_bytes() function of PHP 7. For PHP 5 versions we used the paragonie/random_compat project that is a polyfill for random_bytes()., (*8)

We also generated a random authentication key stored in the same cookie variable. The value stored in the KEY_ cookie is the Base64 representation of the encryption key concatenated with the authentication key., (*9)

Demo

You can test the PHP-Secure-Session using the test/demo/index.php example. You can run the demo using the internal web server of PHP with the following command:, (*10)

php -S 0.0.0.0:8000 -t test/demo

If you open the browser to localhost:8000 you will see the demo in action., (*11)


Copyright 2011-2018 by Enrico Zimuel, (*12)

Released under the MIT License, (*13)

The Versions

01/02 2018

dev-master

9999999-dev https://github.com/ezimuel/PHP-Secure-Session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

authentication encrypt session

01/02 2018

v1.1.0

1.1.0.0 https://github.com/ezimuel/PHP-Secure-Session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

authentication encrypt session

30/03 2017

v1.0.1

1.0.1.0 https://github.com/ezimuel/PHP-Secure-Session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

authentication encrypt session

27/01 2017

v1.0.0

1.0.0.0 https://github.com/ezimuel/PHP-Secure-Session

Encrypt and authenticate PHP session data using AES-256 and HMAC-SHA256

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

authentication encrypt session