Crypt::DSA::GMP::Util(3)

NAME
Crypt::DSA::GMP::Util - DSA Utility functions

SYNOPSIS
    use Crypt::DSA::GMP::Util qw( func1 func2 ... );

DESCRIPTION
Crypt::DSA::GMP::Util contains a set of exportable utility functions used through the Crypt::DSA::GMP module.

  bitsize($n)
Returns the number of bits in the integer $n.

  bin2mp($string)
Given a string $string of any length, treats the string as a base-256 representation of an integer, and returns that integer.

  mp2bin($int)
Given an integer $int (maybe a Math::BigInt object), returns an octet string representation (e.g. a string where each byte is a base-256 digit of the integer).

  mod_exp($a, $exp, $n)
Computes $a ^ $exp mod $n and returns the value.

  mod_inverse($a, $n)
Computes the multiplicative inverse of $a mod $n and returns the value.

  randombytes($n)
Returns $n random bytes from the entropy source. The entropy source is a Crypt::Random::Seed source.

An optional boolean second argument indicates whether the data is being used for key generation, hence the best possible randomness is used. If this argument is not present or is false, then the best non-blocking source will be used.

  makerandom
  $n = makerandom(Size => 512);

Takes a Size argument and creates a random Math::BigInt with exactly that number of bits using data from "randombytes". The high order bit will always be set.

Also takes an optional KeyGen argument that is given to "randombytes".

  makerandomrange
  $n = makerandomrange(Max => $max);  # 0 <= $n <= $max

Returns a Math::BigInt uniformly randomly selected between 0 and $max. Random data is provided by "randombytes".

Also takes an optional KeyGen argument that is given to "randombytes".

AUTHOR & COPYRIGHTS
See Crypt::DSA::GMP for author, copyright, and license information.