Class AesGcm
- Aws\Crypto\Polyfill\AesGcm uses Aws\Crypto\Polyfill\NeedsTrait
- Namespace: Aws\Crypto\Polyfill
- Located at Crypto/Polyfill/AesGcm.php
Class AesGcm
This provides a polyfill for AES-GCM encryption/decryption, with caveats:
- Only 96-bit nonces are supported.
- Only 128-bit authentication tags are supported. (i.e. non-truncated)
Supports AES key sizes of 128-bit, 192-bit, and 256-bit.
Methods Summary
-
__construct ( Aws\Crypto\Polyfill\Key $aesKey, int $keySize = 256, int $blockSize = 8192 )
AesGcm constructor.
-
static
encrypt ( string $plaintext, string $nonce, Aws\Crypto\Polyfill\Key $key, string $aad, string & $tag, int $keySize = 256, int $blockSize = 8192 )
Encryption interface for AES-GCM
-
static
decrypt ( string $ciphertext, string $nonce, Aws\Crypto\Polyfill\Key $key, string $aad, string & $tag, int $keySize = 256, int $blockSize = 8192 )
Decryption interface for AES-GCM
Methods used from Aws\Crypto\Polyfill\NeedsTrait
Methods Details
__construct (
Aws\Crypto\Polyfill\Key
$aesKey,
integer
$keySize = 256,
integer
$blockSize = 8192
)
AesGcm constructor.
Parameters
Aws\Crypto\Polyfill\Key |
$aesKey | |
integer | $keySize = 256 | |
integer | $blockSize = 8192 |
Exceptions
Aws\Exception\CryptoPolyfillException |
InvalidArgumentException |
RangeException |
static
string
encrypt (
string
$plaintext,
string
$nonce,
Aws\Crypto\Polyfill\Key
$key,
string
$aad,
string
& $tag,
integer
$keySize = 256,
integer
$blockSize = 8192
)
Encryption interface for AES-GCM
Parameters
string | $plaintext | Message to be encrypted |
string | $nonce | Number to be used ONCE |
Aws\Crypto\Polyfill\Key |
$key | AES Key |
string | $aad | Additional authenticated data |
string& | $tag | $tag Reference to variable to hold tag |
integer | $keySize = 256 | Key size (bits) |
integer | $blockSize = 8192 | Block size (bytes) -- How much memory to buffer |
Returns
string |
Exceptions
InvalidArgumentException |
static
string
decrypt (
string
$ciphertext,
string
$nonce,
Aws\Crypto\Polyfill\Key
$key,
string
$aad,
string
& $tag,
integer
$keySize = 256,
integer
$blockSize = 8192
)
Decryption interface for AES-GCM
Parameters
string | $ciphertext | Ciphertext to decrypt |
string | $nonce | Number to be used ONCE |
Aws\Crypto\Polyfill\Key |
$key | AES key |
string | $aad | Additional authenticated data |
string& | $tag | Authentication tag |
integer | $keySize = 256 | Key size (bits) |
integer | $blockSize = 8192 | Block size (bytes) -- How much memory to buffer |
Returns
string Plaintext |
Exceptions
Aws\Exception\CryptoPolyfillException |
InvalidArgumentException |