Revision 9476, 1.3 kB
(checked in by daisuke, 6 years ago)

lang/perl/CryptDHGMP; slightly redo method aliasing


Property svn:keywords set to
Id

Line  

1  # $Id$ 

2  

3  package Crypt::DH::GMP::Compat; 

4  

5  package # hide from PAUSE 

6  Crypt::DH; 

7  use strict; 

8  use warnings; 

9  no warnings 'redefine'; 

10  use vars qw(@ISA); 

11  

12  # Add Crypt::DH::GMP as Crypt::DH's parent, and redefine all methods 

13  BEGIN 

14  { 

15  unshift @ISA, 'Crypt::DH::GMP'; 

16  

17  *Crypt::DH::new = sub { shift>SUPER::new(@_) }; 

18  *Crypt::DH::g = sub { 

19  my $self = shift; 

20  if (@_) { 

21  $_[0] = ref $_[0] ? $_[0]>bstr : $_[0]; 

22  } 

23  return Math::BigInt>new( $self>SUPER::g(@_) ); 

24  }; 

25  *Crypt::DH::p = sub { 

26  my $self = shift; 

27  if (@_) { 

28  $_[0] = ref $_[0] ? $_[0]>bstr : $_[0]; 

29  } 

30  return Math::BigInt>new($self>SUPER::p(@_)) 

31  }; 

32  *Crypt::DH::pub_key = sub { Math::BigInt>new(shift>SUPER::pub_key(@_)) }; 

33  *Crypt::DH::priv_key = sub { Math::BigInt>new(shift>SUPER::priv_key(@_)) }; 

34  *Crypt::DH::generate_keys = \&Crypt::DH::GMP::generate_keys; 

35  *Crypt::DH::compute_key = \&Crypt::DH::GMP::compute_key; 

36  *Crypt::DH::compute_secret = \&Crypt::DH::compute_key; 

37  } 

38  

39  1; 

40  

41  __END__ 

42  

43  =head1 NAME 

44  

45  Crypt::DH::GMP::Compat  Compatibility Mode For Crypt::DH 

46  

47  =head1 SYNOPSIS 

48  

49  use Crypt::DH; 

50  use Crypt::DH::GMP qw(compat); 

51  

52  =head1 DESCRIPTION 

53  

54  Crypt::DH::GMP::Compat is a very invasive module that rewrites Crypt::DH's 

55  @ISA and method names so that it uses Crypt::DH::GMP 

56  

57  =cut 
