Skip to content

Commit

Permalink
Tests added and PHPDoc updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Morselli committed Apr 28, 2016
1 parent b6009a2 commit 7d415c6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/AESGCM.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
final class AESGCM
{
/**
* @param string $K Key encryption key
* @param string $IV Initialization vector
* @param string $P Data to encrypt
* @param string $A Additional Authentication Data
* @param string $K Key encryption key
* @param string $IV Initialization vector
* @param null|string $P Data to encrypt (null for authentication)
* @param null|string $A Additional Authentication Data
*
* @return array
*/
Expand All @@ -38,13 +38,13 @@ public static function encrypt($K, $IV, $P, $A)
}

/**
* @param string $K Key encryption key
* @param string $IV Initialization vector
* @param string $C Data to encrypt
* @param string $A Additional Authentication Data
* @param string $T Tag
* @param string $K Key encryption key
* @param string $IV Initialization vector
* @param string|null $C Data to encrypt (null for authentication)
* @param string|null $A Additional Authentication Data
* @param string $T Tag
*
* @return array
* @return string
*/
public static function decrypt($K, $IV, $C, $A, $T)
{
Expand Down
64 changes: 64 additions & 0 deletions tests/NistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,70 @@ public function dataVectors()
hex2bin('3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710'), // Expected C
hex2bin('2519498e80f1478f37ba55bd6d27618c'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39'), // P
hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2'), // A
hex2bin('cafebabefacedbad'), // IV
hex2bin('0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7'), // Expected C
hex2bin('65dcc57fcf623a24094fcca40d3533f8'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39'), // P
hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2'), // A
hex2bin('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b'), // IV
hex2bin('d27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b'), // Expected C
hex2bin('dcf566ff291c25bbb8568fc3d376a6d9'), // Expected T
],
[
hex2bin('0000000000000000000000000000000000000000000000000000000000000000'), // K
null, // P
null, // A
hex2bin('000000000000000000000000'), // IV
null, // Expected C
hex2bin('530f8afbc74536b9a963b4f1c4cb738b'), // Expected T
],
[
hex2bin('0000000000000000000000000000000000000000000000000000000000000000'), // K
hex2bin('00000000000000000000000000000000'), // P
null, // A
hex2bin('000000000000000000000000'), // IV
hex2bin('cea7403d4d606b6e074ec5d3baf39d18'), // Expected C
hex2bin('d0d1c8a799996bf0265b98b5d48ab919'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255'), // P
null, // A
hex2bin('cafebabefacedbaddecaf888'), // IV
hex2bin('522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad'), // Expected C
hex2bin('b094dac5d93471bdec1a502270e3cc6c'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39'), // P
hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2'), // A
hex2bin('cafebabefacedbaddecaf888'), // IV
hex2bin('522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662'), // Expected C
hex2bin('76fc6ece0f4e1768cddf8853bb2d551b'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39'), // P
hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2'), // A
hex2bin('cafebabefacedbad'), // IV
hex2bin('c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f'), // Expected C
hex2bin('3a337dbf46a792c45e454913fe2ea8f2'), // Expected T
],
[
hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308'), // K
hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39'), // P
hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2'), // A
hex2bin('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b'), // IV
hex2bin('5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f'), // Expected C
hex2bin('a44a8266ee1c8eb0c8b5d4cf5ae9f19a'), // Expected T
],
];
}
}

0 comments on commit 7d415c6

Please sign in to comment.