Gmac
in package
Uses
NeedsTrait
Class Gmac
Table of Contents
- BLOCK_SIZE = 16
- $buf : ByteArray
- $bufLength : int
- $h : ByteArray
- $hf : ByteArray
- $key : Key
- $x : ByteArray
- __construct() : mixed
- Gmac constructor.
- finish() : ByteArray
- Finish processing the authentication tag.
- flush() : self
- Finish processing any leftover bytes in the internal buffer.
- needs() : mixed
- Preconditions, postconditions, and loop invariants are very useful for safe programing. They also document the specifications.
- update() : self
- Update the object with some data.
- bit() : int
- Get a specific bit from the provided array, at the given index.
- blockMultiply() : ByteArray
- Galois Field Multiplication
Constants
BLOCK_SIZE
public
mixed
BLOCK_SIZE
= 16
Properties
$buf
protected
ByteArray
$buf
$bufLength
protected
int
$bufLength
= 0
$h
protected
ByteArray
$h
$hf
protected
ByteArray
$hf
$key
protected
Key
$key
$x
protected
ByteArray
$x
Methods
__construct()
Gmac constructor.
public
__construct(Key $aesKey, string $nonce[, int $keySize = 256 ]) : mixed
Parameters
- $aesKey : Key
- $nonce : string
- $keySize : int = 256
Return values
mixed —finish()
Finish processing the authentication tag.
public
finish(int $aadLength, int $ciphertextLength) : ByteArray
This method mutates this Gmac object (effectively resetting it).
Parameters
- $aadLength : int
- $ciphertextLength : int
Return values
ByteArray —flush()
Finish processing any leftover bytes in the internal buffer.
public
flush() : self
Return values
self —needs()
Preconditions, postconditions, and loop invariants are very useful for safe programing. They also document the specifications.
public
static needs( $condition, $errorMessage[, null $exceptionClass = null ]) : mixed
This function is to help simplify the semantic burden of parsing these constructions.
Instead of constructions like if (!(GOOD CONDITION)) { throw new \Exception('condition not true'); }
you can write: needs(GOOD CONDITION, 'condition not true');
Parameters
Return values
mixed —update()
Update the object with some data.
public
update(ByteArray $blocks) : self
This method mutates this Gmac object.
Parameters
- $blocks : ByteArray
Return values
self —bit()
Get a specific bit from the provided array, at the given index.
protected
bit(ByteArray $x, int $i) : int
[01234567], 8+[01234567], 16+[01234567], ...
Parameters
- $x : ByteArray
- $i : int
Return values
int —blockMultiply()
Galois Field Multiplication
protected
blockMultiply(ByteArray $x, ByteArray $y) : ByteArray
This function is the critical path that must be constant-time in order to avoid timing side-channels against AES-GCM.
The contents of each are always calculated, regardless of the branching condition, to prevent another kind of timing leak.