The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

VOMS::Lite::RSAKey - Perl extension for RSA Key Generation

SYNOPSIS

  use VOMS::Lite::RSAKey;
  %RSAKey = %{ VOMS::Lite::RSAKey::Create(%inputref) };

DESCRIPTION

VOMS::Lite::RSAKey::Create

  Generates an RSA key using the MillerRabin Prime search for probable primes.
  %inputref may have the following set
    Bits => bits e.g. 512
    RandomFile /path/to/random e.g. /dev/random or /dev/urandom,
               or a reference to a function where:
                 $_[0] contains the number of bytes of random
                 Returns a string of random bytes.
    Verbose => 'y'

  returns
    A reference to a hash: either:
           Errors ( a regernec to an array of errors )
           - or -
           Modulus, PublicExponent, PrivateExponent, Prime1, Prime2,
           Exponent1, Exponent2, Phi
           and 
           Bits = the number of bits for generated key

VOMS::Lite::RSAKey::Random

  Math::BigInt Random ( \%inputref );
  where %inputref consists of:
    Bits => number of bits of random number to generate e.g. 256
    - or -
    Upper => upper limit of random number to generate (scalar or Math::BigInt)
    Lower => lower limit (default = 0)

    Parity => "Odd" | "Even"

  returns Math::BigInt object;

VOMS::Lite::RSAKey::Finder

  Finder( \%inputref ) finds the next 'probable' prime number after a given number.
  where %inputref consists of:
    Start => (number scalar or Math::BigInt to start searching at)
    Tests => a string consisting of DFSM (tests are performed in the order specified)
               D is VOMS::Lite::RSAKey::DivisionTest
               F is VOMS::Lite::RSAKey::FermatTest
               S is VOMS::Lite::RSAKey::SolovayStrassenTest
               M is VOMS::Lite::RSAKey::MillerRabinTest
             Default is 'M'.
    %inputref is passed through as an input to the above tests.

    Returns reference to hash which includes either 
      Errors a reference to an array of errors
       - or -
      Candidate => Math::BigInt prime candidate

VOMS::Lite::RSAKey::DivisionTest

  DivisionTest( \%inputref ) tests the candidate for primality 
  by division by known small primes (upto the first 10000).
  This is a slow implementation.
  %inputref consist of
    Candidate => scalar or Math::BigInt to test
    D = the number of prime divisors to test; the default is the maximum 10000
  returns 0 if Candidate has small prime divisor
  otherwise returns 1

VOMS::Lite::RSAKey::FermatTest

  FermatTest( \%inputref ) tests the candidate for probable primality
  This is not a good test
  %inputref consist of
    Candidate => scalar or Math::BigInt to test
    F = the number of random divisors to test; the default is 10
  returns 0 if composite
  returns 1 if probably prime

VOMS::Lite::RSAKey::SolovayStrassenTest

  SolovayStrassenTest( \%inputref ) tests the candidate for probable primality
  This is a slow test and not as good as the MillerRabinTest
  %inputref consist of
    Candidate => scalar or Math::BigInt to test
    S = the number of random divisors to test; the default is 10
  returns 0 if composite
  returns 1 if probably prime

VOMS::Lite::RSAKey::JacobiSymbol

  Used by SolovayStrassenTest

VOMS::Lite::RSAKey::MillerRabinTest

  MillerRabinTest( \%inputref ) tests the candidate for probable primality
  %inputref consist of
    Candidate => scalar or Math::BigInt to test
    M = the number of random divisors to test; the default is
        calculated based upon table Handbook of Applied Cryptography table 4.4
  returns 0 if composite
  returns 1 if probably prime

EXPORT

None by default;

SEE ALSO

http://www.rcs.manchester.ac.uk/research/sarongs

This module was originally designed for the SARoNGS project at The University of Manchester for the NGS. http://www.rcs.manchester.ac.uk/research/sarongs http://www.ngs.ac.uk

Handbook of Applied Cryptography, CRC Press, ISBN: 0-8493-8523-7, October 1996.

AUTHOR

Mike Jones <mike.jones@manchester.ac.uk>

COPYRIGHT AND LICENSE

Copyright (C) 2006 2010 by Mike Jones

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.