NAME
Crypt::Bear::AES_CTR::DRBG - AESCTR-DRBG PRNG in BearSSL
VERSION
version 0.002
SYNOPSIS
my $prng = Crypt::Bear::AESCTR_DRBG('0123456789ABCDEF');
$prng->system_seed;
say unpack 'H*', $prng->generate(16);
DESCRIPTION
AESCTR_DRBG is a custom PRNG based on AES-128 in CTR mode. This is meant to be used only in situations where you are desperate for speed, and have an hardware-optimized AES/CTR implementation. Whether this will yield perceptible improvements depends on what you use the pseudorandom bytes for, and how many you want; for instance, RSA key pair generation uses a substantial amount of randomness, and using AESCTR_DRBG instead of HMAC_DRBG yields a 15 to 20% increase in key generation speed on a recent x86 CPU (Intel Core i7-6567U at 3.30 GHz).
Internally, it uses CTR mode with successive counter values, starting at zero (counter value expressed over 128 bits, big-endian convention). The counter is not allowed to reach 32768; thus, every 32768*16 bytes at most, the update()
function is run (on an empty seed, if none is provided). The update()
function computes the new AES-128 key by applying a custom hash function to the concatenation of a state-dependent word (encryption of an all-one block with the current key) and the new seed. The custom hash function uses Hirose's construction over AES-256.
METHODS
new($seed)
Creates a new AES_DRBG
pseudo random generator based on the given $seed
.
AUTHOR
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.