Definition at line 9 of file MacInterface.php.
Construct a new context to generate a Message Authentication Code.
- Parameters
-
MacEnum | $macAlgorithm | Algorithm to use to produce the message authentication code. |
SubAlgorithmAbstractEnum | $innerAlgorithm | Inner algorithm used during generation. This should be either an instance of CipherEnum or MacEnum, depending on the value for the $macAlgorithm parameter. |
- Warning
- For MAC algorithms that use ciphers, the cipher must be configured to use the Electronic Codebook (ECB) mode. Other modes of operations will result in garbage output.
- Parameters
-
string | $key | Secret key used to produce the Message Authentication Code. |
string | $nonce | (optional) Nonce used to randomize the output. |
- Note
- Not all MAC algorithms make use of this parameter.
Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Umac, fpoirotte\Cryptal\DefaultAlgorithms\Cmac, and fpoirotte\Cryptal\DefaultAlgorithms\Poly1305.
static fpoirotte\Cryptal\Implementers\MacInterface::mac |
( |
MacEnum |
$macAlgorithm, |
|
|
SubAlgorithmAbstractEnum |
$innerAlgorithm, |
|
|
|
$key, |
|
|
|
$data, |
|
|
|
$nonce = '' , |
|
|
|
$raw = false |
|
) |
| |
|
static |
All-in-one function to quickly compute the message authentication code for a string of text.
- Parameters
-
MacEnum | $macAlgorithm | Algorithm to use to produce the message authentication code. |
SubAlgorithmAbstractEnum | $innerAlgorithm | Inner algorithm used during generation. This should be either an instance of CipherEnum or MacEnum, depending on the value for the $macAlgorithm parameter. |
string | $key | Secret key used to produce the Message Authentication Code. |
string | $data | Data for which a message authentication code will be generated. |
string | $nonce | (optional) Nonce used to randomize the output. |
- Note
- Not all MAC algorithms make use of this parameter.
- Parameters
-
bool | $raw | (optional) Whether the result should be returned in raw form (true ) or using its hexadecimal representation (false ). Defaults to false . |
- Return values
-
string | Message Authentication Code for the given data. |
Implemented in fpoirotte\Cryptal\Implementers\AbstractMac.
The documentation for this interface was generated from the following file: