PHP Classes

PHP AES GCM Encryption SIV: Encrypt data with pure PHP code for Rijndael AES

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 152 All time: 9,068 This week: 67Up
Version License PHP version Categories
php_aes-gcm-siv 1.0The PHP License5PHP 5, Cryptography
Description 

Author

This class can encrypt data with pure PHP code for Rijndael AES-GCM_SIV.

It can encrypt data using a given key data, initialization vector data, and additional authenticated data.

The class can also decrypt the encrypted result to revert to the original data using the same parameters.

Picture of Jose Luis Lucas
Name: Jose Luis Lucas <contact>
Classes: 10 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 7x

Documentation

  • Copyright I-2019 denobisipsis

FAST AES-GCM-SIV code with each step explained for PHP > 5.6.3

Based on draft 9 https://tools.ietf.org/id/draft-irtf-cfrg-gcmsiv-09.html

USAGE

$text	= "Hello World";
$aad	= "7576f7028ec6eb5ea7e298342a94d4b202b370ef9768ec6561c4fe6b7e7296fa859c21";
$key	= "f901cfe8a69615a93fdf7a98cad48179";
$nonce	= "6245709fb18853f68d833640";

$x=new AES_GCM_SIV;

$x->init($key,$nonce,$aad);

$cipher	= $x->AES_GCM_SIV_encrypt($text);

$text 	= $x->AES_GCM_SIV_decrypt($cipher);

THERE IS A VECTOR-TEST to validate THIS AES-GCM-SIV, SIMPLY RUN check_AES_GCM_SIV()

computing time on x5690 PHP 7.3 x64


https://raw.githubusercontent.com/denobisipsis/PHP_AES-GCM-SIV/master/aes_gcm_siv_test_draft.09.json			 0.010354301 s

more test vectors

https://raw.githubusercontent.com/Metalnem/aes-gcm-siv/master/src/Cryptography.Tests/Vectors/aes-128-gcm-siv.json	 0.004997403 s
https://raw.githubusercontent.com/Metalnem/aes-gcm-siv/master/src/Cryptography.Tests/Vectors/aes-256-gcm-siv.json	 0.005012505 s
https://raw.githubusercontent.com/Metalnem/aes-gcm-siv/master/src/Cryptography.Tests/Vectors/authentication-1000.json	 1.699876871 s
https://raw.githubusercontent.com/Metalnem/aes-gcm-siv/master/src/Cryptography.Tests/Vectors/encryption-1000.json	 1.721209409 s
https://raw.githubusercontent.com/Metalnem/aes-gcm-siv/master/src/Cryptography.Tests/Vectors/random-keys-10000.json	 1.078780167 s

Encryption time average 30 µs	(16 byte block)	550Kb/s


Support modes:

- AES Galois Counter Mode nonce misuse-resistant (GCM-SIV)

Adenda--> dot.vs.gfmul128.php

https://github.com/denobisipsis/PHP_AES-GCM-SIV/blob/master/dot.vs.gfmul128.php

COMPUTING ON GALOIS 128-FIELDS

Functions coded:

as defined in https://www.intel.cn/content/dam/www/public/us/en/documents/white-papers/carry-less-multiplication-instruction-in-gcm-mode-paper.pdf

- PCLMULQDQ 	
- GFMUL     

and as defined in https://www.ietf.org/id/draft-irtf-cfrg-gcmsiv-09.txt


- mulX_POLYVAL 	
- mulX_GHASH 	

- dot_siv_ghash
- dot_siv_polyval (in binary mode, fastest)

- dot_big_math (using longs longs mode 1)
- dot2         (using longs longs mode 2, faster)

License

This code is placed in the public domain.


  Files folder image Files (4)  
File Role Description
Plain text file AES-GCM-SIV.php Class Class source
Accessible without login Plain text file aes_gcm_siv_test_draft.09.json Data Auxiliary data
Accessible without login Plain text file dot.vs.gfmul128.php Aux. Auxiliary script
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:152
This week:0
All time:9,068
This week:67Up