PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-01-20 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 103 This week: 3All time: 9,093 This week: 152Up
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.

Name: Jose Luis Lucas <contact>
Classes: 4 packages by
Country: Spain Spain
Age: ???
All time rank: 3831100 in Spain Spain
Week rank: 78 Up1 in Spain Spain Up
Innovation award
Innovation award
Nominee: 1x

Details
  • 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  
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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:103
This week:3
All time:9,093
This week:152Up