Crypt-Sodium-XS
view release on metacpan or search on metacpan
lib/Crypt/Sodium/XS/MemVault.pm view on Meta::CPAN
my $new_mv = $mv->clone;
Returns a new object C<$new_mv> with identical flags and contents to the
original C<$mv>.
=head2 compare
B<!!WARNING!!>: The results of this comparison method can be used to leak
information about the protected memory. If one can make arbitrary comparisons
and has any visibility to the result, the protected data can be determined in
(nbits - trailing_zero_bits) iterations! For a 256-bit key, that means it takes
no more than 256 tries to extract the key. This method is fixed-time, but the
only safe use of the result is whether it equals 0 or not, and L</memcmp> is a
better way to determine equality.
$mv->compare($bytes, $size);
$mv->compare($other_mv, $size);
Returns C<0> if the bytes are equal, C<-1> if C<$mv> is less than C<$other_mv>
(or C<$bytes>), or C<1> if C<$mv> is greater. This method runs in fixed-time
(for a given size), and compares bytes as little-endian arbitrary-length
( run in 0.786 second using v1.01-cache-2.11-cpan-96521ef73a4 )