2017 © Pedro Peláez
 

library gcm

A PHP library for Galois/Counter Mode encryption with AES.

image

sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  • Friday, December 8, 2017
  • by sop
  • Repository
  • 1 Watchers
  • 1 Stars
  • 840 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 8 % Grown

The README.md

GCM

Build Status Scrutinizer Code Quality Coverage Status License, (*1)

A PHP library for Galois/Counter Mode (GCM) encryption., (*2)

Supports AES-GCM with 128, 192 and 256-bit key sizes and specified authentication tag lengths., (*3)

Requirements

  • PHP >=7.2
  • openssl
  • hash
  • gmp

Installation

This library is available on Packagist., (*4)

composer require sop/gcm

Code examples

Here are some simple usage examples. Namespaces are omitted for brevity., (*5)

Encrypt

Encrypt a message with additional authenticated data, using a 128-bit key., (*6)

[$ciphertext, $auth_tag] = AESGCM::encrypt(
    'Meet me at the pier at midnight.',
    'Additional info', 'some 128 bit key', 'random iv-string');
echo bin2hex($ciphertext) . "\n" . bin2hex($auth_tag);

Outputs:, (*7)

5a24cfccf2e6c7763f71cd2ef6bcaa78385b16328593a93a43146d587e314ed8
389cc23f815d453686915530937d2053

See /examples for a detailed version., (*8)

Decrypt

Decrypt a ciphertext created above. Additional authenticated data must be the same, otherwise authentication fails and an exception shall be thrown., (*9)

$plaintext = AESGCM::decrypt($ciphertext, $auth_tag,
    'Additional info', 'some 128 bit key', 'random iv-string');
echo $plaintext;

Outputs:, (*10)

Meet me at the pier at midnight.

See /examples for a detailed version., (*11)

Using explicit cipher method and tag length

Encrypt a message without additional authenticated data using AES-192 as an underlying cipher and produce a 104-bit (13 bytes) authentication tag., (*12)

$key = '012345678901234567890123'; // 192-bit encryption key
$iv = hex2bin('beadfacebadc0fee'); // random initialization vector
$gcm = new GCM(new AES192Cipher(), 13);
[$ciphertext, $auth_tag] = $gcm->encrypt('Secret message.', '', $key, $iv);
echo bin2hex($ciphertext) . "\n" . bin2hex($auth_tag);

Outputs:, (*13)

7bcd4e423016213c60a3c0a3e3fc0c
027b14cfea0a2307649fc67b1d

Decrypting the output from above., (*14)

$plaintext = $gcm->decrypt($ciphertext, $auth_tag, '', $key, $iv);
echo $plaintext;

Outputs:, (*15)

Secret message.

References

License

This project is licensed under the MIT License., (*16)

The Versions

08/12 2017

dev-master

9999999-dev https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • ext-openssl *
  • ext-gmp *
  • php >=7.0
  • ext-hash *

 

The Development Requires

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

28/11 2017

2.0.0

2.0.0.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=7.0
  • ext-openssl *
  • ext-gmp *

 

The Development Requires

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

03/08 2017

1.0.2

1.0.2.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

22/06 2016

1.0.1

1.0.1.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

20/06 2016

1.0.0

1.0.0.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

01/06 2016

0.2.2

0.2.2.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

30/05 2016

0.2.1

0.2.1.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

27/05 2016

0.2.0

0.2.0.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois

27/05 2016

0.1.0

0.1.0.0 https://github.com/sop/gcm

A PHP library for Galois/Counter Mode encryption with AES.

  Sources   Download

MIT

The Requires

  • php >=5.6.3
  • ext-openssl *
  • ext-gmp *

 

by Joni Eskelinen

encrypt decrypt aes gcm galois counter mode aes-gcm galois