|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* The authentication encryption output data object. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace CryptoManana\DataStructures; |
|
8
|
|
|
|
|
9
|
|
|
use \CryptoManana\Core\Abstractions\DataStructures\AbstractBasicStructure as BasicDataStructure; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class AuthenticatedCipherData - The authentication cipher data structure. |
|
13
|
|
|
* |
|
14
|
|
|
* @package CryptoManana\DataStructures |
|
15
|
|
|
* |
|
16
|
|
|
* @property string $cipherData The encrypted data information. |
|
17
|
|
|
* @property string $authenticationTag The message authentication code (tag). |
|
18
|
|
|
*/ |
|
19
|
|
|
class AuthenticatedCipherData extends BasicDataStructure |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* The encrypted information property storage. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string The encrypted data information. |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $cipherData = ''; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The message authentication code property storage. |
|
30
|
|
|
* |
|
31
|
|
|
* @var string The message authentication code (tag). |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $authenticationTag = ''; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Authenticated cipher data constructor. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $encryptedData The encrypted data information. |
|
39
|
|
|
* @param string $digestionTag The message authentication code (tag). |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct($encryptedData = '', $digestionTag = '') |
|
42
|
|
|
{ |
|
43
|
|
|
if (is_string($encryptedData)) { |
|
|
|
|
|
|
44
|
|
|
$this->cipherData = $encryptedData; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (is_string($digestionTag)) { |
|
|
|
|
|
|
48
|
|
|
$this->authenticationTag = $digestionTag; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Authenticated cipher data destructor |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __destruct() |
|
56
|
|
|
{ |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* The authenticated cipher data string representation. |
|
61
|
|
|
* |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
|
public function __toString() |
|
65
|
|
|
{ |
|
66
|
|
|
return 'encrypted : ' . $this->cipherData . ' | tag : ' . $this->authenticationTag; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|