cryptal  latest
Cryptography Abstraction Layer
fpoirotte\Cryptal\Implementers\MacInterface Interface Reference
+ Inheritance diagram for fpoirotte\Cryptal\Implementers\MacInterface:

Public Member Functions

 __construct (MacEnum $macAlgorithm, SubAlgorithmAbstractEnum $innerAlgorithm, $key, $nonce= '')
 
- Public Member Functions inherited from fpoirotte\Cryptal\ContextBasedInterface
 __toString ()
 
 finalize ($raw=false)
 
 update ($data)
 

Static Public Member Functions

static mac (MacEnum $macAlgorithm, SubAlgorithmAbstractEnum $innerAlgorithm, $key, $data, $nonce= '', $raw=false)
 

Detailed Description

Definition at line 9 of file MacInterface.php.

Constructor & Destructor Documentation

fpoirotte\Cryptal\Implementers\MacInterface::__construct ( MacEnum  $macAlgorithm,
SubAlgorithmAbstractEnum  $innerAlgorithm,
  $key,
  $nonce = '' 
)

Construct a new context to generate a Message Authentication Code.

Parameters
MacEnum$macAlgorithmAlgorithm to use to produce the message authentication code.
SubAlgorithmAbstractEnum$innerAlgorithmInner 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$keySecret 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.

Member Function Documentation

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$macAlgorithmAlgorithm to use to produce the message authentication code.
SubAlgorithmAbstractEnum$innerAlgorithmInner algorithm used during generation. This should be either an instance of CipherEnum or MacEnum, depending on the value for the $macAlgorithm parameter.
string$keySecret key used to produce the Message Authentication Code.
string$dataData 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
stringMessage Authentication Code for the given data.

Implemented in fpoirotte\Cryptal\Implementers\AbstractMac.


The documentation for this interface was generated from the following file: